mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
Remove trailing whitespace
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
# include "winconfig.h"
|
||||
#else
|
||||
# include "config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "cpptest-collectoroutput.h"
|
||||
|
||||
@@ -46,21 +46,21 @@ namespace Test
|
||||
{
|
||||
_tests.reserve(tests);
|
||||
}
|
||||
|
||||
|
||||
/// Constructs a collector object.
|
||||
///
|
||||
CollectorOutput::CollectorOutput()
|
||||
: Output(),
|
||||
_total_errors(0)
|
||||
{}
|
||||
|
||||
|
||||
void
|
||||
CollectorOutput::finished(int tests, const Time& time)
|
||||
{
|
||||
_total_tests = tests;
|
||||
_total_time = time;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CollectorOutput::suite_start(int tests, const string& name)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace Test
|
||||
_cur_suite = &_suites.back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CollectorOutput::suite_end(int tests, const string&, const Time& time)
|
||||
{
|
||||
@@ -80,14 +80,14 @@ namespace Test
|
||||
_total_errors += _cur_suite->_errors;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CollectorOutput::test_start(const string& name)
|
||||
{
|
||||
_cur_suite->_tests.push_back(TestInfo(name));
|
||||
_cur_test = &_cur_suite->_tests.back();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CollectorOutput::test_end(const string&, bool ok, const Time& time)
|
||||
{
|
||||
@@ -95,12 +95,12 @@ namespace Test
|
||||
++_cur_suite->_errors;
|
||||
_cur_test->_time = time;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CollectorOutput::assertment(const Source& s)
|
||||
{
|
||||
_cur_test->_sources.push_back(s);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
@@ -50,12 +50,12 @@ namespace Test
|
||||
throw Test::CompilerOutput::InvalidFormat(format);
|
||||
pos += mod.size();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
/// Constructs a compiler output handler.
|
||||
///
|
||||
/// \param format Pre-defined compiler output format.
|
||||
@@ -72,10 +72,10 @@ namespace Test
|
||||
"%file:%line: %text", // GCC
|
||||
"%file(%line) : %text" // MSVC
|
||||
};
|
||||
|
||||
|
||||
_format = table[format];
|
||||
}
|
||||
|
||||
|
||||
/// Constructs a compiler output handler.
|
||||
///
|
||||
/// \param format %Output format to use.
|
||||
@@ -89,7 +89,7 @@ namespace Test
|
||||
_stream(stream)
|
||||
{
|
||||
int expr(0), file(0), line(0);
|
||||
|
||||
|
||||
for (string::size_type pos = 0;
|
||||
(pos = _format.find_first_of('%', pos)) != string::npos; )
|
||||
{
|
||||
@@ -100,34 +100,34 @@ namespace Test
|
||||
else
|
||||
throw InvalidFormat(format);
|
||||
}
|
||||
|
||||
|
||||
if (!expr && !file && !line)
|
||||
throw InvalidFormat(format);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutput::assertment(const Source& s)
|
||||
{
|
||||
string fmt(_format);
|
||||
string::size_type pos;
|
||||
|
||||
|
||||
fmt.reserve(fmt.size() + 128);
|
||||
|
||||
|
||||
if ((pos = fmt.find("%file")) != string::npos)
|
||||
fmt.replace(pos, 5, s.file());
|
||||
|
||||
|
||||
if ((pos = fmt.find("%text")) != string::npos)
|
||||
fmt.replace(pos, 5, s.message());
|
||||
|
||||
|
||||
if ((pos = fmt.find("%line")) != string::npos)
|
||||
{
|
||||
ostringstream ss;
|
||||
ss << s.line();
|
||||
fmt.replace(pos, 5, ss.str());
|
||||
}
|
||||
|
||||
|
||||
_stream << fmt << endl;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
/// \param a First expression to test.
|
||||
/// \param b Second expression to test.
|
||||
/// \param delta Constant.
|
||||
/// \param msg User message.
|
||||
/// \param msg User message.
|
||||
///
|
||||
/// \see TEST_ASSERT_DELTA(a, b, delta)
|
||||
///
|
||||
@@ -245,7 +245,7 @@
|
||||
if (!continue_after_failure()) return; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/// Verify an expression and expects an exception in return.
|
||||
/// An assertment is issued if the exception is not thrown.
|
||||
///
|
||||
@@ -343,7 +343,7 @@
|
||||
if (!continue_after_failure()) return; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/// Verify an expression and expects no exception in return.
|
||||
/// An assertment is issued if any exception is thrown.
|
||||
///
|
||||
|
||||
@@ -55,52 +55,52 @@ namespace Test
|
||||
virtual void test_end(const std::string& name, bool ok,
|
||||
const Time& time);
|
||||
virtual void assertment(const Source& s);
|
||||
|
||||
|
||||
protected:
|
||||
struct OutputSuiteInfo;
|
||||
struct OutputTestInfo;
|
||||
struct OutputErrorTestInfo;
|
||||
|
||||
|
||||
typedef std::list<Source> Sources;
|
||||
|
||||
|
||||
struct TestInfo
|
||||
{
|
||||
std::string _name;
|
||||
Time _time;
|
||||
|
||||
|
||||
bool _success : 1;
|
||||
Sources _sources;
|
||||
|
||||
|
||||
explicit TestInfo(const std::string name);
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector<TestInfo> Tests;
|
||||
|
||||
|
||||
struct SuiteInfo
|
||||
{
|
||||
std::string _name;
|
||||
int _errors;
|
||||
Tests _tests;
|
||||
Time _time;
|
||||
|
||||
|
||||
SuiteInfo(const std::string& name, int tests);
|
||||
};
|
||||
|
||||
|
||||
typedef std::list<SuiteInfo> Suites;
|
||||
|
||||
|
||||
Suites _suites;
|
||||
int _total_errors;
|
||||
int _total_tests;
|
||||
Time _total_time;
|
||||
|
||||
|
||||
CollectorOutput();
|
||||
|
||||
|
||||
private:
|
||||
SuiteInfo* _cur_suite;
|
||||
TestInfo* _cur_test;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
#endif // #ifndef CPPTEST_COLLECTOROUTPUT_H
|
||||
|
||||
|
||||
@@ -64,14 +64,14 @@ namespace Test
|
||||
InvalidFormat(const std::string& what)
|
||||
: std::logic_error(what) {}
|
||||
};
|
||||
|
||||
|
||||
/// Pre-defined compiler output formats.
|
||||
///
|
||||
enum Format
|
||||
{
|
||||
/// Generic compiler format, which equals:
|
||||
/// <tt>%%file:%%line: %%text</tt>
|
||||
///
|
||||
///
|
||||
Generic,
|
||||
|
||||
/// <a href="http://www.borland.com/products/downloads/download_cbuilder.html">
|
||||
@@ -79,34 +79,34 @@ namespace Test
|
||||
/// <tt>Error cpptest %%file %%line: %%text</tt>.
|
||||
///
|
||||
BCC,
|
||||
|
||||
/// <a href="http://gcc.gnu.org">GNU Compiler Collection</a>
|
||||
|
||||
/// <a href="http://gcc.gnu.org">GNU Compiler Collection</a>
|
||||
/// (GCC) format, which equals:
|
||||
/// <tt>%%file:%%line: %%text</tt>
|
||||
///
|
||||
GCC,
|
||||
|
||||
/// <a href="http://www.microsoft.com">Microsoft Visual C++</a>
|
||||
/// <a href="http://www.microsoft.com">Microsoft Visual C++</a>
|
||||
/// (MSVC) format, which equals:
|
||||
/// <tt>%%file(%%line) : %%text</tt>
|
||||
///
|
||||
MSVC
|
||||
};
|
||||
|
||||
|
||||
explicit CompilerOutput(Format format = Generic,
|
||||
std::ostream& stream = std::cout);
|
||||
|
||||
|
||||
explicit CompilerOutput(const std::string& format,
|
||||
std::ostream& stream = std::cout);
|
||||
|
||||
|
||||
virtual void assertment(const Source& s);
|
||||
|
||||
|
||||
private:
|
||||
std::string _format;
|
||||
std::ostream& _stream;
|
||||
};
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
#endif // #ifndef CPPTEST_COMPILEROUTPUT_H
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace Test
|
||||
class HtmlOutput : public CollectorOutput
|
||||
{
|
||||
public:
|
||||
void generate(std::ostream& os, bool incl_ok_tests = true,
|
||||
void generate(std::ostream& os, bool incl_ok_tests = true,
|
||||
const std::string& name = "");
|
||||
|
||||
|
||||
private:
|
||||
struct SuiteRow;
|
||||
struct TestRow;
|
||||
@@ -57,8 +57,8 @@ namespace Test
|
||||
|
||||
friend struct TestSuiteRow;
|
||||
};
|
||||
|
||||
} // namespace Test
|
||||
|
||||
#endif // #ifndef CPPTEST_HTMLOUTPUT_H
|
||||
|
||||
} // namespace Test
|
||||
|
||||
#endif // #ifndef CPPTEST_HTMLOUTPUT_H
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Test
|
||||
{
|
||||
class Source;
|
||||
class Time;
|
||||
|
||||
|
||||
/// \brief %Test suite output handler.
|
||||
///
|
||||
/// Abstract base class for all suite output handlers. Derive from this
|
||||
@@ -58,7 +58,7 @@ namespace Test
|
||||
/// Empty destructor.
|
||||
///
|
||||
virtual ~Output() {}
|
||||
|
||||
|
||||
/// Called when testing is started.
|
||||
///
|
||||
/// \param tests Total number of tests in all suites.
|
||||
@@ -67,7 +67,7 @@ namespace Test
|
||||
{
|
||||
CPPTEST_UNUSED(tests);
|
||||
}
|
||||
|
||||
|
||||
/// Called when testing is finished.
|
||||
///
|
||||
/// \param tests Total number of tests in all suites.
|
||||
@@ -89,7 +89,7 @@ namespace Test
|
||||
CPPTEST_UNUSED(tests);
|
||||
CPPTEST_UNUSED(name);
|
||||
}
|
||||
|
||||
|
||||
/// Called when a suite is finished.
|
||||
///
|
||||
/// \param tests Number of tests in this suite.
|
||||
@@ -103,7 +103,7 @@ namespace Test
|
||||
CPPTEST_UNUSED(name);
|
||||
CPPTEST_UNUSED(time);
|
||||
}
|
||||
|
||||
|
||||
/// Called when a tests is executed.
|
||||
///
|
||||
/// \param name Name of the test function.
|
||||
@@ -112,7 +112,7 @@ namespace Test
|
||||
{
|
||||
CPPTEST_UNUSED(name);
|
||||
}
|
||||
|
||||
|
||||
/// Called when a test if finished, regardless if an assertment was
|
||||
/// issued.
|
||||
///
|
||||
@@ -127,7 +127,7 @@ namespace Test
|
||||
CPPTEST_UNUSED(ok);
|
||||
CPPTEST_UNUSED(time);
|
||||
}
|
||||
|
||||
|
||||
/// Called when an assertment is issued.
|
||||
///
|
||||
/// \param s Assert point information.
|
||||
@@ -141,12 +141,12 @@ namespace Test
|
||||
/// Empty constructor.
|
||||
///
|
||||
Output() {}
|
||||
|
||||
|
||||
private:
|
||||
Output(const Output&);
|
||||
Output& operator=(const Output&);
|
||||
};
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
#endif // #ifndef CPPTEST_OUTPUT_H
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
namespace Test
|
||||
{
|
||||
class Suite;
|
||||
|
||||
|
||||
/// \brief Assertment source information.
|
||||
///
|
||||
/// Contains information about an assertment point.
|
||||
@@ -42,17 +42,17 @@ namespace Test
|
||||
class Source
|
||||
{
|
||||
friend class Suite;
|
||||
|
||||
|
||||
public:
|
||||
Source();
|
||||
Source(const char* file, unsigned int line, const char* msg);
|
||||
|
||||
|
||||
const std::string& file() const;
|
||||
unsigned int line() const;
|
||||
const std::string& message() const;
|
||||
const std::string& suite() const;
|
||||
const std::string& test() const;
|
||||
|
||||
|
||||
private:
|
||||
unsigned int _line;
|
||||
std::string _file;
|
||||
@@ -60,7 +60,7 @@ namespace Test
|
||||
std::string _suite;
|
||||
std::string _test;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
#endif // #ifndef CPPTEST_SOURCE_H
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
namespace Test
|
||||
{
|
||||
class Output;
|
||||
|
||||
|
||||
/// \brief Unit testing suite.
|
||||
///
|
||||
/// Base class for all suites. Derive from this class to create own
|
||||
@@ -51,52 +51,52 @@ namespace Test
|
||||
///
|
||||
class Suite
|
||||
{
|
||||
public:
|
||||
public:
|
||||
Suite();
|
||||
virtual ~Suite();
|
||||
|
||||
|
||||
void add(Suite* suite);
|
||||
|
||||
|
||||
bool run(Output& output, bool cont_after_fail = true);
|
||||
|
||||
|
||||
protected:
|
||||
/// Pointer to a test function.
|
||||
///
|
||||
typedef void (Suite::*Func)();
|
||||
|
||||
|
||||
bool continue_after_failure() const { return _continue; }
|
||||
|
||||
|
||||
virtual void setup() {}
|
||||
virtual void tear_down() {}
|
||||
|
||||
|
||||
void register_test(Func func, const std::string& name);
|
||||
void assertment(Source s);
|
||||
|
||||
|
||||
private:
|
||||
struct DoRun;
|
||||
struct ExecTests;
|
||||
struct SubSuiteTests;
|
||||
struct SuiteTime;
|
||||
struct SubSuiteTime;
|
||||
|
||||
|
||||
friend struct DoRun;
|
||||
friend struct ExecTests;
|
||||
friend struct SubSuiteTests;
|
||||
friend struct SubSuiteTime;
|
||||
|
||||
|
||||
struct Data
|
||||
{
|
||||
Func _func;
|
||||
std::string _name;
|
||||
Time _time;
|
||||
|
||||
|
||||
Data(Func func, const std::string& name)
|
||||
: _func(func), _name(name) {}
|
||||
};
|
||||
|
||||
|
||||
typedef std::list<Data> Tests;
|
||||
typedef std::list<Suite*> Suites;
|
||||
|
||||
|
||||
std::string _name; // Suite name
|
||||
const std::string* _cur_test; // Current test func name
|
||||
Suites _suites; // External test suites
|
||||
@@ -105,11 +105,11 @@ namespace Test
|
||||
bool _result : 1; // Test result
|
||||
bool _success : 1; // Set if no test failed
|
||||
bool _continue : 1; // Continue func after failures
|
||||
|
||||
|
||||
void do_run(Output* os, bool cont_after_fail);
|
||||
int total_tests() const;
|
||||
Time total_time(bool recursive) const;
|
||||
|
||||
|
||||
// Disable
|
||||
//
|
||||
Suite(const Suite&);
|
||||
@@ -133,7 +133,7 @@ namespace Test
|
||||
///
|
||||
#define TEST_ADD(func)\
|
||||
register_test(static_cast<Func>(&func), #func);
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
#endif // #ifndef CPPTEST_SUITE_H
|
||||
|
||||
@@ -53,15 +53,15 @@ namespace Test
|
||||
/// Terse output mode, which only shows the number of correct tests.
|
||||
///
|
||||
Terse,
|
||||
|
||||
|
||||
/// Verbose output mode, which also shows extended assert
|
||||
/// information for each test that failed.
|
||||
///
|
||||
Verbose
|
||||
Verbose
|
||||
};
|
||||
|
||||
|
||||
TextOutput(Mode mode, std::ostream& stream = std::cout);
|
||||
|
||||
|
||||
virtual void finished(int tests, const Time& time);
|
||||
virtual void suite_start(int tests, const std::string& name);
|
||||
virtual void suite_end(int tests, const std::string& name,
|
||||
@@ -69,10 +69,10 @@ namespace Test
|
||||
virtual void test_end(const std::string& name, bool ok,
|
||||
const Time& time);
|
||||
virtual void assertment(const Source& s);
|
||||
|
||||
|
||||
private:
|
||||
typedef std::list<Source> ErrorList;
|
||||
|
||||
|
||||
Mode _mode;
|
||||
std::ostream& _stream;
|
||||
ErrorList _suite_error_list;
|
||||
@@ -84,5 +84,5 @@ namespace Test
|
||||
};
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
#endif // #ifndef CPPTEST_TEXTOUTPUT_H
|
||||
|
||||
@@ -45,22 +45,22 @@ namespace Test
|
||||
public:
|
||||
Time();
|
||||
Time(unsigned int sec, unsigned int usec);
|
||||
|
||||
|
||||
unsigned int seconds() const;
|
||||
unsigned int microseconds() const;
|
||||
|
||||
|
||||
static Time current();
|
||||
|
||||
|
||||
friend Time operator+(const Time& t1, const Time& t2);
|
||||
friend Time operator-(const Time& t1, const Time& t2);
|
||||
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const Time& t);
|
||||
|
||||
|
||||
private:
|
||||
unsigned int _sec;
|
||||
unsigned int _usec;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
#endif // #ifndef CPPTEST_TIME_H
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
# include "winconfig.h"
|
||||
#else
|
||||
# include "config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "cpptest-htmloutput.h"
|
||||
#include "utils.h"
|
||||
@@ -52,7 +52,7 @@ namespace Test
|
||||
idx += replace.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
escape(string value)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ namespace Test
|
||||
strreplace(value, '\'', "'");
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
header(ostream& os, string name)
|
||||
{
|
||||
@@ -149,7 +149,7 @@ namespace Test
|
||||
"<hr />\n"
|
||||
"\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
footer(ostream& os)
|
||||
{
|
||||
@@ -162,15 +162,15 @@ namespace Test
|
||||
"</p>\n"
|
||||
"</body>\n</html>\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
back_ref(ostream& os, const string& ref, bool prepend_newline = true)
|
||||
{
|
||||
|
||||
|
||||
os << "<p class=\"" << (prepend_newline ? "spaced" : "unspaced") << "\"><a href=\"#" << ref
|
||||
<< "\">Back to " << escape(ref) << "</a>\n</p>\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sub_title(ostream& os, const string& title, int size)
|
||||
{
|
||||
@@ -186,43 +186,43 @@ namespace Test
|
||||
h << "h" << size;
|
||||
os << "<" << h.str() << "><a name=\"" << mark << "\"></a>" << escape(title) << "</" << h.str() << ">\n";
|
||||
}
|
||||
|
||||
|
||||
enum ClassTableType { TableClass_Summary, TableClass_Suites, TableClass_Suite, TableClass_Result };
|
||||
|
||||
|
||||
void
|
||||
table_header(ostream& os, ClassTableType type, const string &summary = "")
|
||||
{
|
||||
static const char* class_tabletypes[] = { "summary", "suites", "suite", "result" };
|
||||
|
||||
|
||||
os << "<table summary=\"" << escape(summary) << "\" class=\"table_" << class_tabletypes[type] << "\">\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
table_footer(ostream& os)
|
||||
{
|
||||
os << "</table>\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
table_tr_header(ostream& os)
|
||||
{
|
||||
os << " <tr>\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
table_tr_footer(ostream& os)
|
||||
{
|
||||
os << " </tr>\n";
|
||||
}
|
||||
|
||||
|
||||
enum ClassType { Title, Success, Error };
|
||||
|
||||
|
||||
void
|
||||
table_entry(ostream& os, ClassType type, const string& s,
|
||||
int width = 0, const string& link = "")
|
||||
{
|
||||
static const char* class_types[] = { "title", "success", "error" };
|
||||
|
||||
|
||||
os << " <td";
|
||||
if (width)
|
||||
os << " style=\"width:" << width << "%\"";
|
||||
@@ -230,11 +230,11 @@ namespace Test
|
||||
os << " class=\"tablecell_" << class_types[type] << "\"><a href=\"#" << link << "\">" << escape(s) << "</a>";
|
||||
else
|
||||
os << " class=\"tablecell_" << class_types[type] << "\">" << escape(s);
|
||||
os << "</td>\n";
|
||||
os << "</td>\n";
|
||||
}
|
||||
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
// Test suite table
|
||||
//
|
||||
struct HtmlOutput::SuiteRow
|
||||
@@ -259,7 +259,7 @@ namespace Test
|
||||
table_tr_footer(_os);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Individual tests tables, tests
|
||||
//
|
||||
struct HtmlOutput::TestRow
|
||||
@@ -276,7 +276,7 @@ namespace Test
|
||||
ti._sources.front().suite() + "_" + ti._name;
|
||||
ClassType type(ti._success ? Success : Error);
|
||||
ostringstream ss;
|
||||
|
||||
|
||||
table_tr_header(_os);
|
||||
table_entry(_os, type, ti._name, 0, link);
|
||||
ss.str(""), ss << ti._sources.size();
|
||||
@@ -288,19 +288,19 @@ namespace Test
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Individual tests tables, header
|
||||
//
|
||||
struct HtmlOutput::TestSuiteRow
|
||||
{
|
||||
bool _incl_ok_tests;
|
||||
ostream& _os;
|
||||
TestSuiteRow(ostream& os, bool incl_ok_tests)
|
||||
TestSuiteRow(ostream& os, bool incl_ok_tests)
|
||||
: _incl_ok_tests(incl_ok_tests), _os(os) {}
|
||||
void operator()(const SuiteInfo& si)
|
||||
{
|
||||
ostringstream ss;
|
||||
|
||||
|
||||
sub_title(_os, "Suite: " + si._name, 3, si._name);
|
||||
table_header(_os, TableClass_Suite, "Details for suite " + si._name);
|
||||
table_tr_header(_os);
|
||||
@@ -309,13 +309,13 @@ namespace Test
|
||||
table_entry(_os, Title, "Success", 10);
|
||||
table_entry(_os, Title, "Time (s)", 10);
|
||||
table_tr_footer(_os);
|
||||
for_each(si._tests.begin(), si._tests.end(),
|
||||
for_each(si._tests.begin(), si._tests.end(),
|
||||
TestRow(_os, _incl_ok_tests));
|
||||
table_footer(_os);
|
||||
back_ref(_os, "top");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Individual tests result tables
|
||||
//
|
||||
struct HtmlOutput::TestResult
|
||||
@@ -325,9 +325,9 @@ namespace Test
|
||||
void operator()(const Source& s)
|
||||
{
|
||||
const int TitleSize = 15;
|
||||
|
||||
|
||||
ostringstream ss;
|
||||
|
||||
|
||||
table_header(_os, TableClass_Result, "Test Failure");
|
||||
table_tr_header(_os);
|
||||
table_entry(_os, Title, "Test", TitleSize);
|
||||
@@ -345,7 +345,7 @@ namespace Test
|
||||
table_footer(_os);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// All tests result tables
|
||||
//
|
||||
struct HtmlOutput::TestResultAll
|
||||
@@ -357,14 +357,14 @@ namespace Test
|
||||
if (!ti._success)
|
||||
{
|
||||
const string& suite = ti._sources.front().suite();
|
||||
|
||||
|
||||
sub_title(_os, suite + "::" + ti._name, 3, suite + "_" + ti._name);
|
||||
for_each(ti._sources.begin(), ti._sources.end(), TestResult(_os));
|
||||
back_ref(_os, suite, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Individual tests result tables, iterator
|
||||
//
|
||||
struct HtmlOutput::SuiteTestResult
|
||||
@@ -376,12 +376,12 @@ namespace Test
|
||||
for_each(si._tests.begin(), si._tests.end(), TestResultAll(_os));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// Generates the HTML table. This function should only be called after
|
||||
/// run(), when all tests have been executed.
|
||||
///
|
||||
/// \param os Output stream.
|
||||
/// \param incl_ok_tests Set if successful tests should be shown;
|
||||
/// \param incl_ok_tests Set if successful tests should be shown;
|
||||
/// false otherwise.
|
||||
/// \param name Name of generated report.
|
||||
///
|
||||
@@ -390,9 +390,9 @@ namespace Test
|
||||
{
|
||||
ClassType type(_total_errors > 0 ? Error : Success);
|
||||
ostringstream ss;
|
||||
|
||||
|
||||
header(os, name);
|
||||
|
||||
|
||||
// Table: Summary
|
||||
//
|
||||
sub_title(os, "Summary", 2);
|
||||
@@ -415,7 +415,7 @@ namespace Test
|
||||
table_tr_footer(os);
|
||||
table_footer(os);
|
||||
os << "<hr />\n\n";
|
||||
|
||||
|
||||
// Table: Test suites
|
||||
//
|
||||
sub_title(os, "Test suites", 2);
|
||||
@@ -430,12 +430,12 @@ namespace Test
|
||||
for_each(_suites.begin(), _suites.end(), SuiteRow(os));
|
||||
table_footer(os);
|
||||
os << "<hr />\n\n";
|
||||
|
||||
|
||||
// Individual tests tables
|
||||
//
|
||||
for_each(_suites.begin(), _suites.end(), TestSuiteRow(os, incl_ok_tests));
|
||||
os << "<hr />\n\n";
|
||||
|
||||
|
||||
// Individual tests result tables
|
||||
//
|
||||
if(_total_errors != 0)
|
||||
@@ -443,11 +443,11 @@ namespace Test
|
||||
sub_title(os, "Test results", 2);
|
||||
for_each(_suites.begin(), _suites.end(), SuiteTestResult(os));
|
||||
os << "<hr />\n\n";
|
||||
}
|
||||
}
|
||||
// EOF
|
||||
//
|
||||
footer(os);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# include "winconfig.h"
|
||||
#else
|
||||
# include "config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "missing.h"
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <cmath>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <ctime>
|
||||
@@ -53,7 +53,7 @@ namespace Test
|
||||
gettimeofday(timeval* tv, void*)
|
||||
{
|
||||
assert(tv);
|
||||
|
||||
|
||||
#ifdef HAVE_GETTICKCOUNT
|
||||
long now = GetTickCount();
|
||||
tv->tv_sec = now / 1000;
|
||||
@@ -62,10 +62,10 @@ namespace Test
|
||||
tv->tv_sec = time(0);
|
||||
tv->tv_usec = 0;
|
||||
#endif // #ifdef HAVE_GETTICKCOUNT
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // #ifndef HAVE_GETTIMEOFDAY
|
||||
|
||||
#ifndef HAVE_ROUND
|
||||
@@ -74,7 +74,7 @@ namespace Test
|
||||
{
|
||||
return d > 0.0 ? floor(d + 0.5) : ceil(d - 0.5);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
# include "winconfig.h"
|
||||
#else
|
||||
# include "config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace Test
|
||||
{
|
||||
@@ -42,15 +42,15 @@ namespace Test
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
|
||||
|
||||
extern int gettimeofday(timeval* tv, void*);
|
||||
|
||||
|
||||
#endif // #ifndef HAVE_GETTIMEOFDAY
|
||||
|
||||
|
||||
#ifndef HAVE_ROUND
|
||||
extern double round(double d);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Test
|
||||
|
||||
#endif // #ifndef CPPTEST_MISSING_H
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Test
|
||||
Source::Source()
|
||||
: _line(0)
|
||||
{}
|
||||
|
||||
|
||||
/// Constructs a source object.
|
||||
///
|
||||
/// \param file Name of the file containing the failing function.
|
||||
@@ -48,15 +48,15 @@ namespace Test
|
||||
_file(file ? file : ""),
|
||||
_msg(msg ? msg : "")
|
||||
{}
|
||||
|
||||
|
||||
/// \return Name of the file containing the failing function.
|
||||
///
|
||||
const string&
|
||||
Source::file() const
|
||||
Source::file() const
|
||||
{
|
||||
return _file;
|
||||
}
|
||||
|
||||
|
||||
/// \return Line where the function starts.
|
||||
///
|
||||
unsigned int
|
||||
@@ -64,7 +64,7 @@ namespace Test
|
||||
{
|
||||
return _line;
|
||||
}
|
||||
|
||||
|
||||
/// \return Descriptive message.
|
||||
///
|
||||
const string&
|
||||
@@ -72,7 +72,7 @@ namespace Test
|
||||
{
|
||||
return _msg;
|
||||
}
|
||||
|
||||
|
||||
/// \return Name of the suite, which the test belongs to.
|
||||
///
|
||||
const string&
|
||||
|
||||
+24
-24
@@ -34,7 +34,7 @@
|
||||
# include "winconfig.h"
|
||||
#else
|
||||
# include "config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "cpptest-output.h"
|
||||
#include "cpptest-source.h"
|
||||
@@ -55,9 +55,9 @@ namespace Test
|
||||
while (first != last)
|
||||
delete *first++;
|
||||
}
|
||||
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
/// Constructs an empty test suite.
|
||||
///
|
||||
Suite::Suite()
|
||||
@@ -65,14 +65,14 @@ namespace Test
|
||||
_output(0),
|
||||
_success(true)
|
||||
{}
|
||||
|
||||
|
||||
/// Destroys this suite object.
|
||||
///
|
||||
Suite::~Suite()
|
||||
{
|
||||
destroy_range(_suites.begin(), _suites.end());
|
||||
}
|
||||
|
||||
|
||||
/// Starts the testing. All tests in this suite and embedded suites will
|
||||
/// be executed.
|
||||
///
|
||||
@@ -90,7 +90,7 @@ namespace Test
|
||||
output.finished(ntests, total_time(true));
|
||||
return _success;
|
||||
}
|
||||
|
||||
|
||||
/// \fn void Suite::setup()
|
||||
///
|
||||
/// Setups a test fixture. This function is called before each test,
|
||||
@@ -100,7 +100,7 @@ namespace Test
|
||||
/// specialized behavior.
|
||||
///
|
||||
/// \see tear_down()
|
||||
|
||||
|
||||
/// \fn void Suite::tear_down()
|
||||
///
|
||||
/// Tears down a test fixture. This function is called after each test,
|
||||
@@ -110,7 +110,7 @@ namespace Test
|
||||
/// specialized behavior.
|
||||
///
|
||||
/// \see setup()
|
||||
|
||||
|
||||
/// Adds a suite to this suite. Tests in added suites will be executed
|
||||
/// when run() of the top-level suite is called.
|
||||
///
|
||||
@@ -121,7 +121,7 @@ namespace Test
|
||||
{
|
||||
_suites.push_back(suite);
|
||||
}
|
||||
|
||||
|
||||
/// Registers a test function.
|
||||
///
|
||||
/// \b Note: Do not call this function directly, use the TEST_ADD(func)
|
||||
@@ -136,11 +136,11 @@ namespace Test
|
||||
{
|
||||
string::size_type pos = name.find_first_of(':');
|
||||
assert(!name.empty() && name[pos + 1] == ':' && name[pos + 2] != '\0');
|
||||
|
||||
|
||||
_name.assign(name, 0, pos);
|
||||
_tests.push_back(Data(func, name.substr(pos + 2)));
|
||||
}
|
||||
|
||||
|
||||
/// Issues an assertment to the output handler.
|
||||
///
|
||||
/// Do not call this function directly, use one of the available assertment
|
||||
@@ -156,21 +156,21 @@ namespace Test
|
||||
_output->assertment(s);
|
||||
_result = _success = false;
|
||||
}
|
||||
|
||||
|
||||
// Functor to execute tests for the given suite.
|
||||
//
|
||||
struct Suite::ExecTests
|
||||
{
|
||||
Suite& _suite;
|
||||
|
||||
|
||||
ExecTests(Suite& s) : _suite(s) {}
|
||||
|
||||
|
||||
void operator()(Data& data)
|
||||
{
|
||||
_suite._cur_test = &data._name;
|
||||
_suite._result = true; // assume success, assert will set to false
|
||||
_suite._output->test_start(data._name);
|
||||
|
||||
|
||||
_suite.setup();
|
||||
Time start(Time::current());
|
||||
// FIXME Also feedback exception to user
|
||||
@@ -182,7 +182,7 @@ namespace Test
|
||||
}
|
||||
Time end(Time::current());
|
||||
_suite.tear_down();
|
||||
|
||||
|
||||
data._time = end - start;
|
||||
_suite._output->test_end(data._name, _suite._result, data._time);
|
||||
}
|
||||
@@ -194,7 +194,7 @@ namespace Test
|
||||
{
|
||||
bool _continue;
|
||||
Output* _output;
|
||||
|
||||
|
||||
DoRun(Output* output, bool cont) : _continue(cont), _output(output) {}
|
||||
void operator()(Suite* suite) { suite->do_run(_output, _continue); }
|
||||
};
|
||||
@@ -206,7 +206,7 @@ namespace Test
|
||||
{
|
||||
_continue = cont_after_fail;
|
||||
_output = os;
|
||||
|
||||
|
||||
_output->suite_start(_tests.size(), _name);
|
||||
for_each(_tests.begin(), _tests.end(), ExecTests(*this));
|
||||
_output->suite_end(_tests.size(), _name, total_time(false));
|
||||
@@ -235,7 +235,7 @@ namespace Test
|
||||
return value + s->total_tests();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Counts all tests in this and all its embedded suites.
|
||||
//
|
||||
int
|
||||
@@ -244,7 +244,7 @@ namespace Test
|
||||
return accumulate(_suites.begin(), _suites.end(),
|
||||
_tests.size(), SubSuiteTests());
|
||||
}
|
||||
|
||||
|
||||
// Functor to accumulate execution time for tests.
|
||||
//
|
||||
struct Suite::SuiteTime
|
||||
@@ -254,7 +254,7 @@ namespace Test
|
||||
return time + data._time;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Functor to accumulate execution time for suites.
|
||||
//
|
||||
struct Suite::SubSuiteTime
|
||||
@@ -264,7 +264,7 @@ namespace Test
|
||||
return time + s->total_time(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Counts time accumulated execution time for all tests in this and all
|
||||
// its embedded suites.
|
||||
//
|
||||
@@ -273,9 +273,9 @@ namespace Test
|
||||
{
|
||||
Time time = accumulate(_tests.begin(), _tests.end(),
|
||||
Time(), SuiteTime());
|
||||
|
||||
|
||||
return !recursive ? time : accumulate(_suites.begin(), _suites.end(),
|
||||
time, SubSuiteTime());
|
||||
}
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
# include "winconfig.h"
|
||||
#else
|
||||
# include "config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "cpptest-textoutput.h"
|
||||
#include "cpptest-time.h"
|
||||
@@ -55,12 +55,12 @@ namespace Test
|
||||
<< "\tFile: " << s.file() << endl
|
||||
<< "\tLine: " << s.line() << endl
|
||||
<< "\tMessage: " << s.message() << endl << endl;
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
/// Constructs a text output handler.
|
||||
///
|
||||
/// \param mode Output mode.
|
||||
@@ -71,7 +71,7 @@ namespace Test
|
||||
_stream(stream),
|
||||
_total_errors(0)
|
||||
{}
|
||||
|
||||
|
||||
void
|
||||
TextOutput::finished(int tests, const Time& time)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ namespace Test
|
||||
<< correct(tests, _total_errors) << "% correct"
|
||||
<< " in " << time << " seconds" << endl;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TextOutput::suite_start(int tests, const string& name)
|
||||
{
|
||||
@@ -89,13 +89,13 @@ namespace Test
|
||||
_suite_tests = _suite_errors = 0;
|
||||
_suite_total_tests = tests;
|
||||
_suite_error_list.clear();
|
||||
|
||||
|
||||
_stream << _suite_name << ": "
|
||||
<< "0/" << _suite_total_tests
|
||||
<< "\r" << flush;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TextOutput::suite_end(int tests, const string& name, const Time& time)
|
||||
{
|
||||
@@ -104,15 +104,15 @@ namespace Test
|
||||
_stream << name << ": " << tests << "/" << tests << ", "
|
||||
<< correct(tests, _suite_errors) << "% correct"
|
||||
<< " in " << time << " seconds" << endl;
|
||||
|
||||
|
||||
if (_mode == Verbose && _suite_errors)
|
||||
for_each(_suite_error_list.begin(), _suite_error_list.end(),
|
||||
ShowSource(_stream));
|
||||
|
||||
|
||||
_total_errors += _suite_errors;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TextOutput::test_end(const string&, bool ok, const Time&)
|
||||
{
|
||||
@@ -122,11 +122,11 @@ namespace Test
|
||||
if (!ok)
|
||||
++_suite_errors;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TextOutput::assertment(const Source& s)
|
||||
{
|
||||
_suite_error_list.push_back(s);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
+15
-15
@@ -28,7 +28,7 @@
|
||||
# include "winconfig.h"
|
||||
#else
|
||||
# include "config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "missing.h"
|
||||
#include "cpptest-time.h"
|
||||
@@ -48,16 +48,16 @@ namespace Test
|
||||
namespace
|
||||
{
|
||||
const unsigned int UsecPerSec = 1000000;
|
||||
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
/// Constructs a time object with zeroed time.
|
||||
///
|
||||
Time::Time()
|
||||
: _sec(0),
|
||||
_usec(0)
|
||||
{}
|
||||
|
||||
|
||||
/// Constructs a time object.
|
||||
///
|
||||
/// \param sec Seconds.
|
||||
@@ -67,7 +67,7 @@ namespace Test
|
||||
: _sec(sec),
|
||||
_usec(usec)
|
||||
{}
|
||||
|
||||
|
||||
/// \return Seconds.
|
||||
///
|
||||
unsigned int
|
||||
@@ -75,7 +75,7 @@ namespace Test
|
||||
{
|
||||
return _sec;
|
||||
}
|
||||
|
||||
|
||||
/// \return Micro-seconds.
|
||||
///
|
||||
unsigned int
|
||||
@@ -83,7 +83,7 @@ namespace Test
|
||||
{
|
||||
return _usec;
|
||||
}
|
||||
|
||||
|
||||
/// \return The current time.
|
||||
///
|
||||
Time
|
||||
@@ -93,7 +93,7 @@ namespace Test
|
||||
gettimeofday(&tv, 0);
|
||||
return Time(tv.tv_sec, tv.tv_usec);
|
||||
}
|
||||
|
||||
|
||||
/// \relates Time
|
||||
///
|
||||
/// Computes the time elapsed between two time values.
|
||||
@@ -108,10 +108,10 @@ namespace Test
|
||||
{
|
||||
if (t2._sec > t1._sec || (t2._sec == t1._sec && t2._usec > t1._usec))
|
||||
return Time();
|
||||
|
||||
|
||||
unsigned int sec = t1._sec - t2._sec;
|
||||
unsigned int usec;
|
||||
|
||||
|
||||
if (t2._usec > t1._usec)
|
||||
{
|
||||
--sec;
|
||||
@@ -119,10 +119,10 @@ namespace Test
|
||||
}
|
||||
else
|
||||
usec = t1._usec - t2._usec;
|
||||
|
||||
|
||||
return Time(sec, usec);
|
||||
}
|
||||
|
||||
|
||||
/// \relates Time
|
||||
///
|
||||
/// Adds two time values.
|
||||
@@ -137,7 +137,7 @@ namespace Test
|
||||
{
|
||||
unsigned int sec = t1._sec + t2._sec;
|
||||
unsigned int usec = t1._usec + t2._usec;
|
||||
|
||||
|
||||
if (usec > UsecPerSec)
|
||||
{
|
||||
++sec;
|
||||
@@ -145,7 +145,7 @@ namespace Test
|
||||
}
|
||||
return Time(sec, usec);
|
||||
}
|
||||
|
||||
|
||||
/// \relates Time
|
||||
///
|
||||
/// Outputs a time to an output stream.
|
||||
@@ -171,6 +171,6 @@ namespace Test
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
# include "winconfig.h"
|
||||
#else
|
||||
# include "config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "missing.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace Test
|
||||
{
|
||||
{
|
||||
// Computes the procentage of correct tests.
|
||||
//
|
||||
int
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
namespace Test
|
||||
{
|
||||
extern int correct(int tests, int errors);
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
#endif // #ifndef CPPTEST_UTILS_H
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#if _MSC_VER == 1200 // MS Visual C++ 6.0
|
||||
#pragma warning (disable: 4786)
|
||||
#endif
|
||||
|
||||
|
||||
#if _MSC_VER > 1300 // MS Visual C++ .NET 2002 and above
|
||||
#pragma warning (disable: 4267)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user