45
45
namespace libtest {
47
std::string& escape4XML(std::string const& arg, std::string& escaped_string)
49
escaped_string.clear();
52
for (std::string::const_iterator x= arg.begin(), end= arg.end(); x != end; ++x)
57
escaped_string+= "&";
61
escaped_string+= ">";
65
escaped_string+= "<";
69
escaped_string+= "'"; break;
73
escaped_string+= """;
85
char const* const hexdig= "0123456789ABCDEF";
86
escaped_string+= "&#x";
87
escaped_string+= hexdig[c >> 4];
88
escaped_string+= hexdig[c & 0xF];
94
return escaped_string;
49
99
TestCase(const std::string& arg):
110
160
void Formatter::skipped()
112
162
current()->result(TEST_SKIPPED);
113
Out << name() << "." << current()->name() << "\t\t\t\t\t" << "[ " << test_strerror(current()->result()) << " ]";
166
<< "[ " << test_strerror(current()->result()) << " ]";
120
173
assert(current());
121
174
current()->result(TEST_FAILURE);
123
Out << name() << "." << current()->name() << "\t\t\t\t\t" << "[ " << test_strerror(current()->result()) << " ]";
177
<< "." << current()->name() << "\t\t\t\t\t"
178
<< "[ " << test_strerror(current()->result()) << " ]";
142
198
void Formatter::xml(libtest::Framework& framework_, std::ofstream& output)
144
output << "<testsuites name=\"" << framework_.name() << "\">" << std::endl;
200
std::string escaped_string;
202
output << "<testsuites name="
203
<< escape4XML(framework_.name(), escaped_string) << ">" << std::endl;
145
205
for (Suites::iterator framework_iter= framework_.suites().begin();
146
206
framework_iter != framework_.suites().end();
147
207
++framework_iter)
149
output << "\t<testsuite name=\"" << (*framework_iter)->name() << "\" classname=\"\" package=\"\">" << std::endl;
209
output << "\t<testsuite name="
210
<< escape4XML((*framework_iter)->name(), escaped_string)
212
<< " classname=\"\" package=\"\""
151
216
for (TestCases::iterator case_iter= (*framework_iter)->formatter()->testcases().begin();
152
217
case_iter != (*framework_iter)->formatter()->testcases().end();
155
output << "\t\t<testcase name=\""
156
<< (*case_iter)->name()
220
output << "\t\t<testcase name="
221
<< escape4XML((*case_iter)->name(), escaped_string)
158
223
<< (*case_iter)->timer().elapsed_milliseconds()
162
226
switch ((*case_iter)->result())
164
228
case TEST_SKIPPED:
229
output << ">" << std::endl;
165
230
output << "\t\t <skipped/>" << std::endl;
231
output << "\t\t</testcase>" << std::endl;
168
234
case TEST_FAILURE:
235
output << ">" << std::endl;
169
236
output << "\t\t <failure message=\"\" type=\"\"/>"<< std::endl;
237
output << "\t\t</testcase>" << std::endl;
172
240
case TEST_SUCCESS:
241
output << "/>" << std::endl;
175
output << "\t\t</testcase>" << std::endl;
177
245
output << "\t</testsuite>" << std::endl;