-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOutputFormat_Verbose.ipf
executable file
·143 lines (118 loc) · 3.58 KB
/
OutputFormat_Verbose.ipf
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef IGORUNIT_OUTPUTFORMAT_VERBOSE
#define IGORUNIT_OUTPUTFORMAT_VERBOSE
Function OFVerbose_init(of)
STRUCT OutputFormat &of
of.name = "Verbose"
OF_setFuncPointers(of, "OFVerbose")
End
Function/S OFVerbose_GroupStart(of, groupname)
STRUCT OutputFormat &of
String groupname
return groupname + "\r"
End
Function/S OFVerbose_TestStart(of, test)
STRUCT OutputFormat &of
STRUCT UnitTest &test
String result_line
String test_id = ""
String docstring = UnitTest_getDocString(test)
if (isStringExists(docstring))
test_id = docstring
else
test_id = UnitTest_getFuncname(test)
endif
sprintf result_line, " %s %s ", test_id, formatVerboseDashes(test_id)
return result_line
End
Function/S OFVerbose_TestSuccess(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return "OK\r"
End
Function/S OFVerbose_TestFailure(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return "FAIL\r"
End
Function/S OFVerbose_TestError(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return "ERROR\r"
End
Function/S OFVerbose_TestIgnore(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
return "IGNORE\r"
End
Function/S OFVerbose_AssertSuccess(of, test, assertion)
STRUCT OutputFormat &of
STRUCT UnitTest &test
STRUCT Assertion &assertion
return ""
End
Function/S OFVerbose_AssertFailure(of, test, assertion)
STRUCT OutputFormat &of
STRUCT UnitTest &test
STRUCT Assertion &assertion
return ""
End
Function/S OFVerbose_TestSuiteSummary(of, tr, ts)
STRUCT OutputFormat &of
STRUCT TestResult &tr
STRUCT TestSuite &ts
return OFBasic_TestSuiteSummary(of, tr, ts)
End
Function/S OFVerbose_TestOutcomeSummary(of, to)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
String groupname = TO_getGroupname(to)
String testname = TO_getTestname(to)
String funcname = TO_getFuncname(to)
String filename = TO_getFilename(to)
String docstring = TO_getDocString(to)
Variable linenum = TO_getLineNumber(to)
String message = TO_getMessage(to)
String defect_summary
sprintf defect_summary, "%s (%s) in %s at line %d\r", testname, funcname, filename, linenum
if (isStringExists(groupname))
sprintf defect_summary, "%s, %s", groupname, defect_summary
endif
if (isStringExists(docstring))
sprintf defect_summary, "%s %s\r", defect_summary, docstring
endif
if (isStringExists(message))
String msg_line
sprintf msg_line, "\t%s\r", message
defect_summary += msg_line
endif
return defect_summary
End
Function/S OFVerbose_AssertionSummary(of, to, assertion)
STRUCT OutputFormat &of
STRUCT TestOutcome &to
STRUCT Assertion &assertion
Variable result_code = Assertion_getResult(assertion)
String type = Assertion_getTypeName(assertion)
String param_list = Assertion_getParams(assertion)
String message = Assertion_getFullMessage(assertion)
String stack_info = Assertion_getStack(assertion)
Variable linenum = Assertion_getLineNumber(assertion)
if (isStringExists(message))
message = message + ", "
endif
String summary
sprintf summary, "\t%s(%s), %s at line %d\r", type, param_list, message, linenum
return summary
End
Constant DASH_COLUMN = 50
Function/S formatVerboseDashes(test_description)
String test_description
String res_dashes = ""
Variable dash_length = DASH_COLUMN - strlen(test_description)
Variable i
for (i=0; i< dash_length; i+=1)
res_dashes += "."
endfor
return res_dashes
End
#endif