diff --git a/test/TileQueueTests.cpp b/test/TileQueueTests.cpp index cc7b8c78eb85..9e7543ad391d 100644 --- a/test/TileQueueTests.cpp +++ b/test/TileQueueTests.cpp @@ -286,14 +286,17 @@ void TileQueueTests::testSenderQueue() LOK_ASSERT_EQUAL_STR(true, queue.dequeue(item)); LOK_ASSERT_EQUAL(static_cast(2), queue.size()); + LOK_ASSERT(item); LOK_ASSERT_EQUAL(messages[0], std::string(item->data().data(), item->data().size())); LOK_ASSERT_EQUAL_STR(true, queue.dequeue(item)); LOK_ASSERT_EQUAL(static_cast(1), queue.size()); + LOK_ASSERT(item); LOK_ASSERT_EQUAL(messages[1], std::string(item->data().data(), item->data().size())); LOK_ASSERT_EQUAL_STR(true, queue.dequeue(item)); LOK_ASSERT_EQUAL(static_cast(0), queue.size()); + LOK_ASSERT(item); LOK_ASSERT_EQUAL(messages[2], std::string(item->data().data(), item->data().size())); LOK_ASSERT_EQUAL(static_cast(0), queue.size()); @@ -345,6 +348,8 @@ void TileQueueTests::testSenderQueueTileDeduplication() LOK_ASSERT_EQUAL(static_cast(1), queue.size()); LOK_ASSERT_EQUAL_STR(true, queue.dequeue(item)); + LOK_ASSERT(item); + // The last one should persist. LOK_ASSERT_EQUAL(dup_messages[2], std::string(item->data().data(), item->data().size())); @@ -379,14 +384,17 @@ void TileQueueTests::testInvalidateViewCursorDeduplication() LOK_ASSERT_EQUAL_STR(true, queue.dequeue(item)); LOK_ASSERT_EQUAL(static_cast(2), queue.size()); + LOK_ASSERT(item); LOK_ASSERT_EQUAL(view_messages[0], std::string(item->data().data(), item->data().size())); LOK_ASSERT_EQUAL_STR(true, queue.dequeue(item)); LOK_ASSERT_EQUAL(static_cast(1), queue.size()); + LOK_ASSERT(item); LOK_ASSERT_EQUAL(view_messages[1], std::string(item->data().data(), item->data().size())); LOK_ASSERT_EQUAL_STR(true, queue.dequeue(item)); LOK_ASSERT_EQUAL(static_cast(0), queue.size()); + LOK_ASSERT(item); LOK_ASSERT_EQUAL(view_messages[2], std::string(item->data().data(), item->data().size())); LOK_ASSERT_EQUAL(static_cast(0), queue.size()); diff --git a/test/lokassert.hpp b/test/lokassert.hpp index 2379705f22b4..8b1208c803f3 100644 --- a/test/lokassert.hpp +++ b/test/lokassert.hpp @@ -78,7 +78,7 @@ std::string inline lokFormatAssertEq(const char* expected_name, const std::strin return oss.str(); } -#ifdef LOK_ABORT_ON_ASSERTION +#if defined(LOK_ABORT_ON_ASSERTION) || defined(__COVERITY__) #define LOK_ASSERT_IMPL(X) assert(X); #else #define LOK_ASSERT_IMPL(X) @@ -115,8 +115,7 @@ inline constexpr bool failed() { return false; } using namespace test::detail; \ if (!failed()) \ { \ - auto&& cond##__LINE__ = !!(condition); \ - if (!cond##__LINE__) \ + if (!(condition)) \ { \ std::ostringstream oss##__LINE__; \ oss##__LINE__ << message; \ @@ -124,7 +123,7 @@ inline constexpr bool failed() { return false; } TST_LOG("ERROR: Assertion failure: " \ << (msg##__LINE__.empty() ? "" : msg##__LINE__ + ". ") \ << "Condition: " << (#condition)); \ - LOK_ASSERT_IMPL(cond##__LINE__); \ + LOK_ASSERT_IMPL(!#condition); /* NOLINT(misc-static-assert) */ \ CPPUNIT_ASSERT_MESSAGE((msg##__LINE__), condition); \ } \ else if (!silent) \