From 62d506c24aaf543f84c82e2850a05b1387e4990d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 9 Jan 2021 13:58:38 +0000 Subject: Clang format --- site/test.cpp | 99 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 48 insertions(+), 51 deletions(-) (limited to 'site/test.cpp') diff --git a/site/test.cpp b/site/test.cpp index 4cd9763..bcff64b 100644 --- a/site/test.cpp +++ b/site/test.cpp @@ -1,68 +1,66 @@ #define BOOST_TEST_MODULE mirrorsearchsite #include -#include -#include #include +#include +#include -#include #include +#include using namespace IceSpider; using namespace MirrorSearch; class TestSerice : public Search { - public: - virtual SearchServices getServices(const ::Ice::Current& = ::Ice::Current()) override - { - return {}; +public: + virtual SearchServices + getServices(const ::Ice::Current & = ::Ice::Current()) override + { + return {}; + } + virtual SearchHits + getMatches(const ::std::string fn, const ::Ice::Current & = ::Ice::Current()) override + { + BOOST_TEST_INFO(fn); + if (fn == "good.txt") { + return {std::make_shared(1, 1, "file:///some/file/path"), + std::make_shared(1, 1, "file:///some/other/path")}; } - virtual SearchHits getMatches(const ::std::string fn, const ::Ice::Current& = ::Ice::Current()) override - { - BOOST_TEST_INFO(fn); - if (fn == "good.txt") { - return { - std::make_shared(1, 1, "file:///some/file/path"), - std::make_shared(1, 1, "file:///some/other/path") - }; - } - return {}; - } - virtual ::Ice::optional<::std::string> feelingLucky(const ::std::string fn, const ::Ice::Current & c = ::Ice::Current()) override - { - auto ms = getMatches(fn, c); - if (ms.empty()) { - return IceUtil::None; - - } - return ms.front()->url; + return {}; + } + virtual ::Ice::optional<::std::string> + feelingLucky(const ::std::string fn, const ::Ice::Current & c = ::Ice::Current()) override + { + auto ms = getMatches(fn, c); + if (ms.empty()) { + return IceUtil::None; } + return ms.front()->url; + } }; class TestApp : public CoreWithDefaultRouter { - public: - TestApp() : - CoreWithDefaultRouter({ - "--MirrorSearch.Search=Search" - }), - adp(communicator->createObjectAdapterWithEndpoints("test", "default")) - { - adp->activate(); - adp->add(std::make_shared(), Ice::stringToIdentity("Search")); - } - - ~TestApp() - { - adp->deactivate(); - adp->destroy(); - } - - Ice::ObjectAdapterPtr adp; +public: + TestApp() : + CoreWithDefaultRouter({"--MirrorSearch.Search=Search"}), + adp(communicator->createObjectAdapterWithEndpoints("test", "default")) + { + adp->activate(); + adp->add(std::make_shared(), Ice::stringToIdentity("Search")); + } + + ~TestApp() + { + adp->deactivate(); + adp->destroy(); + } + + Ice::ObjectAdapterPtr adp; }; BOOST_FIXTURE_TEST_SUITE(ta, TestApp); -BOOST_AUTO_TEST_CASE( testCallIndexNoFile ) +BOOST_AUTO_TEST_CASE(testCallIndexNoFile) { TestRequest requestGetIndex(this, HttpMethod::GET, "/list"); process(&requestGetIndex); @@ -70,7 +68,7 @@ BOOST_AUTO_TEST_CASE( testCallIndexNoFile ) BOOST_CHECK_EQUAL(h["Status"], "404 Not found"); } -BOOST_AUTO_TEST_CASE( testCallServiceList ) +BOOST_AUTO_TEST_CASE(testCallServiceList) { TestRequest requestGetIndex(this, HttpMethod::GET, "/services"); process(&requestGetIndex); @@ -79,7 +77,7 @@ BOOST_AUTO_TEST_CASE( testCallServiceList ) BOOST_CHECK_EQUAL(h["Content-Type"], "application/json"); } -BOOST_AUTO_TEST_CASE( testCallIndex ) +BOOST_AUTO_TEST_CASE(testCallIndex) { TestRequest requestGetIndex(this, HttpMethod::GET, "/list/somefile.txt"); process(&requestGetIndex); @@ -88,7 +86,7 @@ BOOST_AUTO_TEST_CASE( testCallIndex ) BOOST_CHECK_EQUAL(h["Content-Type"], "application/json"); } -BOOST_AUTO_TEST_CASE( testCallDownloadNotFile ) +BOOST_AUTO_TEST_CASE(testCallDownloadNotFile) { TestRequest requestGetIndex(this, HttpMethod::GET, "/download"); process(&requestGetIndex); @@ -96,7 +94,7 @@ BOOST_AUTO_TEST_CASE( testCallDownloadNotFile ) BOOST_CHECK_EQUAL(h["Status"], "404 Not found"); } -BOOST_AUTO_TEST_CASE( testCallDownloadBad ) +BOOST_AUTO_TEST_CASE(testCallDownloadBad) { TestRequest requestGetIndex(this, HttpMethod::GET, "/download/bad.txt"); process(&requestGetIndex); @@ -104,7 +102,7 @@ BOOST_AUTO_TEST_CASE( testCallDownloadBad ) BOOST_CHECK_EQUAL(h["Status"], "404 No mirror found"); } -BOOST_AUTO_TEST_CASE( testCallDownloadGood ) +BOOST_AUTO_TEST_CASE(testCallDownloadGood) { TestRequest requestGetIndex(this, HttpMethod::GET, "/download/good.txt"); process(&requestGetIndex); @@ -114,4 +112,3 @@ BOOST_AUTO_TEST_CASE( testCallDownloadGood ) } BOOST_AUTO_TEST_SUITE_END(); - -- cgit v1.2.3