#define BOOST_TEST_MODULE Deserialize #include #include #include #include #include namespace std { std::ostream & operator<<(std::ostream & o, const Ice::optional & d) { if (d) { o << *d; } return o; } std::ostream & operator<<(std::ostream & o, const TMDb::Date & d) { o << d.Year << '-' << d.Month << '-' << d.Day; return o; } }; BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json_breakingbad ) { auto results = Slicer::DeserializeAny((rootDir / "samples" / "searchMulti_breakingBad.json").string()); BOOST_REQUIRE_EQUAL(1, results->Page); BOOST_REQUIRE_EQUAL(1, results->TotalPages); BOOST_REQUIRE_EQUAL(3, results->TotalResults); BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchTv", results->Results[0]->ice_id()); auto tv = std::dynamic_pointer_cast(results->Results[0]); BOOST_REQUIRE_EQUAL("Breaking Bad", tv->Name); BOOST_REQUIRE_EQUAL("/1yeVJox3rjo2jBKrrihIMj7uoS9.jpg", tv->PosterPath); BOOST_REQUIRE_EQUAL(1396, tv->Id); BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchMovie", results->Results[1]->ice_id()); auto movie = std::dynamic_pointer_cast(results->Results[1]); 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((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[0]->ice_id()); auto person = std::dynamic_pointer_cast(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((rootDir / "samples" / "movie_550.json").string()); BOOST_REQUIRE_EQUAL(550, movie->Id); BOOST_REQUIRE_EQUAL(false, movie->Adult); 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.foxmovies.com/movies/fight-club", movie->HomePage); BOOST_REQUIRE_EQUAL("tt0137523", movie->ImdbId); BOOST_REQUIRE_EQUAL("Fight Club", movie->OriginalTitle); 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(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); BOOST_REQUIRE_EQUAL(TMDb::Date({1999, 10, 15}), movie->ReleaseDate); BOOST_REQUIRE_EQUAL(1, movie->SpokenLanguages.size()); BOOST_REQUIRE_EQUAL("en", movie->SpokenLanguages.front().Id); BOOST_REQUIRE_EQUAL("English", movie->SpokenLanguages.front().Name); BOOST_REQUIRE_EQUAL(100853753, movie->Revenue); BOOST_REQUIRE_EQUAL(139, movie->Runtime); 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(8.2, movie->VoteAverage, 0.01); BOOST_REQUIRE_EQUAL(7715, movie->VoteCount); } BOOST_AUTO_TEST_CASE( deserialize_tvseries_json ) { auto tvSeries = Slicer::DeserializeAny((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); BOOST_REQUIRE_EQUAL("/rLSUjr725ez1cK7SKVxC9udO03Y.jpg", tvSeries->CreatedBy.front().ProfilePath); BOOST_REQUIRE_EQUAL(2, tvSeries->EpisodeRunTimes.size()); BOOST_REQUIRE_EQUAL(45, tvSeries->EpisodeRunTimes.front()); BOOST_REQUIRE_EQUAL(TMDb::Date({2008, 1, 19}), tvSeries->FirstAirDate); 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.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()); BOOST_REQUIRE_EQUAL("en", tvSeries->Languages.front()); BOOST_REQUIRE_EQUAL(TMDb::Date({2013, 9, 29}), tvSeries->LastAirDate); BOOST_REQUIRE_EQUAL("Breaking Bad", tvSeries->Name); BOOST_REQUIRE_EQUAL(1, tvSeries->Networks.size()); BOOST_REQUIRE_EQUAL(174, tvSeries->Networks.front().Id); BOOST_REQUIRE_EQUAL("AMC", tvSeries->Networks.front().Name); BOOST_REQUIRE_EQUAL(62, tvSeries->NumberOfEpisodes); BOOST_REQUIRE_EQUAL(5, tvSeries->NumberOfSeasons); BOOST_REQUIRE_EQUAL(1, tvSeries->OriginCountries.size()); BOOST_REQUIRE_EQUAL("US", tvSeries->OriginCountries.front()); BOOST_REQUIRE_EQUAL(651, tvSeries->Overview.length()); 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("/r3z70vunihrAkjILQKWHX0G2xzO.jpg", tvSeries->Seasons.back().PosterPath); BOOST_REQUIRE_EQUAL(5, tvSeries->Seasons.back().SeasonNumber); BOOST_REQUIRE_EQUAL("Ended", tvSeries->Status); BOOST_REQUIRE_CLOSE(8.2, tvSeries->VoteAverage, 0.01); BOOST_REQUIRE_EQUAL(1536, tvSeries->VoteCount); }