-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_template_cpp_test.py
executable file
·70 lines (60 loc) · 2.6 KB
/
gen_template_cpp_test.py
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
#!/usr/bin/python3
import argparse
parser = argparse.ArgumentParser(description="This creates a template _test.cpp file in the folder \
(Title, section headers, etc) it is called in.")
parser.add_argument("filename", help="The name of the file that you want to generate omitting _test.c (the name of the target module)")
args = parser.parse_args()
filename = args.filename
lines = []
lines.append("/**\n")
lines.append("* \\file %s_test.cpp\n" % filename)
lines.append("*\n")
lines.append("* \\brief ... unit test\n")
lines.append("*\n")
lines.append("* \\author Cathal Harte <[email protected]>\n")
lines.append("*/\n")
lines.append("\n")
lines.append("/*******************************************************************************\n")
lines.append("* Includes\n")
lines.append("*******************************************************************************/\n")
lines.append("\n")
lines.append("#include <gtest/gtest.h>\n")
lines.append("#include <%s.h>\n" % filename)
lines.append("\n")
lines.append("namespace\n")
lines.append("{\n")
lines.append("\n")
lines.append("/*******************************************************************************\n")
lines.append("* Definitions and types\n")
lines.append("*******************************************************************************/\n")
lines.append("\n")
lines.append("DEFINE_FFF_GLOBALS; //!< Required for FFF\n")
lines.append("\n")
lines.append("/*******************************************************************************\n")
lines.append("* Local Function prototypes\n")
lines.append("*******************************************************************************/\n")
lines.append("\n")
lines.append("\n")
lines.append("/*******************************************************************************\n")
lines.append("* Data\n")
lines.append("*******************************************************************************/\n")
lines.append("\n")
lines.append("\n")
lines.append("/*******************************************************************************\n")
lines.append("* Functions\n")
lines.append("*******************************************************************************/\n")
lines.append("\n")
lines.append("/* This will be deleted or overwritten soon */\n")
lines.append("TEST( testGroup1, scrap_test_1 )\n")
lines.append("{\n")
lines.append("\n")
lines.append("\n")
lines.append("}\n")
lines.append("\n")
lines.append("} // namespace\n")
lines.append("\n")
# Create and fill the file.
file = open(filename + "_test.cpp", "w")
for line in lines:
file.write( line )
file.close()