From b8cd8b6087862ff04c9e39a0235ebf870c28ce39 Mon Sep 17 00:00:00 2001 From: Rolf Badorek Date: Fri, 20 Sep 2019 14:20:05 +0300 Subject: [PATCH] Use boolean expects in unit tests Certain gcc versions will give (per my understanding false positive) warning when 'EXPECT_EQ' macro is used so that other argument is 'true' or 'false'. For example, Ubuntu 16.04 has by default such a gcc version. See some related discussion below: https://github.com/google/googletest/issues/322 We have defined all compiler warning to be treated as errors, thus above issue will lead to compilation error. Simple fix is to use 'EXPECT_TRUE' or 'EXPECT_FALSE' instead. Those are more readable, and thus better choice anyway. Signed-off-by: Rolf Badorek Change-Id: Ib0f3841c1b6fe2cf95eac3e4dc0cbcba9c3c8268 --- tst/syncstorageimpl_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tst/syncstorageimpl_test.cpp b/tst/syncstorageimpl_test.cpp index 4176852..7eab410 100644 --- a/tst/syncstorageimpl_test.cpp +++ b/tst/syncstorageimpl_test.cpp @@ -343,7 +343,7 @@ TEST_F(SyncStorageImplTest, SetIfNotExistsSuccessfully) expectSetIfNotExistsAsync("key1", { 0x0a, 0x0b, 0x0c }); expectPollWait(); expectModifyIfAck(std::error_code(), true); - EXPECT_EQ(true, syncStorage->setIfNotExists(ns, "key1", { 0x0a, 0x0b, 0x0c })); + EXPECT_TRUE(syncStorage->setIfNotExists(ns, "key1", { 0x0a, 0x0b, 0x0c })); } TEST_F(SyncStorageImplTest, SetIfNotExistsReturnsFalseIfKeyAlreadyExists) @@ -353,7 +353,7 @@ TEST_F(SyncStorageImplTest, SetIfNotExistsReturnsFalseIfKeyAlreadyExists) expectSetIfNotExistsAsync("key1", { 0x0a, 0x0b, 0x0c }); expectPollWait(); expectModifyIfAck(std::error_code(), false); - EXPECT_EQ(false, syncStorage->setIfNotExists(ns, "key1", { 0x0a, 0x0b, 0x0c })); + EXPECT_FALSE(syncStorage->setIfNotExists(ns, "key1", { 0x0a, 0x0b, 0x0c })); } TEST_F(SyncStorageImplTest, SetIfNotExistsCanThrowBackendError) @@ -414,7 +414,7 @@ TEST_F(SyncStorageImplTest, RemoveIfSuccessfully) expectRemoveIfAsync("key1", { 0x0a, 0x0b, 0x0c }); expectPollWait(); expectModifyIfAck(std::error_code(), true); - EXPECT_EQ(true, syncStorage->removeIf(ns, "key1", { 0x0a, 0x0b, 0x0c })); + EXPECT_TRUE(syncStorage->removeIf(ns, "key1", { 0x0a, 0x0b, 0x0c })); } TEST_F(SyncStorageImplTest, RemoveIfReturnsFalseIfKeyDoesnotMatch) @@ -424,7 +424,7 @@ TEST_F(SyncStorageImplTest, RemoveIfReturnsFalseIfKeyDoesnotMatch) expectRemoveIfAsync("key1", { 0x0a, 0x0b, 0x0c }); expectPollWait(); expectModifyIfAck(std::error_code(), false); - EXPECT_EQ(false, syncStorage->removeIf(ns, "key1", { 0x0a, 0x0b, 0x0c })); + EXPECT_FALSE(syncStorage->removeIf(ns, "key1", { 0x0a, 0x0b, 0x0c })); } TEST_F(SyncStorageImplTest, RemoveIfCanThrowBackendError) -- 2.16.6