I am testing 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
the tests run OK, but the two tests behave differently: the 'true' case compiles OK, the 'false' case presents with the warning
In file included from /... ./build/gtest/src/gtest/include/gtest/gtest.h:1929:0, from /... .cpp:1: /... .cpp: In member function ‘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-null] (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1) ^
Why gtest wants to convert 'false' to pointer? And why not 'true'? Do I miss something?
If you have a broken test that you cannot fix right away, you can add the DISABLED_ prefix to its name. This will exclude it from execution. This is better than commenting out the code or using #if 0 , as disabled tests are still compiled (and thus won't rot).
You must always put a mock method definition ( MOCK_METHOD ) in a public: section of the mock class, regardless of the method being mocked being public , protected , or private in the base class.
Google Test (also known as gtest) is a unit testing library for the C++ programming language, based on the xUnit architecture. The library is released under the BSD 3-clause license.
EXPECT_CALL not only defines the behavior, but also sets an expectation that the method will be called with the given arguments, for the given number of times (and in the given order when you specify the order too).
For booleans you need to use EXPECT_TRUE()
and EXPECT_FALSE()
rather than EXPECT_EQ
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With