-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmock.conf
101 lines (75 loc) · 2.12 KB
/
gmock.conf
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# parameters:
# mock_name: name of your class without "Mock" (e.g., MyClass, the mock class will be MyClassMock)
# name_space
# mock_header_template
# mock_cpp_template
# stubs_file_template
# stub_function_template
# internally used only:
# guard: used in mock header, inferred from moc_name (e.g, __MYCLASS_MOCK_)
# mock_header: file name of mock header, inferred from moc_name (e.g, myclass_mock.hpp)
# mock_methods
# mock_instance
# headers
parsing_args = "-x c++ --std=c++11 -include stddef.h -include stdint.h"
name_space = "mynamespace"
mock_name = "MyClass"
header_output_path = "my/output/path"
mock_header_template = """
//
// Confidential
//
#ifndef %(guard)s
#define %(guard)s
#include <gmock/gmock.h>
%(header_files)s
namespace %(name_space)s {
namespace unittest {
class %(mock_name)s {
public:
%(mock_methods)s
static testing::NiceMock<%(mock_name)s>* getInstance();
static void removeInstance();
private:
static testing::NiceMock<%(mock_name)s> *%(mock_instance)s;
};
} /* unittest */
} /* %(name_space)s */
#endif /* %(guard)s */
"""
mock_cpp_template = """
//
// Confidential
//
#include "%(header_output_path)s/%(mock_header)s"
namespace %(name_space)s {
namespace unittest {
testing::NiceMock<%(mock_name)s> *%(mock_name)s::%(mock_instance)s = nullptr;
testing::NiceMock<%(mock_name)s>* %(mock_name)s::getInstance() {
if( %(mock_name)s::%(mock_instance)s == nullptr ) {
%(mock_name)s::%(mock_instance)s = new testing::NiceMock<%(mock_name)s>();
}
return %(mock_name)s::%(mock_instance)s;
}
void %(mock_name)s::removeInstance() {
if( %(mock_name)s::%(mock_instance)s ) {
delete %(mock_name)s::%(mock_instance)s;
}
%(mock_name)s::%(mock_instance)s = nullptr;
}
} /* unittest */
} /* %(name_space)s */
"""
stubs_file_template = """
//
// Confidential
//
#include "%(header_output_path)s/%(mock_header)s"
using %(name_space)s::unittest::%(mock_name)s;
%(stubs)s
"""
stub_function_template = """
%(result_type)s %(function_name)s( %(parameters_with_types)s ) {
%(return)s %(mock_name)s::getInstance()->%(function_name)s( %(parameters)s );
}
"""