From 0fc46fc9590912bf6925c899edd02d7a2cdf5f79 Mon Sep 17 00:00:00 2001 From: dan miller Date: Fri, 19 Oct 2007 04:28:53 +0000 Subject: adding ode source to /libraries --- .../tests/CppTestHarness/HTMLTestReporter.cpp" | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 "libraries/ode-0.9\\/tests/CppTestHarness/HTMLTestReporter.cpp" (limited to 'libraries/ode-0.9\/tests/CppTestHarness/HTMLTestReporter.cpp') diff --git "a/libraries/ode-0.9\\/tests/CppTestHarness/HTMLTestReporter.cpp" "b/libraries/ode-0.9\\/tests/CppTestHarness/HTMLTestReporter.cpp" new file mode 100755 index 0000000..fd4acb1 --- /dev/null +++ "b/libraries/ode-0.9\\/tests/CppTestHarness/HTMLTestReporter.cpp" @@ -0,0 +1,87 @@ +#include "HTMLTestReporter.h" + +#ifdef _MSC_VER +# pragma warning(disable:4996) // shut the secure crt stuff up, ctime is used correctly here. +#endif + +#include +#include +#include + +namespace CppTestHarness +{ + +void HTMLTestReporter::ReportFailure(char const* file, int const line, std::string const failure) +{ + std::stringstream msg; + msg << file << "(" << line << ") : " << failure; + + m_failureMessages.push_back(msg.str()); +} + +void HTMLTestReporter::ReportSingleResult(const std::string& testName, bool failed) +{ + ResultRecord r; + r.testName = testName; + r.failed = failed; + + //get reported failures and clear temp list + r.failureMessages = m_failureMessages; + m_failureMessages.clear(); + + m_results.push_back(r); +} + +void HTMLTestReporter::ReportSummary(int const testCount, int const failureCount) +{ + std::ostream& os = std::cout; + + //TODO: make all strings html safe + os << ""; + os << "\n"; + os << "\n"; + os << " Test Report\n"; + os << "\n"; + os << "\n"; + + std::time_t currtime; + std::time(&currtime); + + os << "

Test Report: " << std::ctime(&currtime) << "

\n"; + os << "

"; + os << testCount << " tests run.
\n"; + os << failureCount << " failed.
\n"; + os << "

"; + + os << ""; + + //for each single test + for (ResultList::iterator i = m_results.begin(); i != m_results.end(); ++i) + { + os << ""; + os << ""; + + if (i->failed) + os << ""; + else + os << ""; + + os << ""; + } + + os << "
" << i->testName << "FAILEDPASSED
"; + if (i->failed) os << "
    "; + + for (MessageList::iterator j = i->failureMessages.begin(); j != i->failureMessages.end(); ++j) + { + os << "
  • "<< *j << "
  • \n"; + } + + if (i->failed) os << "
"; + os << "
"; + os << ""; + os << ""; +} + +} + -- cgit v1.1