#include <algorithm>
#include <fstream>
#include <iostream>
-
+#include <ostream>
+
namespace libtest {
std::string& escape4XML(std::string const& arg, std::string& escaped_string)
for (std::string::const_iterator x= arg.begin(), end= arg.end(); x != end; ++x)
{
unsigned char c= *x;
- if (' ' <= c and c <= '~' and c != '\\' and c != '"' and c != '>' and c != '<')
+ if (c == '&')
{
- escaped_string+= c;
+ escaped_string+= "&";
}
else if (c == '>')
{
- escaped_string+= '&';
- escaped_string+= 'g';
- escaped_string+= 't';
- escaped_string+= ';';
+ escaped_string+= ">";
}
else if (c == '<')
{
- escaped_string+= '&';
- escaped_string+= 'l';
- escaped_string+= 't';
- escaped_string+= ';';
+ escaped_string+= "<";
+ }
+ else if (c == '\'')
+ {
+ escaped_string+= "'"; break;
+ }
+ else if (c == '"')
+ {
+ escaped_string+= """;
+ }
+ else if (c == ' ')
+ {
+ escaped_string+= ' ';
+ }
+ else if (isalnum(c))
+ {
+ escaped_string+= c;
}
else
{
- escaped_string+= '\\';
- switch (c) {
- case '"': escaped_string+= '"'; break;
- case '\\': escaped_string+= '\\'; break;
- case '\t': escaped_string+='t'; break;
- case '\r': escaped_string+='r'; break;
- case '\n': escaped_string+='n'; break;
- default:
- char const* const hexdig= "0123456789ABCDEF";
- escaped_string+= 'x';
- escaped_string+= hexdig[c >> 4];
- escaped_string+= hexdig[c & 0xF];
- }
+ char const* const hexdig= "0123456789ABCDEF";
+ escaped_string+= "&#x";
+ escaped_string+= hexdig[c >> 4];
+ escaped_string+= hexdig[c & 0xF];
+ escaped_string+= ';';
}
}
escaped_string+= '"';
void Formatter::skipped()
{
+ assert(current());
current()->result(TEST_SKIPPED);
- Out << name() << "."
- << current()->name()
- << "\t\t\t\t\t"
- << "[ " << test_strerror(current()->result()) << " ]";
+
+ Out
+ << "[ " << test_strerror(current()->result()) << " ]"
+ << "\t\t"
+ << name() << "." << current()->name()
+ ;
reset();
}
assert(current());
current()->result(TEST_FAILURE);
- Out << name()
- << "." << current()->name() << "\t\t\t\t\t"
- << "[ " << test_strerror(current()->result()) << " ]";
+ Out
+ << "[ " << test_strerror(current()->result()) << " ]"
+ << "\t\t"
+ << name() << "." << current()->name()
+ ;
reset();
}
{
assert(current());
current()->result(TEST_SUCCESS, timer_);
- std::string escaped_string;
- Out << name() << "."
- << current()->name()
- << "\t\t\t\t\t"
- << current()->timer()
- << " [ " << test_strerror(current()->result()) << " ]";
+ Out
+ << "[ " << test_strerror(current()->result()) << " ]"
+ << "\t"
+ << current()->timer()
+ << "\t"
+ << name() << "." << current()->name()
+ ;
reset();
}
<< escape4XML((*case_iter)->name(), escaped_string)
<< " time=\""
<< (*case_iter)->timer().elapsed_milliseconds()
- << "\""
- << std::endl;
+ << "\"";
switch ((*case_iter)->result())
{
assert(_suite_name.empty() == false);
TestCase* _current_testcase= new TestCase(arg);
_testcases.push_back(_current_testcase);
+
+ assert(current());
+
+ Echo
+ << "\t\t\t"
+ << name() << "." << current()->name()
+ << "... \r"
+ ;
}
void Formatter::reset()