From 28691c29e93fbc4fdb5ae4866287282840fba021 Mon Sep 17 00:00:00 2001 From: randomdan Date: Fri, 19 Sep 2014 23:52:30 +0000 Subject: First bash at a slicer ice proxy for TMDb and an untested instantiation in p2pvr's core adapter --- libtmdb/testFormatUrls.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 libtmdb/testFormatUrls.cpp (limited to 'libtmdb/testFormatUrls.cpp') diff --git a/libtmdb/testFormatUrls.cpp b/libtmdb/testFormatUrls.cpp new file mode 100644 index 0000000..f3aa2a8 --- /dev/null +++ b/libtmdb/testFormatUrls.cpp @@ -0,0 +1,58 @@ +#define BOOST_TEST_MODULE FormatUrls +#include + +#define private public +#define protected public + +#include "tmdb-proxy.h" + +const std::string MockBase = "http://private-5513-themoviedb.apiary-mock.com/3"; +const std::string ApiKey = "48b32823d2b60c5c1085af36daed03fa"; + +BOOST_AUTO_TEST_CASE( initialize_simple_proxy ) +{ + TMDb::Proxy test(MockBase, ApiKey); +} + +BOOST_AUTO_TEST_CASE( format_url_simple ) +{ + TMDb::Proxy test(MockBase, ApiKey); + auto url = test.GetUrl("/something/%d", 23, { }); + BOOST_REQUIRE_EQUAL("http://private-5513-themoviedb.apiary-mock.com/3/something/23?apikey=48b32823d2b60c5c1085af36daed03fa", url); +} + +BOOST_AUTO_TEST_CASE( format_url_query ) +{ + TMDb::Proxy test(MockBase, ApiKey); + auto url = test.GetUrl("/something/%d", 23, { { "page", 5 } }); + BOOST_REQUIRE_EQUAL("http://private-5513-themoviedb.apiary-mock.com/3/something/23?apikey=48b32823d2b60c5c1085af36daed03fa&page=5", url); +} + +BOOST_AUTO_TEST_CASE( format_url_multiple ) +{ + TMDb::Proxy test(MockBase, ApiKey); + auto url = test.GetUrl("/something", { { "page", 5}, {"query", "string" } }); + BOOST_REQUIRE_EQUAL("http://private-5513-themoviedb.apiary-mock.com/3/something?apikey=48b32823d2b60c5c1085af36daed03fa&page=5&query=string", url); +} + +BOOST_AUTO_TEST_CASE( format_url_escaped ) +{ + TMDb::Proxy test(MockBase, ApiKey); + auto url = test.GetUrl("/something", { { "query", "sample string" } }); + BOOST_REQUIRE_EQUAL("http://private-5513-themoviedb.apiary-mock.com/3/something?apikey=48b32823d2b60c5c1085af36daed03fa&query=sample%20string", url); +} + +BOOST_AUTO_TEST_CASE( format_url_optionalvalue ) +{ + TMDb::Proxy test(MockBase, ApiKey); + auto url = test.GetUrl("/something", { { "query", IceUtil::Optional(10) } }); + BOOST_REQUIRE_EQUAL("http://private-5513-themoviedb.apiary-mock.com/3/something?apikey=48b32823d2b60c5c1085af36daed03fa&query=10", url); +} + +BOOST_AUTO_TEST_CASE( format_url_optionalnovalue ) +{ + TMDb::Proxy test(MockBase, ApiKey); + auto url = test.GetUrl("/something", { { "query", IceUtil::Optional() } }); + BOOST_REQUIRE_EQUAL("http://private-5513-themoviedb.apiary-mock.com/3/something?apikey=48b32823d2b60c5c1085af36daed03fa", url); +} + -- cgit v1.2.3