-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_main.cpp
43 lines (34 loc) · 849 Bytes
/
test_main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "class.hpp"
#include "class_2.hpp"
#include <gtest/gtest.h>
#include <gmock/gmock.h>
// TEST to check if foo is called
TEST (FooUsageTest, FooIsCalled)
{
class MockFoo : public FooPureVirtual {
public:
MOCK_METHOD(void, foo, (), (override));
MOCK_METHOD(void, bar, (), (override));
};
MockFoo mockFoo;
UseFoo useFoo(&mockFoo);
EXPECT_CALL(mockFoo, foo()).Times(1);
useFoo.useFoo();
}
TEST (FooVirtual, FooIsCalled)
{
class MockFoo : public FooVirtual {
public:
MOCK_METHOD(void, foo, (), (override));
MOCK_METHOD(void, bar, ());
};
MockFoo mockFoo;
UseFoo2 useFoo(&mockFoo);
EXPECT_CALL(mockFoo, foo()).Times(1);
useFoo.useFoo();
}
int main (int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}