diff options
author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2019-01-29 14:46:59 +0000 |
---|---|---|
committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2019-01-29 14:46:59 +0000 |
commit | ea3e21f209db50d3446bee7fbb2215ae378c51ae (patch) | |
tree | 69dd10575f12cf45ddd6cf0e93e826c4bc3e5ee8 | |
parent | Remove boost::filesystem in favour of std::filesystem (diff) | |
download | libadhocutil-ea3e21f209db50d3446bee7fbb2215ae378c51ae.tar.bz2 libadhocutil-ea3e21f209db50d3446bee7fbb2215ae378c51ae.tar.xz libadhocutil-ea3e21f209db50d3446bee7fbb2215ae378c51ae.zip |
Remove calls nolonger required
-rw-r--r-- | libadhocutil/unittests/testCurl.cpp | 28 | ||||
-rw-r--r-- | libadhocutil/unittests/testDirs.cpp | 6 | ||||
-rw-r--r-- | libadhocutil/unittests/testPluginsRuntime.cpp | 2 |
3 files changed, 21 insertions, 15 deletions
diff --git a/libadhocutil/unittests/testCurl.cpp b/libadhocutil/unittests/testCurl.cpp index 729f018..04d5ed9 100644 --- a/libadhocutil/unittests/testCurl.cpp +++ b/libadhocutil/unittests/testCurl.cpp @@ -5,6 +5,7 @@ #include "curlHandle.h" #include "curlMultiHandle.h" #include "curlStream.h" +#include "compileTimeFormatter.h" #include "definedDirs.h" #include "net.h" #include <boost/algorithm/string/predicate.hpp> @@ -18,17 +19,22 @@ discard(void *, size_t sz, size_t nm, void *) return sz * nm; } +AdHocFormatter(FileUrl, "file://%?/%?"); +const auto urlGen = std::bind((std::string(*)(const std::string &, const std::string_view &))&FileUrl::get, rootDir, std::placeholders::_1); + BOOST_AUTO_TEST_CASE( fetch_file ) { - auto url = "file://" + rootDir.string() + "/testCurl.cpp"; - CurlHandle ch(url); - ch.setopt(CURLOPT_WRITEFUNCTION, discard); - ch.perform(); + auto url = urlGen("testCurl.cpp"); + BOOST_TEST_CONTEXT(url) { + CurlHandle ch(url); + ch.setopt(CURLOPT_WRITEFUNCTION, discard); + ch.perform(); + } } BOOST_AUTO_TEST_CASE( setAndGetOptions ) { - auto url = "file://" + rootDir.string() + "/testCurl.cpp"; + auto url = urlGen("testCurl.cpp"); CurlHandle ch(url); // function ch.setopt(CURLOPT_WRITEFUNCTION, discard); @@ -52,7 +58,7 @@ BOOST_AUTO_TEST_CASE( setAndGetOptions ) BOOST_AUTO_TEST_CASE( fetch_missing ) { - auto url = "file://" + rootDir.string() + "/nothere"; + auto url = urlGen("nothere"); CurlHandle ch(url); BOOST_REQUIRE_THROW(ch.perform(), AdHoc::Net::CurlException); } @@ -76,7 +82,7 @@ BOOST_AUTO_TEST_CASE( fetch_http_stream ) BOOST_AUTO_TEST_CASE( fetch_file_stream ) { - auto url = "file://" + rootDir.string() + "/testCurl.cpp"; + auto url = urlGen("testCurl.cpp"); CurlStreamSource css(url); CurlStream curlstrm(css); std::string tok; @@ -93,7 +99,7 @@ BOOST_AUTO_TEST_CASE( fetch_file_stream ) BOOST_AUTO_TEST_CASE( fetch_missing_stream ) { - auto url = "file://" + rootDir.string() + "/nothere"; + auto url = urlGen("nothere"); CurlStreamSource css(url); css.setopt(CURLOPT_FAILONERROR, 1L); CurlStream curlstrm(css); @@ -118,11 +124,11 @@ BOOST_AUTO_TEST_CASE( fetch_multi ) using std::placeholders::_1; CurlMultiHandle cmh; std::map<std::string, std::string> files; - cmh.addCurl("file://" + rootDir.string() + "/testBuffer.cpp", + cmh.addCurl(urlGen("/testBuffer.cpp"), std::bind(&mapFileToName, std::ref(files), "testBuffer.cpp", _1)); - cmh.addCurl("file://" + rootDir.string() + "/testCurl.cpp", + cmh.addCurl(urlGen("/testCurl.cpp"), std::bind(&mapFileToName, std::ref(files), "testCurl.cpp", _1)); - cmh.addCurl("file://" + rootDir.string() + "/testLocks.cpp", + cmh.addCurl(urlGen("/testLocks.cpp"), std::bind(&mapFileToName, std::ref(files), "testLocks.cpp", _1)); cmh.performAll(); BOOST_REQUIRE_EQUAL(3, files.size()); diff --git a/libadhocutil/unittests/testDirs.cpp b/libadhocutil/unittests/testDirs.cpp index 5a6065e..08284ee 100644 --- a/libadhocutil/unittests/testDirs.cpp +++ b/libadhocutil/unittests/testDirs.cpp @@ -8,9 +8,9 @@ BOOST_AUTO_TEST_CASE( iexist ) { BOOST_REQUIRE(std::filesystem::exists(selfExe)); BOOST_REQUIRE(selfExe.is_absolute()); - BOOST_REQUIRE_EQUAL("testDirs", selfExe.filename().string()); - BOOST_REQUIRE_EQUAL("unittests", rootDir.filename().string()); + BOOST_REQUIRE_EQUAL("testDirs", selfExe.filename()); + BOOST_REQUIRE_EQUAL("unittests", rootDir.filename()); BOOST_REQUIRE(std::filesystem::is_directory(binDir)); - BOOST_REQUIRE_EQUAL("libadhocutil", rootDir.parent_path().filename().string()); + BOOST_REQUIRE_EQUAL("libadhocutil", rootDir.parent_path().filename()); } diff --git a/libadhocutil/unittests/testPluginsRuntime.cpp b/libadhocutil/unittests/testPluginsRuntime.cpp index c68c39e..9f8f3e6 100644 --- a/libadhocutil/unittests/testPluginsRuntime.cpp +++ b/libadhocutil/unittests/testPluginsRuntime.cpp @@ -60,7 +60,7 @@ goodResolver(const std::type_info & t, const std::string_view & n) { BOOST_REQUIRE_EQUAL(typeid(BaseThing), t); BOOST_REQUIRE_EQUAL("ImplOfThing", n); - return lib.string(); + return lib; } BOOST_AUTO_TEST_CASE( addAndRemoveResolver ) |