parent
26b79bdefa
commit
867c315e56
3 changed files with 59 additions and 0 deletions
@ -0,0 +1,27 @@ |
||||
#include<gtest/gtest.h> |
||||
#include<gmock/gmock.h> |
||||
|
||||
using ::testing::Return; |
||||
|
||||
class Foo { |
||||
public: |
||||
Foo() { x = 42; } |
||||
virtual ~Foo() {}; |
||||
|
||||
virtual int getValue() const { return x; } |
||||
|
||||
private: |
||||
int x; |
||||
}; |
||||
|
||||
class MockFoo : public Foo { |
||||
public: |
||||
MOCK_CONST_METHOD0(getValue, int()); |
||||
}; |
||||
|
||||
TEST(counttest, once) { |
||||
MockFoo f; |
||||
EXPECT_CALL(f, getValue()).Times(1).WillOnce(Return(42)); |
||||
|
||||
EXPECT_EQ(f.getValue(), 42) << "Got wrong value"; |
||||
} |
@ -0,0 +1,10 @@ |
||||
project('gmock test', 'cxx') |
||||
|
||||
# Using gmock without gtest is a pain so just |
||||
# don't support that then. |
||||
|
||||
gtest = find_dep('gtest', required : true) |
||||
gmock = find_dep('gmock', required : true) |
||||
|
||||
e = executable('gmocktest', 'gmocktest.cc', deps : [gtest, gmock]) |
||||
add_test('gmock test', e) |
Loading…
Reference in new issue