diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-03-13 20:15:27 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2018-03-13 20:29:11 +0000 |
commit | e998fabccdbd027d7e8af99f322162e1f883b8d2 (patch) | |
tree | eafa86908ba1939578bf560cfc5560a37c452d21 | |
parent | Don't need to add don't print log for nullptr_t from boost 1.64 onwards (diff) | |
download | libadhocutil-e998fabccdbd027d7e8af99f322162e1f883b8d2.tar.bz2 libadhocutil-e998fabccdbd027d7e8af99f322162e1f883b8d2.tar.xz libadhocutil-e998fabccdbd027d7e8af99f322162e1f883b8d2.zip |
Streams don't throw exceptions, they set !stream::good()
-rw-r--r-- | libadhocutil/unittests/testCurl.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libadhocutil/unittests/testCurl.cpp b/libadhocutil/unittests/testCurl.cpp index 85ddb0c..c202f79 100644 --- a/libadhocutil/unittests/testCurl.cpp +++ b/libadhocutil/unittests/testCurl.cpp @@ -94,12 +94,12 @@ BOOST_AUTO_TEST_CASE( fetch_file_stream ) BOOST_AUTO_TEST_CASE( fetch_missing_stream ) { auto url = "file://" + rootDir.string() + "/nothere"; - BOOST_REQUIRE_THROW({ - CurlStreamSource css(url); - CurlStream curlstrm(css); - std::string tok; - curlstrm >> tok; - }, AdHoc::Net::CurlException); + CurlStreamSource css(url); + css.setopt(CURLOPT_FAILONERROR, 1L); + CurlStream curlstrm(css); + std::string tok; + curlstrm >> tok; + BOOST_REQUIRE(!curlstrm.good()); } static @@ -136,16 +136,16 @@ BOOST_AUTO_TEST_CASE( fetch_multi_fail ) bool errored = false; bool finished = false; cmh.addCurl("http://sys.randomdan.homeip.net/missing", [&finished, &errored](std::istream & s) { - try { - std::string tok; - while (!s.eof()) { - s >> tok; - } - finished = true; - } catch (...) { + std::string tok; + while (!s.eof()) { + if (!s.good()) { errored = true; + return; } - }); + s >> tok; + } + finished = true; + }); cmh.performAll(); BOOST_REQUIRE(!finished); BOOST_REQUIRE(errored); |