Most unexpected conversion

I check the correct operation of my function

bool Core::IsMeta(void) { return mProc->GetCode(mPC)->Meta; } 

using instructions

 EXPECT_EQ(true,CC->IsMeta()); // The instruction pointed to is meta EXPECT_EQ(false,CC1->IsMeta()); // The instruction pointed to is NOT meta 

tests work fine, but two tests behave differently: the β€œtrue” case compiles OK, the β€œfalse” case presents a warning

In the file included in /..../build/gtest/src/gtest/include/gtest/gtest.h:1929:07, from /....cpp: 1: /....cpp: In function -membered virtual void ... :: TestBody (): /.../build/gtest/src/gtest/include/gtest/internal/gtest-internal.h:133:55: warning: converting 'false to pointer type for argument 1 of 'char testing :: internal :: IsNullLiteralHelper (testing :: internal :: Secret *) [-Wconversion-zero] (sizeof (:: testing :: internal :: IsNullLiteralHelper (x)) == 1) ^

Why does gtest want to convert 'false' to a pointer? And why not the "truth"? Did I miss something?

+5
source share
2 answers

For booleans, you need to use EXPECT_TRUE() and EXPECT_FALSE() , not EXPECT_EQ .

+6
source

The problem is not gtest, it is actually a gcc error, as stated here .

0
source

Source: https://habr.com/ru/post/1237716/


All Articles