-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpp gMock.eta
45 lines (42 loc) · 1.08 KB
/
cpp gMock.eta
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
<%/***theta
defaultSelection: document
formatOnPaste: true
***/%>
<% if (it.source && it.source != it.destination && /\.h(?:pp)?$/.test(it.source.uri.path)) {%>
#include "<%= it.source.relativePath %>"
<% }
const classRe = /^(?:class|struct)\s+(\w+)/
const methodRe = /(?:virtual\s+)?(?<retType>\w[\w:<>]*)\s+(?<name>\w+)\s*(?<params>\([^\)]*\))\s*(?<const>const)?\s*(?:override)?\s*(?:=\s*0\s*)?/
let inStruct = false
let structFound = false
for (row of it.rows) {
if (!inStruct) {
const m = row.match(classRe)
if (m)
{
inStruct = true
structFound = true %>
struct <%= m[1] %>Mock : <%= m[1] %>
{
<%
}
} else {
const m = methodRe.exec(row)
if (m)
{ -%>
MOCK_METHOD(<%= m.groups.retType %>, <%= m.groups.name %>, <%= m.groups.params %>, (<%= m.groups.const??"" %> override));
<%
} else if (row.startsWith("};")) {
inStruct = false %>
};
<%
}
}
}
if (!structFound) {
it.fail("No class or struct was found")
}
else if (inStruct) { -%>
};
<%
} -%>