diff options
author | Dan Goodliffe <daniel.goodliffe@pressassociation.com> | 2017-08-22 12:01:20 +0100 |
---|---|---|
committer | Dan Goodliffe <daniel.goodliffe@pressassociation.com> | 2017-08-22 12:01:20 +0100 |
commit | 6ba1d24e22bf90333aaf5d3d0f32f6165ee8cc02 (patch) | |
tree | 4659b41ac5274120f2c975b55d24d79b18494957 | |
parent | Fix FileHandle move constructor and bolster test coverage (diff) | |
download | libadhocutil-6ba1d24e22bf90333aaf5d3d0f32f6165ee8cc02.tar.bz2 libadhocutil-6ba1d24e22bf90333aaf5d3d0f32f6165ee8cc02.tar.xz libadhocutil-6ba1d24e22bf90333aaf5d3d0f32f6165ee8cc02.zip |
Prefer BOOST_REQUIRE_* comparisons
-rw-r--r-- | libadhocutil/unittests/testCurl.cpp | 4 | ||||
-rw-r--r-- | libadhocutil/unittests/testFactory.cpp | 2 | ||||
-rw-r--r-- | libadhocutil/unittests/testFileUtils.cpp | 4 | ||||
-rw-r--r-- | libadhocutil/unittests/testLexer.cpp | 2 | ||||
-rw-r--r-- | libadhocutil/unittests/testNvpParse.cpp | 12 | ||||
-rw-r--r-- | libadhocutil/unittests/testPlugins.cpp | 10 | ||||
-rw-r--r-- | libadhocutil/unittests/testProcessPipes.cpp | 4 | ||||
-rw-r--r-- | libadhocutil/unittests/testResourcePool.cpp | 6 |
8 files changed, 23 insertions, 21 deletions
diff --git a/libadhocutil/unittests/testCurl.cpp b/libadhocutil/unittests/testCurl.cpp index ba7cfcf..85ddb0c 100644 --- a/libadhocutil/unittests/testCurl.cpp +++ b/libadhocutil/unittests/testCurl.cpp @@ -46,8 +46,8 @@ BOOST_AUTO_TEST_CASE( setAndGetOptions ) // double double totalTime; ch.getinfo(CURLINFO_TOTAL_TIME, totalTime); - BOOST_REQUIRE(totalTime > 0); - BOOST_REQUIRE(totalTime < 50); + BOOST_REQUIRE_GT(totalTime, 0); + BOOST_REQUIRE_LT(totalTime, 50); } BOOST_AUTO_TEST_CASE( fetch_missing ) diff --git a/libadhocutil/unittests/testFactory.cpp b/libadhocutil/unittests/testFactory.cpp index 582ba51..10e2013 100644 --- a/libadhocutil/unittests/testFactory.cpp +++ b/libadhocutil/unittests/testFactory.cpp @@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE( get ) BOOST_REQUIRE(factory1); BOOST_REQUIRE_EQUAL(factory1, factory2); BOOST_REQUIRE(factory3); - BOOST_REQUIRE(factory1 != factory3); + BOOST_REQUIRE_NE(factory1, factory3); } BOOST_AUTO_TEST_CASE( create ) diff --git a/libadhocutil/unittests/testFileUtils.cpp b/libadhocutil/unittests/testFileUtils.cpp index 0729c1f..973b9bb 100644 --- a/libadhocutil/unittests/testFileUtils.cpp +++ b/libadhocutil/unittests/testFileUtils.cpp @@ -9,13 +9,13 @@ BOOST_REQUIRE_EQUAL(fcntl(fh, F_GETFD), -1) #define REQUIRE_VALID_FH(fh) \ - BOOST_REQUIRE(fcntl(fh, F_GETFD) != -1) + BOOST_REQUIRE_NE(fcntl(fh, F_GETFD), -1) template <typename T> void testRaw() { int f = open("/proc/self/exe", O_RDONLY); - BOOST_REQUIRE(f != -1); + BOOST_REQUIRE_NE(f, -1); T fh(f); BOOST_REQUIRE_EQUAL(f, fh); } diff --git a/libadhocutil/unittests/testLexer.cpp b/libadhocutil/unittests/testLexer.cpp index 0e23586..f58b002 100644 --- a/libadhocutil/unittests/testLexer.cpp +++ b/libadhocutil/unittests/testLexer.cpp @@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE( multibyte ) "^# ([^<\n]+)? ?(<(.+?@[^\n>]+)>?)? \\((\\d+ *(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\\w* \\d+)\\)$", (GRegexCompileFlags)(G_REGEX_OPTIMIZE | G_REGEX_CASELESS | G_REGEX_UNGREEDY)); Glib::ustring input("# Michał Górny <mgorny@gentoo.org> (28 Mar 2015)"); - BOOST_REQUIRE(input.bytes() > input.length()); + BOOST_REQUIRE_GT(input.bytes(), input.length()); BOOST_REQUIRE(maskHead->matches(input.c_str(), input.bytes(), 0)); BOOST_REQUIRE_EQUAL(maskHead->matchedLength(), input.bytes()); BOOST_REQUIRE(maskHead->match(1)); diff --git a/libadhocutil/unittests/testNvpParse.cpp b/libadhocutil/unittests/testNvpParse.cpp index db552de..9e3bf06 100644 --- a/libadhocutil/unittests/testNvpParse.cpp +++ b/libadhocutil/unittests/testNvpParse.cpp @@ -20,13 +20,15 @@ NvpTarget(TestTarget) TestTargetMap { NvpValue(TestTarget, d), }; +BOOST_TEST_DONT_PRINT_LOG_VALUE(decltype(TestTargetMap.find(""))); + BOOST_AUTO_TEST_CASE ( targetmap ) { - BOOST_REQUIRE(TestTargetMap.find("a") != TestTargetMap.end()); - BOOST_REQUIRE(TestTargetMap.find("b") != TestTargetMap.end()); - BOOST_REQUIRE(TestTargetMap.find("c") != TestTargetMap.end()); - BOOST_REQUIRE(TestTargetMap.find("d") != TestTargetMap.end()); - BOOST_REQUIRE(TestTargetMap.find("e") == TestTargetMap.end()); + BOOST_REQUIRE_NE(TestTargetMap.find("a"), TestTargetMap.end()); + BOOST_REQUIRE_NE(TestTargetMap.find("b"), TestTargetMap.end()); + BOOST_REQUIRE_NE(TestTargetMap.find("c"), TestTargetMap.end()); + BOOST_REQUIRE_NE(TestTargetMap.find("d"), TestTargetMap.end()); + BOOST_REQUIRE_EQUAL(TestTargetMap.find("e"), TestTargetMap.end()); } BOOST_AUTO_TEST_CASE ( parse ) diff --git a/libadhocutil/unittests/testPlugins.cpp b/libadhocutil/unittests/testPlugins.cpp index d0f38a1..81d7ec1 100644 --- a/libadhocutil/unittests/testPlugins.cpp +++ b/libadhocutil/unittests/testPlugins.cpp @@ -20,9 +20,9 @@ BOOST_AUTO_TEST_CASE( registered ) BOOST_AUTO_TEST_CASE( get ) { auto implOfThingPlugin = PluginManager::getDefault()->get<BaseThing>("ImplOfThing"); - BOOST_REQUIRE(implOfThingPlugin != nullptr); + BOOST_REQUIRE(implOfThingPlugin); auto implOfThing = implOfThingPlugin->implementation(); - BOOST_REQUIRE(implOfThing != nullptr); + BOOST_REQUIRE(implOfThing); auto implOfThingDirect = PluginManager::getDefault()->getImplementation<BaseThing>("ImplOfThing"); BOOST_REQUIRE_EQUAL(implOfThing, implOfThingDirect); } @@ -54,8 +54,8 @@ BOOST_AUTO_TEST_CASE( addManual ) BOOST_REQUIRE(c2); BOOST_REQUIRE(o2); BOOST_REQUIRE_EQUAL(o1, o2); - BOOST_REQUIRE(c1 != o1); - BOOST_REQUIRE(c2 != o1); + BOOST_REQUIRE_NE(c1, o1); + BOOST_REQUIRE_NE(c2, o1); } BOOST_AUTO_TEST_CASE( removeManual ) @@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE( otherTypes ) PluginPtr p2 = PluginManager::getDefault()->get<OtherBase>("ImplOfThing"); BOOST_REQUIRE(p1); BOOST_REQUIRE(p2); - BOOST_REQUIRE(p1 != p2); + BOOST_REQUIRE_NE(p1, p2); PluginManager::getDefault()->remove<OtherBase>("ImplOfThing"); BOOST_REQUIRE_EQUAL(1, PluginManager::getDefault()->count()); BOOST_REQUIRE(PluginManager::getDefault()->get<BaseThing>("ImplOfThing")); diff --git a/libadhocutil/unittests/testProcessPipes.cpp b/libadhocutil/unittests/testProcessPipes.cpp index ecd596b..8a3a12e 100644 --- a/libadhocutil/unittests/testProcessPipes.cpp +++ b/libadhocutil/unittests/testProcessPipes.cpp @@ -11,8 +11,8 @@ BOOST_AUTO_TEST_CASE ( readfind ) { ProcessPipes pp({"/usr/bin/find", rootDir.string(), "-maxdepth", "1"}, false, true, true); BOOST_REQUIRE_EQUAL(pp.fdIn(), -1); - BOOST_REQUIRE(pp.fdOut() != -1); - BOOST_REQUIRE(pp.fdError() != -1); + BOOST_REQUIRE_NE(pp.fdOut(), -1); + BOOST_REQUIRE_NE(pp.fdError(), -1); char buf[BUFSIZ]; ssize_t bytes = read(pp.fdOut(), buf, BUFSIZ); BOOST_REQUIRE_MESSAGE(bytes > 0, "bytes = " << bytes); diff --git a/libadhocutil/unittests/testResourcePool.cpp b/libadhocutil/unittests/testResourcePool.cpp index e297cae..bc469c4 100644 --- a/libadhocutil/unittests/testResourcePool.cpp +++ b/libadhocutil/unittests/testResourcePool.cpp @@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE( threading1 ) })); usleep(5000); // pool size never exceeds 3 - BOOST_REQUIRE(pool.inUseCount() <= 3); + BOOST_REQUIRE_LE(pool.inUseCount(), 3); } for(std::thread * thread : threads) { thread->join(); @@ -319,14 +319,14 @@ BOOST_AUTO_TEST_CASE( test ) { auto r = pool.get(); BOOST_REQUIRE(r.get()); - BOOST_REQUIRE(rpId != r.get()->id); + BOOST_REQUIRE_NE(rpId, r.get()->id); BOOST_REQUIRE_EQUAL(1, MockResource::count); rpId = r.get()->id; } { auto r = pool.get(); BOOST_REQUIRE(r.get()); - BOOST_REQUIRE(rpId == r.get()->id); + BOOST_REQUIRE_EQUAL(rpId, r.get()->id); BOOST_REQUIRE_EQUAL(1, MockResource::count); } } |