Debian Codegraph @

vendored-meson/meson/test cases/frameworks/3 gmock/gmocktest.cc

raw
1 #include<gtest/gtest.h>
2 #include<gmock/gmock.h>
3
4 using ::testing::Return;
5
6 class Foo {
7 public:
8 Foo() { x = 42; }
9 virtual ~Foo() {};
10
11 virtual int getValue() const { return x; }
12
13 private:
14 int x;
15 };
16
17 class MockFoo : public Foo {
18 public:
19 MOCK_CONST_METHOD0(getValue, int());
20 };
21
22 TEST(counttest, once) {
23 MockFoo f;
24 EXPECT_CALL(f, getValue()).Times(1).WillOnce(Return(42));
25
26 EXPECT_EQ(f.getValue(), 42) << "Got wrong value";
27 }