summaryrefslogtreecommitdiff
path: root/libtmdb/testModels.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libtmdb/testModels.cpp')
-rw-r--r--libtmdb/testModels.cpp65
1 files changed, 35 insertions, 30 deletions
diff --git a/libtmdb/testModels.cpp b/libtmdb/testModels.cpp
index 0557017..3b1b289 100644
--- a/libtmdb/testModels.cpp
+++ b/libtmdb/testModels.cpp
@@ -4,6 +4,7 @@
#include <tmdb-models.h>
#include <slicer/slicer.h>
#include <slicer/json/serializer.h>
+#include <definedDirs.h>
namespace std {
std::ostream &
@@ -14,13 +15,9 @@ namespace std {
}
};
-#define XSTR(s) STR(s)
-#define STR(s) #s
-const boost::filesystem::path root(XSTR(ROOT));
-
-BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json )
+BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json_breakingbad )
{
- auto results = Slicer::DeserializeAny<Slicer::JsonFileDeserializer, TMDb::SearchMultiResultsPtr>((root / "samples" / "searchMulti_breakingBad.json").string());
+ auto results = Slicer::DeserializeAny<Slicer::JsonFileDeserializer, TMDb::SearchMultiResultsPtr>((rootDir / "samples" / "searchMulti_breakingBad.json").string());
BOOST_REQUIRE_EQUAL(1, results->Page);
BOOST_REQUIRE_EQUAL(1, results->TotalPages);
BOOST_REQUIRE_EQUAL(3, results->TotalResults);
@@ -28,7 +25,7 @@ BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json )
BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchTv", results->Results[0]->ice_id());
auto tv = TMDb::SearchMatchTvPtr::dynamicCast(results->Results[0]);
BOOST_REQUIRE_EQUAL("Breaking Bad", tv->Name);
- BOOST_REQUIRE_EQUAL("/4yMXf3DW6oCL0lVPZaZM2GypgwE.jpg", tv->PosterPath);
+ BOOST_REQUIRE_EQUAL("/1yeVJox3rjo2jBKrrihIMj7uoS9.jpg", tv->PosterPath);
BOOST_REQUIRE_EQUAL(1396, tv->Id);
BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchMovie", results->Results[1]->ice_id());
@@ -36,32 +33,40 @@ BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json )
BOOST_REQUIRE_EQUAL("No Half Measures: Creating the Final Season of Breaking Bad", movie->Title);
BOOST_REQUIRE_EQUAL("/8OixSR45U5dbqv8F0tlspmTbXxN.jpg", movie->PosterPath);
BOOST_REQUIRE_EQUAL(239459, movie->Id);
+}
+
+BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json_bradpitt )
+{
+ auto results = Slicer::DeserializeAny<Slicer::JsonFileDeserializer, TMDb::SearchMultiResultsPtr>((rootDir / "samples" / "searchMulti_bradPitt.json").string());
+ BOOST_REQUIRE_EQUAL(1, results->Page);
+ BOOST_REQUIRE_EQUAL(1, results->TotalPages);
+ BOOST_REQUIRE_EQUAL(1, results->TotalResults);
- BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchPerson", results->Results[2]->ice_id());
- auto person = TMDb::SearchMatchPersonPtr::dynamicCast(results->Results[2]);
+ BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchPerson", results->Results[0]->ice_id());
+ auto person = TMDb::SearchMatchPersonPtr::dynamicCast(results->Results[0]);
BOOST_REQUIRE_EQUAL("Brad Pitt", person->Name);
BOOST_REQUIRE_EQUAL(287, person->Id);
}
BOOST_AUTO_TEST_CASE( deserialize_movie_json )
{
- auto movie = Slicer::DeserializeAny<Slicer::JsonFileDeserializer, TMDb::MoviePtr>((root / "samples" / "movie_550.json").string());
+ auto movie = Slicer::DeserializeAny<Slicer::JsonFileDeserializer, TMDb::MoviePtr>((rootDir / "samples" / "movie_550.json").string());
BOOST_REQUIRE_EQUAL(550, movie->Id);
BOOST_REQUIRE_EQUAL(false, movie->Adult);
- BOOST_REQUIRE_EQUAL("/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg", movie->BackdropPath);
- BOOST_REQUIRE_EQUAL(3, movie->Genres.size());
- BOOST_REQUIRE_EQUAL(28, movie->Genres.front().Id);
- BOOST_REQUIRE_EQUAL("Action", movie->Genres.front().Name);
+ BOOST_REQUIRE_EQUAL("/87hTDiay2N2qWyX4Ds7ybXi9h8I.jpg", movie->BackdropPath);
+ BOOST_REQUIRE_EQUAL(1, movie->Genres.size());
+ BOOST_REQUIRE_EQUAL(18, movie->Genres.front().Id);
+ BOOST_REQUIRE_EQUAL("Drama", movie->Genres.front().Name);
BOOST_REQUIRE_EQUAL(63000000, movie->Budget);
- BOOST_REQUIRE_EQUAL("http://www.fightclub.com/", movie->HomePage);
+ BOOST_REQUIRE_EQUAL("http://www.foxmovies.com/movies/fight-club", movie->HomePage);
BOOST_REQUIRE_EQUAL("tt0137523", movie->ImdbId);
BOOST_REQUIRE_EQUAL("Fight Club", movie->OriginalTitle);
- BOOST_REQUIRE_CLOSE(61151.75, movie->Popularity, 0.1);
- BOOST_REQUIRE_EQUAL("/2lECpi35Hnbpa4y46JX0aY3AWTy.jpg", movie->PosterPath);
+ BOOST_REQUIRE_CLOSE(8.202502, movie->Popularity, 0.1);
+ BOOST_REQUIRE_EQUAL("/adw6Lq9FiC9zjYEpOqfq03ituwp.jpg", movie->PosterPath);
BOOST_REQUIRE_EQUAL(295, movie->Overview.length());
- BOOST_REQUIRE_EQUAL(1, movie->ProductionCompanies.size());
- BOOST_REQUIRE_EQUAL(25, movie->ProductionCompanies.front().Id);
- BOOST_REQUIRE_EQUAL("20th Century Fox", movie->ProductionCompanies.front().Name);
+ BOOST_REQUIRE_EQUAL(6, movie->ProductionCompanies.size());
+ BOOST_REQUIRE_EQUAL(508, movie->ProductionCompanies.front().Id);
+ BOOST_REQUIRE_EQUAL("Regency Enterprises", movie->ProductionCompanies.front().Name);
BOOST_REQUIRE_EQUAL(2, movie->ProductionCountries.size());
BOOST_REQUIRE_EQUAL("DE", movie->ProductionCountries.front().Id);
BOOST_REQUIRE_EQUAL("Germany", movie->ProductionCountries.front().Name);
@@ -74,14 +79,14 @@ BOOST_AUTO_TEST_CASE( deserialize_movie_json )
BOOST_REQUIRE_EQUAL("Released", movie->Status);
BOOST_REQUIRE_EQUAL("How much can you know about yourself if you've never been in a fight?", movie->Tagline);
BOOST_REQUIRE_EQUAL("Fight Club", movie->Title);
- BOOST_REQUIRE_CLOSE(9.0999999, movie->VoteAverage, 0.01);
- BOOST_REQUIRE_EQUAL(174, movie->VoteCount);
+ BOOST_REQUIRE_CLOSE(8.2, movie->VoteAverage, 0.01);
+ BOOST_REQUIRE_EQUAL(7715, movie->VoteCount);
}
BOOST_AUTO_TEST_CASE( deserialize_tvseries_json )
{
- auto tvSeries = Slicer::DeserializeAny<Slicer::JsonFileDeserializer, TMDb::TvSeriesPtr>((root / "samples" / "tv_1396.json").string());
- BOOST_REQUIRE_EQUAL("/sIJyCJedGlZf1TId41gCtkblBGo.jpg", tvSeries->BackdropPath);
+ auto tvSeries = Slicer::DeserializeAny<Slicer::JsonFileDeserializer, TMDb::TvSeriesPtr>((rootDir / "samples" / "tv_1396.json").string());
+ BOOST_REQUIRE_EQUAL("/eSzpy96DwBujGFj0xMbXBcGcfxX.jpg", tvSeries->BackdropPath);
BOOST_REQUIRE_EQUAL(1, tvSeries->CreatedBy.size());
BOOST_REQUIRE_EQUAL(66633, tvSeries->CreatedBy.front().Id);
BOOST_REQUIRE_EQUAL("Vince Gilligan", tvSeries->CreatedBy.front().Name);
@@ -92,7 +97,7 @@ BOOST_AUTO_TEST_CASE( deserialize_tvseries_json )
BOOST_REQUIRE_EQUAL(1, tvSeries->Genres.size());
BOOST_REQUIRE_EQUAL(18, tvSeries->Genres.front().Id);
BOOST_REQUIRE_EQUAL("Drama", tvSeries->Genres.front().Name);
- BOOST_REQUIRE_EQUAL("http://www.amctv.com/shows/breaking-bad", tvSeries->HomePage);
+ BOOST_REQUIRE_EQUAL("http://www.amc.com/shows/breaking-bad", tvSeries->HomePage);
BOOST_REQUIRE_EQUAL(1396, tvSeries->Id);
BOOST_REQUIRE_EQUAL(false, tvSeries->InProduction);
BOOST_REQUIRE_EQUAL(5, tvSeries->Languages.size());
@@ -107,15 +112,15 @@ BOOST_AUTO_TEST_CASE( deserialize_tvseries_json )
BOOST_REQUIRE_EQUAL(1, tvSeries->OriginCountries.size());
BOOST_REQUIRE_EQUAL("US", tvSeries->OriginCountries.front());
BOOST_REQUIRE_EQUAL(651, tvSeries->Overview.length());
- BOOST_REQUIRE_CLOSE(7.684, tvSeries->Popularity, 0.01);
- BOOST_REQUIRE_EQUAL("/4yMXf3DW6oCL0lVPZaZM2GypgwE.jpg", tvSeries->PosterPath);
+ BOOST_REQUIRE_CLOSE(18.21, tvSeries->Popularity, 0.01);
+ BOOST_REQUIRE_EQUAL("/1yeVJox3rjo2jBKrrihIMj7uoS9.jpg", tvSeries->PosterPath);
BOOST_REQUIRE_EQUAL(6, tvSeries->Seasons.size());
BOOST_REQUIRE_EQUAL(TMDb::Date({2012, 7, 15}), tvSeries->Seasons.back().AirDate);
BOOST_REQUIRE_EQUAL(3578, tvSeries->Seasons.back().Id);
- BOOST_REQUIRE_EQUAL("/ih1JKNxEzW56azeFpEQmdu4poA4.jpg", tvSeries->Seasons.back().PosterPath);
+ BOOST_REQUIRE_EQUAL("/r3z70vunihrAkjILQKWHX0G2xzO.jpg", tvSeries->Seasons.back().PosterPath);
BOOST_REQUIRE_EQUAL(5, tvSeries->Seasons.back().SeasonNumber);
BOOST_REQUIRE_EQUAL("Ended", tvSeries->Status);
- BOOST_REQUIRE_CLOSE(9, tvSeries->VoteAverage, 0.01);
- BOOST_REQUIRE_EQUAL(72, tvSeries->VoteCount);
+ BOOST_REQUIRE_CLOSE(8.2, tvSeries->VoteAverage, 0.01);
+ BOOST_REQUIRE_EQUAL(1536, tvSeries->VoteCount);
}