using ::testing::Eq; using ::testing::Lt; ... // Expects that Foo()'s argument == bar. EXPECT_CALL(mock_obj, Foo(Eq(std::ref(bar))); // Expects that Foo()'s argument < bar. EXPECT_CALL(mock_obj, Foo(Lt(std::ref(bar)));Remember...
using ::testing::ByRef; using ::testing::Eq; using ::testing::Lt; ... // Expects that Foo()'s argument == bar. EXPECT_CALL(mock_obj, Foo(Eq(ByRef(bar))); // Expects that Foo()'s argument < bar. EXPECT_CALL(mock_obj, Foo(Lt(ByRef(bar)));Remember...
So, you can make a method do different things depending on its argument values like this:using ::testing::_; using ::testing::Lt; using ::testing::Return; ... // The default case. EXPECT_CALL(foo, DoThis(_)) .WillRepeatedly(Return('b')); // The more specific case. EXPECT_CALL...
The difference between an assert and an expect is that an expect is a non-fatal assertion, which means it does not break a test; it only registers the failure information. In this library, expects are counted as simple warnings rather than failures because they are not fatal. Here are two...
TEST_F(QueueTest, IsEmptyInitially) {EXPECT_EQ(0, q0_.size()); }TEST_F(QueueTest, DequeueWorks) {int* n = q0_.Dequeue();EXPECT_EQ(NULL, n); n = q1_.Dequeue();ASSERT_TRUE(n !=NULL);EXPECT_EQ(1, *n);EXPECT_EQ(0, q1_.size());deleten; n = q2_.Dequeue();ASSERT_TRU...
Solution 1 - wrap with parentheses: {: .good} classMockFoo{public:MOCK_METHOD((std::pair<bool,int>), GetPair, ());MOCK_METHOD(bool, CheckMap, ((std::map<int,double>),bool)); }; Note that wrapping a return or argument type with parentheses is, in general, invalid C++.M...
using ::testing::Eq; using ::testing::Lt; ... // Expects that Foo()'s argument == bar. EXPECT_CALL(mock_obj, Foo(Eq(std::ref(bar))); // Expects that Foo()'s argument < bar. EXPECT_CALL(mock_obj, Foo(Lt(std::ref(bar)));Remember...