diff options
Diffstat (limited to '3rdparty/unittest-cpp/UnitTest++')
54 files changed, 3758 insertions, 0 deletions
diff --git a/3rdparty/unittest-cpp/UnitTest++/AssertException.cpp b/3rdparty/unittest-cpp/UnitTest++/AssertException.cpp new file mode 100644 index 00000000000..9a7d78f23a2 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/AssertException.cpp @@ -0,0 +1,17 @@ +#include "AssertException.h" + +#ifndef UNITTEST_NO_EXCEPTIONS + +namespace UnitTest { + +AssertException::AssertException() +{ +} + +AssertException::~AssertException() throw() +{ +} + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/AssertException.h b/3rdparty/unittest-cpp/UnitTest++/AssertException.h new file mode 100644 index 00000000000..e5d07058001 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/AssertException.h @@ -0,0 +1,23 @@ +#ifndef UNITTEST_ASSERTEXCEPTION_H +#define UNITTEST_ASSERTEXCEPTION_H + +#include "Config.h" +#ifndef UNITTEST_NO_EXCEPTIONS + +#include "HelperMacros.h" +#include <exception> + +namespace UnitTest { + +class UNITTEST_LINKAGE AssertException : public std::exception +{ +public: + AssertException(); + virtual ~AssertException() throw(); +}; + +} + +#endif + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/CheckMacros.h b/3rdparty/unittest-cpp/UnitTest++/CheckMacros.h new file mode 100644 index 00000000000..9d6a759203c --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/CheckMacros.h @@ -0,0 +1,179 @@ +#ifndef UNITTEST_CHECKMACROS_H +#define UNITTEST_CHECKMACROS_H + +#include "HelperMacros.h" +#include "ExceptionMacros.h" +#include "Checks.h" +#include "AssertException.h" +#include "MemoryOutStream.h" +#include "TestDetails.h" +#include "CurrentTest.h" +#include "ReportAssertImpl.h" + +#ifdef CHECK + #error UnitTest++ redefines CHECK +#endif + +#ifdef CHECK_EQUAL + #error UnitTest++ redefines CHECK_EQUAL +#endif + +#ifdef CHECK_CLOSE + #error UnitTest++ redefines CHECK_CLOSE +#endif + +#ifdef CHECK_ARRAY_EQUAL + #error UnitTest++ redefines CHECK_ARRAY_EQUAL +#endif + +#ifdef CHECK_ARRAY_CLOSE + #error UnitTest++ redefines CHECK_ARRAY_CLOSE +#endif + +#ifdef CHECK_ARRAY2D_CLOSE + #error UnitTest++ redefines CHECK_ARRAY2D_CLOSE +#endif + +#define CHECK(value) \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + UT_TRY \ + ({ \ + if (!UnitTest::Check(value)) \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \ + }) \ + UT_CATCH (std::exception, e, \ + { \ + UnitTest::MemoryOutStream message; \ + message << "Unhandled exception (" << e.what() << ") in CHECK(" #value ")"; \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + message.GetText()); \ + }) \ + UT_CATCH_ALL \ + ({ \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + "Unhandled exception in CHECK(" #value ")"); \ + }) \ + UNITTEST_MULTILINE_MACRO_END + +#define CHECK_EQUAL(expected, actual) \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + UT_TRY \ + ({ \ + UnitTest::CheckEqual(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ + }) \ + UT_CATCH (std::exception, e, \ + { \ + UnitTest::MemoryOutStream message; \ + message << "Unhandled exception (" << e.what() << ") in CHECK_EQUAL(" #expected ", " #actual ")"; \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + message.GetText()); \ + }) \ + UT_CATCH_ALL \ + ({ \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + "Unhandled exception in CHECK_EQUAL(" #expected ", " #actual ")"); \ + }) \ + UNITTEST_MULTILINE_MACRO_END + +#define CHECK_CLOSE(expected, actual, tolerance) \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + UT_TRY \ + ({ \ + UnitTest::CheckClose(*UnitTest::CurrentTest::Results(), expected, actual, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ + }) \ + UT_CATCH (std::exception, e, \ + { \ + UnitTest::MemoryOutStream message; \ + message << "Unhandled exception (" << e.what() << ") in CHECK_CLOSE(" #expected ", " #actual ")"; \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + message.GetText()); \ + }) \ + UT_CATCH_ALL \ + ({ \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + "Unhandled exception in CHECK_CLOSE(" #expected ", " #actual ")"); \ + }) \ + UNITTEST_MULTILINE_MACRO_END + +#define CHECK_ARRAY_EQUAL(expected, actual, count) \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + UT_TRY \ + ({ \ + UnitTest::CheckArrayEqual(*UnitTest::CurrentTest::Results(), expected, actual, count, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ + }) \ + UT_CATCH (std::exception, e, \ + { \ + UnitTest::MemoryOutStream message; \ + message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY_EQUAL(" #expected ", " #actual ")"; \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + message.GetText()); \ + }) \ + UT_CATCH_ALL \ + ({ \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + "Unhandled exception in CHECK_ARRAY_EQUAL(" #expected ", " #actual ")"); \ + }) \ + UNITTEST_MULTILINE_MACRO_END + +#define CHECK_ARRAY_CLOSE(expected, actual, count, tolerance) \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + UT_TRY \ + ({ \ + UnitTest::CheckArrayClose(*UnitTest::CurrentTest::Results(), expected, actual, count, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ + }) \ + UT_CATCH (std::exception, e, \ + { \ + UnitTest::MemoryOutStream message; \ + message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY_CLOSE(" #expected ", " #actual ")"; \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + message.GetText()); \ + }) \ + UT_CATCH_ALL \ + ({ \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + "Unhandled exception in CHECK_ARRAY_CLOSE(" #expected ", " #actual ")"); \ + }) \ + UNITTEST_MULTILINE_MACRO_END + +#define CHECK_ARRAY2D_CLOSE(expected, actual, rows, columns, tolerance) \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + UT_TRY \ + ({ \ + UnitTest::CheckArray2DClose(*UnitTest::CurrentTest::Results(), expected, actual, rows, columns, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ + }) \ + UT_CATCH (std::exception, e, \ + { \ + UnitTest::MemoryOutStream message; \ + message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY2D_CLOSE(" #expected ", " #actual ")"; \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + message.GetText()); \ + }) \ + UT_CATCH_ALL \ + ({ \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ + "Unhandled exception in CHECK_ARRAY2D_CLOSE(" #expected ", " #actual ")"); \ + }) \ + UNITTEST_MULTILINE_MACRO_END + + +// CHECK_THROW and CHECK_ASSERT only exist when UNITTEST_NO_EXCEPTIONS isn't defined (see config.h) +#ifndef UNITTEST_NO_EXCEPTIONS +#define CHECK_THROW(expression, ExpectedExceptionType) \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + bool caught_ = false; \ + try { expression; } \ + catch (ExpectedExceptionType const&) { caught_ = true; } \ + catch (...) {} \ + if (!caught_) \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), "Expected exception: \"" #ExpectedExceptionType "\" not thrown"); \ + UNITTEST_MULTILINE_MACRO_END + + +#define CHECK_ASSERT(expression) \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + UnitTest::Detail::ExpectAssert(true); \ + CHECK_THROW(expression, UnitTest::AssertException); \ + UnitTest::Detail::ExpectAssert(false); \ + UNITTEST_MULTILINE_MACRO_END +#endif +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/Checks.cpp b/3rdparty/unittest-cpp/UnitTest++/Checks.cpp new file mode 100644 index 00000000000..3e09231d3f9 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Checks.cpp @@ -0,0 +1,50 @@ +#include "Checks.h" +#include <cstring> + +namespace UnitTest { + +namespace { + +void CheckStringsEqual(TestResults& results, char const* expected, char const* actual, + TestDetails const& details) +{ + using namespace std; + + if ((expected && actual) ? strcmp(expected, actual) : (expected || actual)) + { + UnitTest::MemoryOutStream stream; + stream << "Expected " << (expected ? expected : "<NULLPTR>") << " but was " << (actual ? actual : "<NULLPTR>"); + + results.OnTestFailure(details, stream.GetText()); + } +} + +} + + +void CheckEqual(TestResults& results, char const* expected, char const* actual, + TestDetails const& details) +{ + CheckStringsEqual(results, expected, actual, details); +} + +void CheckEqual(TestResults& results, char* expected, char* actual, + TestDetails const& details) +{ + CheckStringsEqual(results, expected, actual, details); +} + +void CheckEqual(TestResults& results, char* expected, char const* actual, + TestDetails const& details) +{ + CheckStringsEqual(results, expected, actual, details); +} + +void CheckEqual(TestResults& results, char const* expected, char* actual, + TestDetails const& details) +{ + CheckStringsEqual(results, expected, actual, details); +} + + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/Checks.h b/3rdparty/unittest-cpp/UnitTest++/Checks.h new file mode 100644 index 00000000000..b2cc4dbf659 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Checks.h @@ -0,0 +1,158 @@ +#ifndef UNITTEST_CHECKS_H +#define UNITTEST_CHECKS_H + +#include "Config.h" +#include "TestResults.h" +#include "MemoryOutStream.h" + +namespace UnitTest { + + +template< typename Value > +bool Check(Value const value) +{ + return !!value; // doing double negative to avoid silly VS warnings +} + + +template< typename Expected, typename Actual > +void CheckEqual(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details) +{ + if (!(expected == actual)) + { + UnitTest::MemoryOutStream stream; + stream << "Expected " << expected << " but was " << actual; + + results.OnTestFailure(details, stream.GetText()); + } +} + +UNITTEST_LINKAGE void CheckEqual(TestResults& results, char const* expected, char const* actual, TestDetails const& details); + +UNITTEST_LINKAGE void CheckEqual(TestResults& results, char* expected, char* actual, TestDetails const& details); + +UNITTEST_LINKAGE void CheckEqual(TestResults& results, char* expected, char const* actual, TestDetails const& details); + +UNITTEST_LINKAGE void CheckEqual(TestResults& results, char const* expected, char* actual, TestDetails const& details); + +template< typename Expected, typename Actual, typename Tolerance > +bool AreClose(Expected const& expected, Actual const& actual, Tolerance const& tolerance) +{ + return (actual >= (expected - tolerance)) && (actual <= (expected + tolerance)); +} + +template< typename Expected, typename Actual, typename Tolerance > +void CheckClose(TestResults& results, Expected const& expected, Actual const& actual, Tolerance const& tolerance, + TestDetails const& details) +{ + if (!AreClose(expected, actual, tolerance)) + { + UnitTest::MemoryOutStream stream; + stream << "Expected " << expected << " +/- " << tolerance << " but was " << actual; + + results.OnTestFailure(details, stream.GetText()); + } +} + + +template< typename Expected, typename Actual > +void CheckArrayEqual(TestResults& results, Expected const& expected, Actual const& actual, + int const count, TestDetails const& details) +{ + bool equal = true; + for (int i = 0; i < count; ++i) + equal &= (expected[i] == actual[i]); + + if (!equal) + { + UnitTest::MemoryOutStream stream; + + stream << "Expected [ "; + + for (int expectedIndex = 0; expectedIndex < count; ++expectedIndex) + stream << expected[expectedIndex] << " "; + + stream << "] but was [ "; + + for (int actualIndex = 0; actualIndex < count; ++actualIndex) + stream << actual[actualIndex] << " "; + + stream << "]"; + + results.OnTestFailure(details, stream.GetText()); + } +} + +template< typename Expected, typename Actual, typename Tolerance > +bool ArrayAreClose(Expected const& expected, Actual const& actual, int const count, Tolerance const& tolerance) +{ + bool equal = true; + for (int i = 0; i < count; ++i) + equal &= AreClose(expected[i], actual[i], tolerance); + return equal; +} + +template< typename Expected, typename Actual, typename Tolerance > +void CheckArrayClose(TestResults& results, Expected const& expected, Actual const& actual, + int const count, Tolerance const& tolerance, TestDetails const& details) +{ + bool equal = ArrayAreClose(expected, actual, count, tolerance); + + if (!equal) + { + UnitTest::MemoryOutStream stream; + + stream << "Expected [ "; + for (int expectedIndex = 0; expectedIndex < count; ++expectedIndex) + stream << expected[expectedIndex] << " "; + stream << "] +/- " << tolerance << " but was [ "; + + for (int actualIndex = 0; actualIndex < count; ++actualIndex) + stream << actual[actualIndex] << " "; + stream << "]"; + + results.OnTestFailure(details, stream.GetText()); + } +} + +template< typename Expected, typename Actual, typename Tolerance > +void CheckArray2DClose(TestResults& results, Expected const& expected, Actual const& actual, + int const rows, int const columns, Tolerance const& tolerance, TestDetails const& details) +{ + bool equal = true; + for (int i = 0; i < rows; ++i) + equal &= ArrayAreClose(expected[i], actual[i], columns, tolerance); + + if (!equal) + { + UnitTest::MemoryOutStream stream; + + stream << "Expected [ "; + + for (int expectedRow = 0; expectedRow < rows; ++expectedRow) + { + stream << "[ "; + for (int expectedColumn = 0; expectedColumn < columns; ++expectedColumn) + stream << expected[expectedRow][expectedColumn] << " "; + stream << "] "; + } + + stream << "] +/- " << tolerance << " but was [ "; + + for (int actualRow = 0; actualRow < rows; ++actualRow) + { + stream << "[ "; + for (int actualColumn = 0; actualColumn < columns; ++actualColumn) + stream << actual[actualRow][actualColumn] << " "; + stream << "] "; + } + + stream << "]"; + + results.OnTestFailure(details, stream.GetText()); + } +} + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/CompositeTestReporter.cpp b/3rdparty/unittest-cpp/UnitTest++/CompositeTestReporter.cpp new file mode 100644 index 00000000000..2dd2ffc506b --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/CompositeTestReporter.cpp @@ -0,0 +1,67 @@ +#include "CompositeTestReporter.h" +#include <cstddef> + +namespace UnitTest { + +CompositeTestReporter::CompositeTestReporter() + : m_reporterCount(0) +{ +} + +int CompositeTestReporter::GetReporterCount() const +{ + return m_reporterCount; +} + +bool CompositeTestReporter::AddReporter(TestReporter* reporter) +{ + if (m_reporterCount == kMaxReporters) + return false; + + m_reporters[m_reporterCount++] = reporter; + return true; +} + +bool CompositeTestReporter::RemoveReporter(TestReporter* reporter) +{ + for (int index = 0; index < m_reporterCount; ++index) + { + if (m_reporters[index] == reporter) + { + m_reporters[index] = m_reporters[m_reporterCount - 1]; + --m_reporterCount; + return true; + } + } + + return false; +} + +void CompositeTestReporter::ReportFailure(TestDetails const& details, char const* failure) +{ + for (int index = 0; index < m_reporterCount; ++index) + m_reporters[index]->ReportFailure(details, failure); +} + +void CompositeTestReporter::ReportTestStart(TestDetails const& test) +{ + for (int index = 0; index < m_reporterCount; ++index) + m_reporters[index]->ReportTestStart(test); +} + +void CompositeTestReporter::ReportTestFinish(TestDetails const& test, float secondsElapsed) +{ + for (int index = 0; index < m_reporterCount; ++index) + m_reporters[index]->ReportTestFinish(test, secondsElapsed); +} + +void CompositeTestReporter::ReportSummary(int totalTestCount, + int failedTestCount, + int failureCount, + float secondsElapsed) +{ + for (int index = 0; index < m_reporterCount; ++index) + m_reporters[index]->ReportSummary(totalTestCount, failedTestCount, failureCount, secondsElapsed); +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/CompositeTestReporter.h b/3rdparty/unittest-cpp/UnitTest++/CompositeTestReporter.h new file mode 100644 index 00000000000..a9a0d296964 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/CompositeTestReporter.h @@ -0,0 +1,34 @@ +#ifndef UNITTEST_COMPOSITETESTREPORTER_H +#define UNITTEST_COMPOSITETESTREPORTER_H + +#include "TestReporter.h" + +namespace UnitTest { + +class UNITTEST_LINKAGE CompositeTestReporter : public TestReporter +{ +public: + CompositeTestReporter(); + + int GetReporterCount() const; + bool AddReporter(TestReporter* reporter); + bool RemoveReporter(TestReporter* reporter); + + virtual void ReportTestStart(TestDetails const& test); + virtual void ReportFailure(TestDetails const& test, char const* failure); + virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed); + virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); + +private: + enum { kMaxReporters = 16 }; + TestReporter* m_reporters[kMaxReporters]; + int m_reporterCount; + + // revoked + CompositeTestReporter(const CompositeTestReporter&); + CompositeTestReporter& operator =(const CompositeTestReporter&); +}; + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/Config.h b/3rdparty/unittest-cpp/UnitTest++/Config.h new file mode 100644 index 00000000000..4f695f7c9f7 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Config.h @@ -0,0 +1,73 @@ +#ifndef UNITTEST_CONFIG_H +#define UNITTEST_CONFIG_H + +// Standard defines documented here: http://predef.sourceforge.net + +#if defined(_MSC_VER) + #pragma warning(disable:4702) // unreachable code + #pragma warning(disable:4722) // destructor never returns, potential memory leak + +#if (_MSC_VER == 1200) // VC6 + #define UNITTEST_COMPILER_IS_MSVC6 + #pragma warning(disable:4786) + #pragma warning(disable:4290) + #endif + + #ifdef _USRDLL + #define UNITTEST_WIN32_DLL + #endif + #define UNITTEST_WIN32 +#endif + +#if defined(unix) || defined(__unix__) || defined(__unix) || defined(linux) || \ + defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) + #define UNITTEST_POSIX +#endif + +#if defined(__MINGW32__) + #define UNITTEST_MINGW +#endif + + +// By default, MemoryOutStream is implemented in terms of std::ostringstream. +// This is useful if you are using the CHECK macros on objects that have something like this defined: +// std::ostringstream& operator<<(std::ostringstream& s, const YourObject& value) +// +// On the other hand, it can be more expensive. +// Un-comment this line to use the custom MemoryOutStream (no deps on std::ostringstream). + +// #define UNITTEST_USE_CUSTOM_STREAMS + +// Developer note: This dual-macro setup is to preserve compatibility with UnitTest++ 1.4 users +// who may have used or defined UNITTEST_USE_CUSTOM_STREAMS outside of this configuration file, as +// well as Google Code HEAD users that may have used or defined +// UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM outside of this configuration file. +#ifndef UNITTEST_USE_CUSTOM_STREAMS + #define UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM +#endif + +// DeferredTestReporter uses the STL to collect test results for subsequent export by reporters like +// XmlTestReporter. If you don't want to use this functionality, uncomment this line and no STL +// headers or code will be compiled into UnitTest++ + +//#define UNITTEST_NO_DEFERRED_REPORTER + + +// By default, asserts that you report via UnitTest::ReportAssert() abort the current test and +// continue to the next one by throwing an exception, which unwinds the stack naturally, destroying +// all auto variables on its way back down. If you don't want to (or can't) use exceptions for your +// platform/compiler, uncomment this line. All exception code will be removed from UnitTest++, +// assert recovery will be done via setjmp/longjmp, and NO correct stack unwinding will happen! + +//#define UNITTEST_NO_EXCEPTIONS + + +// std namespace qualification: used for functions like strcpy that +// may live in std:: namespace (cstring header). +#if defined( UNITTEST_COMPILER_IS_MSVC6 ) + #define UNIITEST_NS_QUAL_STD(x) x +#else + #define UNIITEST_NS_QUAL_STD(x) ::std::x +#endif + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/CurrentTest.cpp b/3rdparty/unittest-cpp/UnitTest++/CurrentTest.cpp new file mode 100644 index 00000000000..dd9d2450e3f --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/CurrentTest.cpp @@ -0,0 +1,18 @@ +#include "CurrentTest.h" +#include <cstddef> + +namespace UnitTest { + +UNITTEST_LINKAGE TestResults*& CurrentTest::Results() +{ + static TestResults* testResults = NULL; + return testResults; +} + +UNITTEST_LINKAGE const TestDetails*& CurrentTest::Details() +{ + static const TestDetails* testDetails = NULL; + return testDetails; +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/CurrentTest.h b/3rdparty/unittest-cpp/UnitTest++/CurrentTest.h new file mode 100644 index 00000000000..642b9dce010 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/CurrentTest.h @@ -0,0 +1,19 @@ +#ifndef UNITTEST_CURRENTTESTRESULTS_H +#define UNITTEST_CURRENTTESTRESULTS_H + +#include "HelperMacros.h" + +namespace UnitTest { + +class TestResults; +class TestDetails; + +namespace CurrentTest +{ + UNITTEST_LINKAGE TestResults*& Results(); + UNITTEST_LINKAGE const TestDetails*& Details(); +} + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/DeferredTestReporter.cpp b/3rdparty/unittest-cpp/UnitTest++/DeferredTestReporter.cpp new file mode 100644 index 00000000000..60e0ded8379 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/DeferredTestReporter.cpp @@ -0,0 +1,33 @@ +#include "Config.h" +#ifndef UNITTEST_NO_DEFERRED_REPORTER + +#include "DeferredTestReporter.h" +#include "TestDetails.h" + +using namespace UnitTest; + +void DeferredTestReporter::ReportTestStart(TestDetails const& details) +{ + m_results.push_back(DeferredTestResult(details.suiteName, details.testName)); +} + +void DeferredTestReporter::ReportFailure(TestDetails const& details, char const* failure) +{ + DeferredTestResult& r = m_results.back(); + r.failed = true; + r.failures.push_back(DeferredTestFailure(details.lineNumber, failure)); + r.failureFile = details.filename; +} + +void DeferredTestReporter::ReportTestFinish(TestDetails const&, float secondsElapsed) +{ + DeferredTestResult& r = m_results.back(); + r.timeElapsed = secondsElapsed; +} + +DeferredTestReporter::DeferredTestResultList& DeferredTestReporter::GetResults() +{ + return m_results; +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/DeferredTestReporter.h b/3rdparty/unittest-cpp/UnitTest++/DeferredTestReporter.h new file mode 100644 index 00000000000..757e53f808e --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/DeferredTestReporter.h @@ -0,0 +1,35 @@ +#ifndef UNITTEST_DEFERREDTESTREPORTER_H +#define UNITTEST_DEFERREDTESTREPORTER_H + +#include "Config.h" + +#ifndef UNITTEST_NO_DEFERRED_REPORTER + +#include "TestReporter.h" +#include "DeferredTestResult.h" + +#include <vector> + +UNITTEST_STDVECTOR_LINKAGE(UnitTest::DeferredTestResult); + +namespace UnitTest +{ + +class UNITTEST_LINKAGE DeferredTestReporter : public TestReporter +{ +public: + virtual void ReportTestStart(TestDetails const& details); + virtual void ReportFailure(TestDetails const& details, char const* failure); + virtual void ReportTestFinish(TestDetails const& details, float secondsElapsed); + + typedef std::vector< DeferredTestResult > DeferredTestResultList; + DeferredTestResultList& GetResults(); + +private: + DeferredTestResultList m_results; +}; + +} + +#endif +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/DeferredTestResult.cpp b/3rdparty/unittest-cpp/UnitTest++/DeferredTestResult.cpp new file mode 100644 index 00000000000..cdad9eb82d3 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/DeferredTestResult.cpp @@ -0,0 +1,46 @@ +#include "Config.h" +#ifndef UNITTEST_NO_DEFERRED_REPORTER + +#include "DeferredTestResult.h" +#include <cstring> + +namespace UnitTest +{ + +DeferredTestFailure::DeferredTestFailure() + : lineNumber(-1) +{ + failureStr[0] = '\0'; +} + +DeferredTestFailure::DeferredTestFailure(int lineNumber_, const char* failureStr_) + : lineNumber(lineNumber_) +{ + UNIITEST_NS_QUAL_STD(strcpy)(failureStr, failureStr_); +} + +DeferredTestResult::DeferredTestResult() + : suiteName("") + , testName("") + , failureFile("") + , timeElapsed(0.0f) + , failed(false) +{ +} + +DeferredTestResult::DeferredTestResult(char const* suite, char const* test) + : suiteName(suite) + , testName(test) + , failureFile("") + , timeElapsed(0.0f) + , failed(false) +{ +} + +DeferredTestResult::~DeferredTestResult() +{ +} + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/DeferredTestResult.h b/3rdparty/unittest-cpp/UnitTest++/DeferredTestResult.h new file mode 100644 index 00000000000..092956657c5 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/DeferredTestResult.h @@ -0,0 +1,52 @@ +#ifndef UNITTEST_DEFERREDTESTRESULT_H +#define UNITTEST_DEFERREDTESTRESULT_H + +#include "Config.h" +#ifndef UNITTEST_NO_DEFERRED_REPORTER + +#include "HelperMacros.h" +#include <string> +#include <vector> + +namespace UnitTest +{ + +class UNITTEST_LINKAGE DeferredTestFailure +{ +public: + DeferredTestFailure(); + DeferredTestFailure(int lineNumber_, const char* failureStr_); + + int lineNumber; + char failureStr[1024]; +}; + +} + +UNITTEST_STDVECTOR_LINKAGE(UnitTest::DeferredTestFailure); + +namespace UnitTest +{ + +class UNITTEST_LINKAGE DeferredTestResult +{ +public: + DeferredTestResult(); + DeferredTestResult(char const* suite, char const* test); + ~DeferredTestResult(); + + std::string suiteName; + std::string testName; + std::string failureFile; + + typedef std::vector< DeferredTestFailure > FailureVec; + FailureVec failures; + + float timeElapsed; + bool failed; +}; + +} + +#endif +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/ExceptionMacros.h b/3rdparty/unittest-cpp/UnitTest++/ExceptionMacros.h new file mode 100644 index 00000000000..e549c2ce72b --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/ExceptionMacros.h @@ -0,0 +1,18 @@ +#ifndef UNITTEST_EXCEPTIONMACROS_H +#define UNITTEST_EXCEPTIONMACROS_H + +#include "Config.h" + +#ifndef UNITTEST_NO_EXCEPTIONS + #define UT_TRY(x) try x + #define UT_THROW(x) throw x + #define UT_CATCH(ExceptionType, ExceptionName, CatchBody) catch(ExceptionType& ExceptionName) CatchBody + #define UT_CATCH_ALL(CatchBody) catch(...) CatchBody +#else + #define UT_TRY(x) x + #define UT_THROW(x) + #define UT_CATCH(ExceptionType, ExceptionName, CatchBody) + #define UT_CATCH_ALL(CatchBody) +#endif + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/ExecuteTest.h b/3rdparty/unittest-cpp/UnitTest++/ExecuteTest.h new file mode 100644 index 00000000000..d683dc0c172 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/ExecuteTest.h @@ -0,0 +1,59 @@ +#ifndef UNITTEST_EXECUTE_TEST_H +#define UNITTEST_EXECUTE_TEST_H + +#include "Config.h" +#include "ExceptionMacros.h" +#include "TestDetails.h" +#include "TestResults.h" +#include "MemoryOutStream.h" +#include "AssertException.h" +#include "CurrentTest.h" + +#ifdef UNITTEST_NO_EXCEPTIONS + #include "ReportAssertImpl.h" +#endif + +#ifdef UNITTEST_POSIX + #include "Posix/SignalTranslator.h" +#endif + +namespace UnitTest { + +template< typename T > +void ExecuteTest(T& testObject, TestDetails const& details, bool isMockTest) +{ + if (isMockTest == false) + CurrentTest::Details() = &details; + +#ifdef UNITTEST_NO_EXCEPTIONS + if (UNITTEST_SET_ASSERT_JUMP_TARGET() == 0) + { +#endif +#ifndef UNITTEST_POSIX + UT_TRY({ testObject.RunImpl(); }) +#else + UT_TRY + ({ + UNITTEST_THROW_SIGNALS_POSIX_ONLY + testObject.RunImpl(); + }) +#endif + UT_CATCH(AssertException, e, { (void)e; }) + UT_CATCH(std::exception, e, + { + MemoryOutStream stream; + stream << "Unhandled exception: " << e.what(); + CurrentTest::Results()->OnTestFailure(details, stream.GetText()); + }) + UT_CATCH_ALL + ({ + CurrentTest::Results()->OnTestFailure(details, "Unhandled exception: test crashed"); + }) +#ifdef UNITTEST_NO_EXCEPTIONS + } +#endif +} + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/HelperMacros.h b/3rdparty/unittest-cpp/UnitTest++/HelperMacros.h new file mode 100644 index 00000000000..699d99d9bd3 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/HelperMacros.h @@ -0,0 +1,52 @@ +#ifndef UNITTEST_HELPERMACROS_H +#define UNITTEST_HELPERMACROS_H + +#include "Config.h" + +#define UNITTEST_MULTILINE_MACRO_BEGIN do { + +#if defined(UNITTEST_WIN32) && !defined(UNITTEST_COMPILER_IS_MSVC6) + #define UNITTEST_MULTILINE_MACRO_END \ + } __pragma(warning(push)) __pragma(warning(disable:4127)) while (0) __pragma(warning(pop)) +#else + #define UNITTEST_MULTILINE_MACRO_END } while(0) +#endif + + +#ifdef UNITTEST_WIN32_DLL + #define UNITTEST_IMPORT __declspec(dllimport) + #define UNITTEST_EXPORT __declspec(dllexport) + + #ifdef UNITTEST_DLL_EXPORT + #define UNITTEST_LINKAGE UNITTEST_EXPORT + #define UNITTEST_IMPEXP_TEMPLATE + #else + #define UNITTEST_LINKAGE UNITTEST_IMPORT + #define UNITTEST_IMPEXP_TEMPLATE extern + #endif + + #define UNITTEST_STDVECTOR_LINKAGE(T) \ + __pragma(warning(push)) \ + __pragma(warning(disable:4231)) \ + UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::allocator< T >; \ + UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::vector< T >; \ + __pragma(warning(pop)) +#else + #define UNITTEST_IMPORT + #define UNITTEST_EXPORT + #define UNITTEST_LINKAGE + #define UNITTEST_IMPEXP_TEMPLATE + #define UNITTEST_STDVECTOR_LINKAGE(T) +#endif + +#ifdef UNITTEST_WIN32 + #define UNITTEST_JMPBUF jmp_buf + #define UNITTEST_SETJMP setjmp + #define UNITTEST_LONGJMP longjmp +#elif defined UNITTEST_POSIX + #define UNITTEST_JMPBUF std::jmp_buf + #define UNITTEST_SETJMP setjmp + #define UNITTEST_LONGJMP std::longjmp +#endif + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/Makefile.am b/3rdparty/unittest-cpp/UnitTest++/Makefile.am new file mode 100644 index 00000000000..399a0226722 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Makefile.am @@ -0,0 +1,9 @@ +lib_LTLIBRARIES = libUnitTest++.la +pkgincludedir = $(includedir)/UnitTest++ +nobase_pkginclude_HEADERS = UnitTest++.h UnitTestPP.h Config.h HelperMacros.h Test.h TestDetails.h TestList.h TestSuite.h TestResults.h TestMacros.h CheckMacros.h TestRunner.h TimeConstraint.h ExecuteTest.h AssertException.h MemoryOutStream.h CurrentTest.h Posix/SignalTranslator.h Checks.h TimeHelpers.h Posix/TimeHelpers.h ExceptionMacros.h ReportAssert.h ReportAssertImpl.h TestReporter.h TestReporterStdout.h CompositeTestReporter.h DeferredTestReporter.h DeferredTestResult.h +libUnitTest___la_SOURCES = AssertException.cpp Test.cpp Checks.cpp TestRunner.cpp TestResults.cpp TestReporter.cpp TestReporterStdout.cpp ReportAssert.cpp TestList.cpp TimeConstraint.cpp TestDetails.cpp MemoryOutStream.cpp DeferredTestReporter.cpp DeferredTestResult.cpp XmlTestReporter.cpp CurrentTest.cpp Posix/SignalTranslator.cpp Posix/TimeHelpers.cpp CompositeTestReporter.cpp +libUnitTest___la_LDFLAGS = -version-number @LIBUNITTEST_SO_VERSION@ +check_PROGRAMS = TestUnitTest++ +TestUnitTest___SOURCES = $(top_srcdir)/tests/Main.cpp $(top_srcdir)/tests/TestAssertHandler.cpp $(top_srcdir)/tests/TestCheckMacros.cpp $(top_srcdir)/tests/TestChecks.cpp $(top_srcdir)/tests/TestCompositeTestReporter.cpp $(top_srcdir)/tests/TestCurrentTest.cpp $(top_srcdir)/tests/TestDeferredTestReporter.cpp $(top_srcdir)/tests/TestExceptions.cpp $(top_srcdir)/tests/TestMemoryOutStream.cpp $(top_srcdir)/tests/TestTest.cpp $(top_srcdir)/tests/TestTestList.cpp $(top_srcdir)/tests/TestTestMacros.cpp $(top_srcdir)/tests/TestTestResults.cpp $(top_srcdir)/tests/TestTestRunner.cpp $(top_srcdir)/tests/TestTestSuite.cpp $(top_srcdir)/tests/TestTimeConstraint.cpp $(top_srcdir)/tests/TestTimeConstraintMacro.cpp $(top_srcdir)/tests/TestUnitTestPP.cpp $(top_srcdir)/tests/TestXmlTestReporter.cpp +TestUnitTest___LDADD = libUnitTest++.la +TESTS = TestUnitTest++ diff --git a/3rdparty/unittest-cpp/UnitTest++/MemoryOutStream.cpp b/3rdparty/unittest-cpp/UnitTest++/MemoryOutStream.cpp new file mode 100644 index 00000000000..319dfda9c74 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/MemoryOutStream.cpp @@ -0,0 +1,218 @@ +#include "MemoryOutStream.h" + +#ifdef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM + +namespace UnitTest { + +char const* MemoryOutStream::GetText() const +{ + m_text = this->str(); + return m_text.c_str(); +} + +void MemoryOutStream::Clear() +{ + this->str(std::string()); + m_text = this->str(); +} + +#ifdef UNITTEST_COMPILER_IS_MSVC6 + +#define snprintf _snprintf + +template<typename ValueType> +std::ostream& FormatToStream(std::ostream& stream, char const* format, ValueType const& value) +{ + using namespace std; + + const size_t BUFFER_SIZE=32; + char txt[BUFFER_SIZE]; + snprintf(txt, BUFFER_SIZE, format, value); + return stream << txt; +} + +std::ostream& operator<<(std::ostream& stream, __int64 const n) +{ + return FormatToStream(stream, "%I64d", n); +} + +std::ostream& operator<<(std::ostream& stream, unsigned __int64 const n) +{ + return FormatToStream(stream, "%I64u", n); +} + +#endif + +} + +#else + +#include <cstring> +#include <cstdio> + +#if _MSC_VER +#define snprintf _snprintf +#endif + +namespace UnitTest { + +namespace { + +template<typename ValueType> +void FormatToStream(MemoryOutStream& stream, char const* format, ValueType const& value) +{ + using namespace std; + + const size_t BUFFER_SIZE=32; + char txt[BUFFER_SIZE]; + snprintf(txt, BUFFER_SIZE, format, value); + stream << txt; +} + +int RoundUpToMultipleOfPow2Number (int n, int pow2Number) +{ + return (n + (pow2Number - 1)) & ~(pow2Number - 1); +} + +} + + +MemoryOutStream::MemoryOutStream(int const size) + : m_capacity (0) + , m_buffer (0) + +{ + GrowBuffer(size); +} + +MemoryOutStream::~MemoryOutStream() +{ + delete [] m_buffer; +} + +void MemoryOutStream::Clear() +{ + m_buffer[0] = '\0'; +} + +char const* MemoryOutStream::GetText() const +{ + return m_buffer; +} + +MemoryOutStream& MemoryOutStream::operator <<(char const* txt) +{ + using namespace std; + + int const bytesLeft = m_capacity - (int)strlen(m_buffer); + int const bytesRequired = (int)strlen(txt) + 1; + + if (bytesRequired > bytesLeft) + { + int const requiredCapacity = bytesRequired + m_capacity - bytesLeft; + GrowBuffer(requiredCapacity); + } + + strcat(m_buffer, txt); + return *this; +} + +MemoryOutStream& MemoryOutStream::operator <<(int const n) +{ + FormatToStream(*this, "%i", n); + return *this; +} + +MemoryOutStream& MemoryOutStream::operator <<(long const n) +{ + FormatToStream(*this, "%li", n); + return *this; +} + +MemoryOutStream& MemoryOutStream::operator <<(unsigned long const n) +{ + FormatToStream(*this, "%lu", n); + return *this; +} + +#ifdef UNITTEST_COMPILER_IS_MSVC6 +MemoryOutStream& MemoryOutStream::operator <<(__int64 const n) +#else +MemoryOutStream& MemoryOutStream::operator <<(long long const n) +#endif +{ +#ifdef UNITTEST_WIN32 + FormatToStream(*this, "%I64d", n); +#else + FormatToStream(*this, "%lld", n); +#endif + + return *this; +} + +#ifdef UNITTEST_COMPILER_IS_MSVC6 +MemoryOutStream& MemoryOutStream::operator <<(unsigned __int64 const n) +#else +MemoryOutStream& MemoryOutStream::operator <<(unsigned long long const n) +#endif +{ +#ifdef UNITTEST_WIN32 + FormatToStream(*this, "%I64u", n); +#else + FormatToStream(*this, "%llu", n); +#endif + + return *this; +} + +MemoryOutStream& MemoryOutStream::operator <<(float const f) +{ + FormatToStream(*this, "%0.6f", f); + return *this; +} + +MemoryOutStream& MemoryOutStream::operator <<(void const* p) +{ + FormatToStream(*this, "%p", p); + return *this; +} + +MemoryOutStream& MemoryOutStream::operator <<(unsigned int const s) +{ + FormatToStream(*this, "%u", s); + return *this; +} + +MemoryOutStream& MemoryOutStream::operator <<(double const d) +{ + FormatToStream(*this, "%0.6f", d); + return *this; +} + +int MemoryOutStream::GetCapacity() const +{ + return m_capacity; +} + + +void MemoryOutStream::GrowBuffer(int const desiredCapacity) +{ + int const newCapacity = RoundUpToMultipleOfPow2Number(desiredCapacity, GROW_CHUNK_SIZE); + + using namespace std; + + char* buffer = new char[newCapacity]; + if (m_buffer) + strcpy(buffer, m_buffer); + else + strcpy(buffer, ""); + + delete [] m_buffer; + m_buffer = buffer; + m_capacity = newCapacity; +} + +} + + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/MemoryOutStream.h b/3rdparty/unittest-cpp/UnitTest++/MemoryOutStream.h new file mode 100644 index 00000000000..b9cea19a39d --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/MemoryOutStream.h @@ -0,0 +1,87 @@ +#ifndef UNITTEST_MEMORYOUTSTREAM_H +#define UNITTEST_MEMORYOUTSTREAM_H + +#include "Config.h" +#include "HelperMacros.h" + +#ifdef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM + +#include <sstream> + +namespace UnitTest +{ + +class UNITTEST_LINKAGE MemoryOutStream : public std::ostringstream +{ +public: + MemoryOutStream() {} + ~MemoryOutStream() {} + void Clear(); + char const* GetText() const; + +private: + MemoryOutStream(MemoryOutStream const&); + void operator =(MemoryOutStream const&); + + mutable std::string m_text; +}; + +#ifdef UNITTEST_COMPILER_IS_MSVC6 +std::ostream& operator<<(std::ostream& stream, __int64 const n); +std::ostream& operator<<(std::ostream& stream, unsigned __int64 const n); +#endif + +} + +#else + +#include <cstddef> + +#ifdef UNITTEST_COMPILER_IS_MSVC6 +namespace std {} +#endif + +namespace UnitTest +{ + +class UNITTEST_LINKAGE MemoryOutStream +{ +public: + explicit MemoryOutStream(int const size = 256); + ~MemoryOutStream(); + + void Clear(); + char const* GetText() const; + + MemoryOutStream& operator <<(char const* txt); + MemoryOutStream& operator <<(int n); + MemoryOutStream& operator <<(long n); + MemoryOutStream& operator <<(unsigned long n); +#ifdef UNITTEST_COMPILER_IS_MSVC6 + MemoryOutStream& operator <<(__int64 n); + MemoryOutStream& operator <<(unsigned __int64 n); +#else + MemoryOutStream& operator <<(long long n); + MemoryOutStream& operator <<(unsigned long long n); +#endif + MemoryOutStream& operator <<(float f); + MemoryOutStream& operator <<(double d); + MemoryOutStream& operator <<(void const* p); + MemoryOutStream& operator <<(unsigned int s); + + enum { GROW_CHUNK_SIZE = 32 }; + int GetCapacity() const; + +private: + void operator= (MemoryOutStream const&); + void GrowBuffer(int capacity); + + int m_capacity; + char* m_buffer; +}; + +} + +#endif + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/Posix/SignalTranslator.cpp b/3rdparty/unittest-cpp/UnitTest++/Posix/SignalTranslator.cpp new file mode 100644 index 00000000000..3689c8c34d0 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Posix/SignalTranslator.cpp @@ -0,0 +1,46 @@ +#include "SignalTranslator.h" + +namespace UnitTest { + +sigjmp_buf* SignalTranslator::s_jumpTarget = 0; + +namespace { + +void SignalHandler(int sig) +{ + siglongjmp(*SignalTranslator::s_jumpTarget, sig ); +} + +} + + +SignalTranslator::SignalTranslator() +{ + m_oldJumpTarget = s_jumpTarget; + s_jumpTarget = &m_currentJumpTarget; + + struct sigaction action; + action.sa_flags = 0; + action.sa_handler = SignalHandler; + sigemptyset( &action.sa_mask ); + + sigaction( SIGSEGV, &action, &m_old_SIGSEGV_action ); + sigaction( SIGFPE , &action, &m_old_SIGFPE_action ); + sigaction( SIGTRAP, &action, &m_old_SIGTRAP_action ); + sigaction( SIGBUS , &action, &m_old_SIGBUS_action ); + sigaction( SIGILL , &action, &m_old_SIGBUS_action ); +} + +SignalTranslator::~SignalTranslator() +{ + sigaction( SIGILL , &m_old_SIGBUS_action , 0 ); + sigaction( SIGBUS , &m_old_SIGBUS_action , 0 ); + sigaction( SIGTRAP, &m_old_SIGTRAP_action, 0 ); + sigaction( SIGFPE , &m_old_SIGFPE_action , 0 ); + sigaction( SIGSEGV, &m_old_SIGSEGV_action, 0 ); + + s_jumpTarget = m_oldJumpTarget; +} + + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/Posix/SignalTranslator.h b/3rdparty/unittest-cpp/UnitTest++/Posix/SignalTranslator.h new file mode 100644 index 00000000000..5b98d977b93 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Posix/SignalTranslator.h @@ -0,0 +1,42 @@ +#ifndef UNITTEST_SIGNALTRANSLATOR_H +#define UNITTEST_SIGNALTRANSLATOR_H + +#include <setjmp.h> +#include <signal.h> + +namespace UnitTest { + +class SignalTranslator +{ +public: + SignalTranslator(); + ~SignalTranslator(); + + static sigjmp_buf* s_jumpTarget; + +private: + sigjmp_buf m_currentJumpTarget; + sigjmp_buf* m_oldJumpTarget; + + struct sigaction m_old_SIGFPE_action; + struct sigaction m_old_SIGTRAP_action; + struct sigaction m_old_SIGSEGV_action; + struct sigaction m_old_SIGBUS_action; + //struct sigaction m_old_SIGABRT_action; + //struct sigaction m_old_SIGALRM_action; +}; + +#if !defined (__GNUC__) + #define UNITTEST_EXTENSION +#else + #define UNITTEST_EXTENSION __extension__ +#endif + +#define UNITTEST_THROW_SIGNALS_POSIX_ONLY \ + UnitTest::SignalTranslator sig; \ + if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \ + throw ("Unhandled system exception"); + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/Posix/TimeHelpers.cpp b/3rdparty/unittest-cpp/UnitTest++/Posix/TimeHelpers.cpp new file mode 100644 index 00000000000..65c63937a0e --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Posix/TimeHelpers.cpp @@ -0,0 +1,33 @@ +#include "TimeHelpers.h" +#include <unistd.h> + +namespace UnitTest { + +Timer::Timer() +{ + m_startTime.tv_sec = 0; + m_startTime.tv_usec = 0; +} + +void Timer::Start() +{ + gettimeofday(&m_startTime, 0); +} + +double Timer::GetTimeInMs() const +{ + struct timeval currentTime; + gettimeofday(¤tTime, 0); + + double const dsecs = currentTime.tv_sec - m_startTime.tv_sec; + double const dus = currentTime.tv_usec - m_startTime.tv_usec; + + return (dsecs * 1000.0) + (dus / 1000.0); +} + +void TimeHelpers::SleepMs(int ms) +{ + usleep(ms * 1000); +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/Posix/TimeHelpers.h b/3rdparty/unittest-cpp/UnitTest++/Posix/TimeHelpers.h new file mode 100644 index 00000000000..0de4b1a9c7e --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Posix/TimeHelpers.h @@ -0,0 +1,28 @@ +#ifndef UNITTEST_TIMEHELPERS_H +#define UNITTEST_TIMEHELPERS_H + +#include <sys/time.h> + +namespace UnitTest { + +class Timer +{ +public: + Timer(); + void Start(); + double GetTimeInMs() const; + +private: + struct timeval m_startTime; +}; + + +namespace TimeHelpers +{ + void SleepMs(int ms); +} + + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/ReportAssert.cpp b/3rdparty/unittest-cpp/UnitTest++/ReportAssert.cpp new file mode 100644 index 00000000000..7a9a63a6561 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/ReportAssert.cpp @@ -0,0 +1,70 @@ +#include "ReportAssert.h" +#include "ReportAssertImpl.h" +#include "AssertException.h" +#include "CurrentTest.h" +#include "TestResults.h" +#include "TestDetails.h" + +#ifdef UNITTEST_NO_EXCEPTIONS + #include "ReportAssertImpl.h" +#endif + +namespace UnitTest { + +namespace +{ + bool& AssertExpectedFlag() + { + static bool s_assertExpected = false; + return s_assertExpected; + } +} + +UNITTEST_LINKAGE void ReportAssert(char const* description, char const* filename, int lineNumber) +{ + Detail::ReportAssertEx(CurrentTest::Results(), CurrentTest::Details(), + description, filename, lineNumber); +} + +namespace Detail { + +#ifdef UNITTEST_NO_EXCEPTIONS +UNITTEST_JMPBUF* GetAssertJmpBuf() +{ + static UNITTEST_JMPBUF s_jmpBuf; + return &s_jmpBuf; +} +#endif + +UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults, + const TestDetails* testDetails, + char const* description, + char const* filename, + int lineNumber) +{ + if (AssertExpectedFlag() == false) + { + TestDetails assertDetails(testDetails->testName, testDetails->suiteName, filename, lineNumber); + testResults->OnTestFailure(assertDetails, description); + } + + ExpectAssert(false); + +#ifndef UNITTEST_NO_EXCEPTIONS + throw AssertException(); +#else + UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET(); +#endif +} + +UNITTEST_LINKAGE void ExpectAssert(bool expected) +{ + AssertExpectedFlag() = expected; +} + +UNITTEST_LINKAGE bool AssertExpected() +{ + return AssertExpectedFlag(); +} + +}} diff --git a/3rdparty/unittest-cpp/UnitTest++/ReportAssert.h b/3rdparty/unittest-cpp/UnitTest++/ReportAssert.h new file mode 100644 index 00000000000..0b5d6dde6c1 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/ReportAssert.h @@ -0,0 +1,12 @@ +#ifndef UNITTEST_ASSERT_H +#define UNITTEST_ASSERT_H + +#include "HelperMacros.h" + +namespace UnitTest { + +UNITTEST_LINKAGE void ReportAssert(char const* description, char const* filename, int lineNumber); + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/ReportAssertImpl.h b/3rdparty/unittest-cpp/UnitTest++/ReportAssertImpl.h new file mode 100644 index 00000000000..88efc03e423 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/ReportAssertImpl.h @@ -0,0 +1,46 @@ +#ifndef UNITTEST_REPORTASSERTIMPL_H +#define UNITTEST_REPORTASSERTIMPL_H + +#include "Config.h" +#include "HelperMacros.h" + +#ifdef UNITTEST_NO_EXCEPTIONS + #include <csetjmp> +#endif + +namespace UnitTest { + +class TestResults; +class TestDetails; + +namespace Detail { + +UNITTEST_LINKAGE void ExpectAssert(bool expected); + +UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults, + const TestDetails* testDetails, + char const* description, + char const* filename, + int lineNumber); + +UNITTEST_LINKAGE bool AssertExpected(); + +#ifdef UNITTEST_NO_EXCEPTIONS + UNITTEST_LINKAGE UNITTEST_JMPBUF* GetAssertJmpBuf(); + + #ifdef UNITTEST_WIN32 + #define UNITTEST_SET_ASSERT_JUMP_TARGET() \ + __pragma(warning(push)) __pragma(warning(disable:4611)) \ + UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf()) \ + __pragma(warning(pop)) + #else + #define UNITTEST_SET_ASSERT_JUMP_TARGET() UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf()) + #endif + + #define UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET() UNITTEST_LONGJMP(*UnitTest::Detail::GetAssertJmpBuf(), 1) +#endif + +} +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/Test.cpp b/3rdparty/unittest-cpp/UnitTest++/Test.cpp new file mode 100644 index 00000000000..69417223847 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Test.cpp @@ -0,0 +1,41 @@ +#include "Config.h" +#include "Test.h" +#include "TestList.h" +#include "TestResults.h" +#include "AssertException.h" +#include "MemoryOutStream.h" +#include "ExecuteTest.h" + +#ifdef UNITTEST_POSIX + #include "Posix/SignalTranslator.h" +#endif + +namespace UnitTest { + +TestList& Test::GetTestList() +{ + static TestList s_list; + return s_list; +} + +Test::Test(char const* testName, char const* suiteName, char const* filename, int lineNumber) + : m_details(testName, suiteName, filename, lineNumber) + , m_nextTest(0) + , m_isMockTest(false) +{ +} + +Test::~Test() +{ +} + +void Test::Run() +{ + ExecuteTest(*this, m_details, m_isMockTest); +} + +void Test::RunImpl() const +{ +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/Test.h b/3rdparty/unittest-cpp/UnitTest++/Test.h new file mode 100644 index 00000000000..bf7c4a35eb6 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Test.h @@ -0,0 +1,35 @@ +#ifndef UNITTEST_TEST_H +#define UNITTEST_TEST_H + +#include "TestDetails.h" + +namespace UnitTest { + +class TestResults; +class TestList; + +class UNITTEST_LINKAGE Test +{ +public: + explicit Test(char const* testName, char const* suiteName = "DefaultSuite", char const* filename = "", int lineNumber = 0); + virtual ~Test(); + void Run(); + + TestDetails const m_details; + Test* m_nextTest; + + mutable bool m_isMockTest; + + static TestList& GetTestList(); + + virtual void RunImpl() const; + +private: + Test(Test const&); + Test& operator =(Test const&); +}; + + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TestDetails.cpp b/3rdparty/unittest-cpp/UnitTest++/TestDetails.cpp new file mode 100644 index 00000000000..3af04465061 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestDetails.cpp @@ -0,0 +1,24 @@ +#include "TestDetails.h" + +namespace UnitTest { + +TestDetails::TestDetails(char const* testName_, char const* suiteName_, char const* filename_, int lineNumber_) + : suiteName(suiteName_) + , testName(testName_) + , filename(filename_) + , lineNumber(lineNumber_) + , timeConstraintExempt(false) +{ +} + +TestDetails::TestDetails(const TestDetails& details, int lineNumber_) + : suiteName(details.suiteName) + , testName(details.testName) + , filename(details.filename) + , lineNumber(lineNumber_) + , timeConstraintExempt(details.timeConstraintExempt) +{ +} + + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/TestDetails.h b/3rdparty/unittest-cpp/UnitTest++/TestDetails.h new file mode 100644 index 00000000000..eb7d596f5d2 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestDetails.h @@ -0,0 +1,27 @@ +#ifndef UNITTEST_TESTDETAILS_H +#define UNITTEST_TESTDETAILS_H + +#include "HelperMacros.h" + +namespace UnitTest { + +class UNITTEST_LINKAGE TestDetails +{ +public: + TestDetails(char const* testName, char const* suiteName, char const* filename, int lineNumber); + TestDetails(const TestDetails& details, int lineNumber); + + char const* const suiteName; + char const* const testName; + char const* const filename; + int const lineNumber; + mutable bool timeConstraintExempt; + + TestDetails(TestDetails const&); // Why is it public? --> http://gcc.gnu.org/bugs.html#cxx_rvalbind +private: + TestDetails& operator=(TestDetails const&); +}; + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TestList.cpp b/3rdparty/unittest-cpp/UnitTest++/TestList.cpp new file mode 100644 index 00000000000..4583cbbaff5 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestList.cpp @@ -0,0 +1,39 @@ +#include "TestList.h" +#include "Test.h" + +#include <cassert> + +namespace UnitTest { + +TestList::TestList() + : m_head(0) + , m_tail(0) +{ +} + +void TestList::Add(Test* test) +{ + if (m_tail == 0) + { + assert(m_head == 0); + m_head = test; + m_tail = test; + } + else + { + m_tail->m_nextTest = test; + m_tail = test; + } +} + +Test* TestList::GetHead() const +{ + return m_head; +} + +ListAdder::ListAdder(TestList& list, Test* test) +{ + list.Add(test); +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/TestList.h b/3rdparty/unittest-cpp/UnitTest++/TestList.h new file mode 100644 index 00000000000..a001d3f22cf --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestList.h @@ -0,0 +1,33 @@ +#ifndef UNITTEST_TESTLIST_H +#define UNITTEST_TESTLIST_H + +#include "HelperMacros.h" + +namespace UnitTest { + +class Test; + +class UNITTEST_LINKAGE TestList +{ +public: + TestList(); + void Add (Test* test); + + Test* GetHead() const; + +private: + Test* m_head; + Test* m_tail; +}; + + +class UNITTEST_LINKAGE ListAdder +{ +public: + ListAdder(TestList& list, Test* test); +}; + +} + + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TestMacros.h b/3rdparty/unittest-cpp/UnitTest++/TestMacros.h new file mode 100644 index 00000000000..facc94e8019 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestMacros.h @@ -0,0 +1,117 @@ +#ifndef UNITTEST_TESTMACROS_H +#define UNITTEST_TESTMACROS_H + +#include "Config.h" +#include "TestSuite.h" +#include "ExceptionMacros.h" +#include "ExecuteTest.h" +#include "AssertException.h" +#include "TestDetails.h" +#include "MemoryOutStream.h" + +#ifndef UNITTEST_POSIX + #define UNITTEST_THROW_SIGNALS_POSIX_ONLY +#else + #include "Posix/SignalTranslator.h" +#endif + +#ifdef TEST + #error UnitTest++ redefines TEST +#endif + +#ifdef TEST_EX + #error UnitTest++ redefines TEST_EX +#endif + +#ifdef TEST_FIXTURE_EX + #error UnitTest++ redefines TEST_FIXTURE_EX +#endif + +#define SUITE(Name) \ + namespace Suite##Name { \ + namespace UnitTestSuite { \ + inline char const* GetSuiteName () { \ + return #Name ; \ + } \ + } \ + } \ + namespace Suite##Name + +#define TEST_EX(Name, List) \ + class Test##Name : public UnitTest::Test \ + { \ + public: \ + Test##Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \ + private: \ + virtual void RunImpl() const; \ + } test##Name##Instance; \ + \ + UnitTest::ListAdder adder##Name (List, &test##Name##Instance); \ + \ + void Test##Name::RunImpl() const + + +#define TEST(Name) TEST_EX(Name, UnitTest::Test::GetTestList()) + + +#define TEST_FIXTURE_EX(Fixture, Name, List) \ + class Fixture##Name##Helper : public Fixture \ + { \ + public: \ + explicit Fixture##Name##Helper(UnitTest::TestDetails const& details) : m_details(details) {} \ + void RunImpl(); \ + UnitTest::TestDetails const& m_details; \ + private: \ + Fixture##Name##Helper(Fixture##Name##Helper const&); \ + Fixture##Name##Helper& operator =(Fixture##Name##Helper const&); \ + }; \ + \ + class Test##Fixture##Name : public UnitTest::Test \ + { \ + public: \ + Test##Fixture##Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \ + private: \ + virtual void RunImpl() const; \ + } test##Fixture##Name##Instance; \ + \ + UnitTest::ListAdder adder##Fixture##Name (List, &test##Fixture##Name##Instance); \ + \ + void Test##Fixture##Name::RunImpl() const \ + { \ + volatile bool ctorOk = false; \ + UT_TRY \ + ({ \ + Fixture##Name##Helper fixtureHelper(m_details); \ + ctorOk = true; \ + UnitTest::ExecuteTest(fixtureHelper, m_details, false); \ + }) \ + UT_CATCH (UnitTest::AssertException, e, \ + { \ + (void)e; \ + }) \ + UT_CATCH (std::exception, e, \ + { \ + UnitTest::MemoryOutStream stream; \ + stream << "Unhandled exception: " << e.what(); \ + UnitTest::CurrentTest::Results()->OnTestFailure(m_details, stream.GetText()); \ + }) \ + UT_CATCH_ALL \ + ({ \ + if (ctorOk) \ + { \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(m_details, __LINE__), \ + "Unhandled exception while destroying fixture " #Fixture); \ + } \ + else \ + { \ + UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(m_details, __LINE__), \ + "Unhandled exception while constructing fixture " #Fixture); \ + } \ + }) \ + } \ + void Fixture##Name##Helper::RunImpl() + +#define TEST_FIXTURE(Fixture,Name) TEST_FIXTURE_EX(Fixture, Name, UnitTest::Test::GetTestList()) + + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TestReporter.cpp b/3rdparty/unittest-cpp/UnitTest++/TestReporter.cpp new file mode 100644 index 00000000000..acfca3ebe90 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestReporter.cpp @@ -0,0 +1,9 @@ +#include "TestReporter.h" + +namespace UnitTest { + +TestReporter::~TestReporter() +{ +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/TestReporter.h b/3rdparty/unittest-cpp/UnitTest++/TestReporter.h new file mode 100644 index 00000000000..21005243c52 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestReporter.h @@ -0,0 +1,22 @@ +#ifndef UNITTEST_TESTREPORTER_H +#define UNITTEST_TESTREPORTER_H + +#include "HelperMacros.h" + +namespace UnitTest { + +class TestDetails; + +class UNITTEST_LINKAGE TestReporter +{ +public: + virtual ~TestReporter(); + + virtual void ReportTestStart(TestDetails const& test) = 0; + virtual void ReportFailure(TestDetails const& test, char const* failure) = 0; + virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed) = 0; + virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed) = 0; +}; + +} +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TestReporterStdout.cpp b/3rdparty/unittest-cpp/UnitTest++/TestReporterStdout.cpp new file mode 100644 index 00000000000..7d089033f26 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestReporterStdout.cpp @@ -0,0 +1,46 @@ +#include "TestReporterStdout.h" +#include <cstdio> + +#include "TestDetails.h" + +// cstdio doesn't pull in namespace std on VC6, so we do it here. +#if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) + namespace std {} +#endif + +namespace UnitTest { + +void TestReporterStdout::ReportFailure(TestDetails const& details, char const* failure) +{ + using namespace std; +#if defined(__APPLE__) || defined(__GNUG__) + char const* const errorFormat = "%s:%d:%d: error: Failure in %s: %s\n"; + fprintf(stderr, errorFormat, details.filename, details.lineNumber, 1, details.testName, failure); +#else + char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n"; + fprintf(stderr, errorFormat, details.filename, details.lineNumber, details.testName, failure); +#endif +} + +void TestReporterStdout::ReportTestStart(TestDetails const& /*test*/) +{ +} + +void TestReporterStdout::ReportTestFinish(TestDetails const& /*test*/, float) +{ +} + +void TestReporterStdout::ReportSummary(int const totalTestCount, int const failedTestCount, + int const failureCount, float const secondsElapsed) +{ + using namespace std; + + if (failureCount > 0) + printf("FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount); + else + printf("Success: %d tests passed.\n", totalTestCount); + + printf("Test time: %.2f seconds.\n", secondsElapsed); +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/TestReporterStdout.h b/3rdparty/unittest-cpp/UnitTest++/TestReporterStdout.h new file mode 100644 index 00000000000..e8d7bbfbed0 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestReporterStdout.h @@ -0,0 +1,19 @@ +#ifndef UNITTEST_TESTREPORTERSTDOUT_H +#define UNITTEST_TESTREPORTERSTDOUT_H + +#include "TestReporter.h" + +namespace UnitTest { + +class UNITTEST_LINKAGE TestReporterStdout : public TestReporter +{ +private: + virtual void ReportTestStart(TestDetails const& test); + virtual void ReportFailure(TestDetails const& test, char const* failure); + virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed); + virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); +}; + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TestResults.cpp b/3rdparty/unittest-cpp/UnitTest++/TestResults.cpp new file mode 100644 index 00000000000..b3b67c0c8e2 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestResults.cpp @@ -0,0 +1,60 @@ +#include "TestResults.h" +#include "TestReporter.h" + +#include "TestDetails.h" + +namespace UnitTest { + +TestResults::TestResults(TestReporter* testReporter) + : m_testReporter(testReporter) + , m_totalTestCount(0) + , m_failedTestCount(0) + , m_failureCount(0) + , m_currentTestFailed(false) +{ +} + +void TestResults::OnTestStart(TestDetails const& test) +{ + ++m_totalTestCount; + m_currentTestFailed = false; + if (m_testReporter) + m_testReporter->ReportTestStart(test); +} + +void TestResults::OnTestFailure(TestDetails const& test, char const* failure) +{ + ++m_failureCount; + if (!m_currentTestFailed) + { + ++m_failedTestCount; + m_currentTestFailed = true; + } + + if (m_testReporter) + m_testReporter->ReportFailure(test, failure); +} + +void TestResults::OnTestFinish(TestDetails const& test, float secondsElapsed) +{ + if (m_testReporter) + m_testReporter->ReportTestFinish(test, secondsElapsed); +} + +int TestResults::GetTotalTestCount() const +{ + return m_totalTestCount; +} + +int TestResults::GetFailedTestCount() const +{ + return m_failedTestCount; +} + +int TestResults::GetFailureCount() const +{ + return m_failureCount; +} + + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/TestResults.h b/3rdparty/unittest-cpp/UnitTest++/TestResults.h new file mode 100644 index 00000000000..a24aaf550de --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestResults.h @@ -0,0 +1,38 @@ +#ifndef UNITTEST_TESTRESULTS_H +#define UNITTEST_TESTRESULTS_H + +#include "HelperMacros.h" + +namespace UnitTest { + +class TestReporter; +class TestDetails; + +class UNITTEST_LINKAGE TestResults +{ +public: + explicit TestResults(TestReporter* reporter = 0); + + void OnTestStart(TestDetails const& test); + void OnTestFailure(TestDetails const& test, char const* failure); + void OnTestFinish(TestDetails const& test, float secondsElapsed); + + int GetTotalTestCount() const; + int GetFailedTestCount() const; + int GetFailureCount() const; + +private: + TestReporter* m_testReporter; + int m_totalTestCount; + int m_failedTestCount; + int m_failureCount; + + bool m_currentTestFailed; + + TestResults(TestResults const&); + TestResults& operator =(TestResults const&); +}; + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TestRunner.cpp b/3rdparty/unittest-cpp/UnitTest++/TestRunner.cpp new file mode 100644 index 00000000000..a8151e6a8d7 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestRunner.cpp @@ -0,0 +1,82 @@ +#include "TestRunner.h" +#include "TestResults.h" +#include "TestReporter.h" +#include "TestReporterStdout.h" +#include "TimeHelpers.h" +#include "MemoryOutStream.h" + +#include <cstring> + + +namespace UnitTest { + +int RunAllTests() +{ + TestReporterStdout reporter; + TestRunner runner(reporter); + return runner.RunTestsIf(Test::GetTestList(), NULL, True(), 0); +} + + +TestRunner::TestRunner(TestReporter& reporter) + : m_reporter(&reporter) + , m_result(new TestResults(&reporter)) + , m_timer(new Timer) +{ + m_timer->Start(); +} + +TestRunner::~TestRunner() +{ + delete m_result; + delete m_timer; +} + +TestResults* TestRunner::GetTestResults() +{ + return m_result; +} + +int TestRunner::Finish() const +{ + float const secondsElapsed = static_cast<float>(m_timer->GetTimeInMs() / 1000.0); + m_reporter->ReportSummary(m_result->GetTotalTestCount(), + m_result->GetFailedTestCount(), + m_result->GetFailureCount(), + secondsElapsed); + + return m_result->GetFailureCount(); +} + +bool TestRunner::IsTestInSuite(const Test* const curTest, char const* suiteName) const +{ + using namespace std; + return (suiteName == NULL) || !strcmp(curTest->m_details.suiteName, suiteName); +} + +void TestRunner::RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const +{ + if (curTest->m_isMockTest == false) + CurrentTest::Results() = result; + + Timer testTimer; + testTimer.Start(); + + result->OnTestStart(curTest->m_details); + + curTest->Run(); + + double const testTimeInMs = testTimer.GetTimeInMs(); + if (maxTestTimeInMs > 0 && testTimeInMs > maxTestTimeInMs && !curTest->m_details.timeConstraintExempt) + { + MemoryOutStream stream; + stream << "Global time constraint failed. Expected under " << maxTestTimeInMs << + "ms but took " << testTimeInMs << "ms."; + + result->OnTestFailure(curTest->m_details, stream.GetText()); + } + + result->OnTestFinish(curTest->m_details, static_cast< float >(testTimeInMs / 1000.0)); +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/TestRunner.h b/3rdparty/unittest-cpp/UnitTest++/TestRunner.h new file mode 100644 index 00000000000..f88b9cc6281 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestRunner.h @@ -0,0 +1,61 @@ +#ifndef UNITTEST_TESTRUNNER_H +#define UNITTEST_TESTRUNNER_H + +#include "Test.h" +#include "TestList.h" +#include "CurrentTest.h" + +namespace UnitTest { + +class TestReporter; +class TestResults; +class Timer; + +UNITTEST_LINKAGE int RunAllTests(); + +struct True +{ + bool operator()(const Test* const) const + { + return true; + } +}; + +class UNITTEST_LINKAGE TestRunner +{ +public: + explicit TestRunner(TestReporter& reporter); + ~TestRunner(); + + template< class Predicate > + int RunTestsIf(TestList const& list, char const* suiteName, + const Predicate& predicate, int maxTestTimeInMs) const + { + Test* curTest = list.GetHead(); + + while (curTest != 0) + { + if (IsTestInSuite(curTest, suiteName) && predicate(curTest)) + RunTest(m_result, curTest, maxTestTimeInMs); + + curTest = curTest->m_nextTest; + } + + return Finish(); + } + + TestResults* GetTestResults(); + +private: + TestReporter* m_reporter; + TestResults* m_result; + Timer* m_timer; + + int Finish() const; + bool IsTestInSuite(const Test* const curTest, char const* suiteName) const; + void RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const; +}; + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TestSuite.h b/3rdparty/unittest-cpp/UnitTest++/TestSuite.h new file mode 100644 index 00000000000..2812d8c9496 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TestSuite.h @@ -0,0 +1,12 @@ +#ifndef UNITTEST_TESTSUITE_H +#define UNITTEST_TESTSUITE_H + +namespace UnitTestSuite +{ + inline char const* GetSuiteName () + { + return "DefaultSuite"; + } +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TimeConstraint.cpp b/3rdparty/unittest-cpp/UnitTest++/TimeConstraint.cpp new file mode 100644 index 00000000000..1c12d8354ff --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TimeConstraint.cpp @@ -0,0 +1,29 @@ +#include "TimeConstraint.h" +#include "TestResults.h" +#include "MemoryOutStream.h" +#include "CurrentTest.h" + +namespace UnitTest { + + +TimeConstraint::TimeConstraint(int ms, TestDetails const& details) + : m_details(details) + , m_maxMs(ms) +{ + m_timer.Start(); +} + +TimeConstraint::~TimeConstraint() +{ + double const totalTimeInMs = m_timer.GetTimeInMs(); + if (totalTimeInMs > m_maxMs) + { + MemoryOutStream stream; + stream << "Time constraint failed. Expected to run test under " << m_maxMs << + "ms but took " << totalTimeInMs << "ms."; + + CurrentTest::Results()->OnTestFailure(m_details, stream.GetText()); + } +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/TimeConstraint.h b/3rdparty/unittest-cpp/UnitTest++/TimeConstraint.h new file mode 100644 index 00000000000..8c06913ebb8 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TimeConstraint.h @@ -0,0 +1,37 @@ +#ifndef UNITTEST_TIMECONSTRAINT_H +#define UNITTEST_TIMECONSTRAINT_H + +#include "TimeHelpers.h" +#include "HelperMacros.h" + +namespace UnitTest { + +class TestResults; +class TestDetails; + +class UNITTEST_LINKAGE TimeConstraint +{ +public: + TimeConstraint(int ms, TestDetails const& details); + ~TimeConstraint(); + +private: + void operator=(TimeConstraint const&); + TimeConstraint(TimeConstraint const&); + + Timer m_timer; + TestDetails const& m_details; + int const m_maxMs; +}; + +#define UNITTEST_TIME_CONSTRAINT(ms) \ + UnitTest::TimeConstraint unitTest__timeConstraint__(ms, UnitTest::TestDetails(m_details, __LINE__)) + +#define UNITTEST_TIME_CONSTRAINT_EXEMPT() \ + UNITTEST_MULTILINE_MACRO_BEGIN \ + m_details.timeConstraintExempt = true; \ + UNITTEST_MULTILINE_MACRO_END + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/TimeHelpers.h b/3rdparty/unittest-cpp/UnitTest++/TimeHelpers.h new file mode 100644 index 00000000000..f34ed008571 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/TimeHelpers.h @@ -0,0 +1,7 @@ +#include "Config.h" + +#if defined UNITTEST_POSIX + #include "Posix/TimeHelpers.h" +#else + #include "Win32/TimeHelpers.h" +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/UnitTest++.h b/3rdparty/unittest-cpp/UnitTest++/UnitTest++.h new file mode 100644 index 00000000000..1a9fe86a49b --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/UnitTest++.h @@ -0,0 +1 @@ +#include "UnitTestPP.h"
\ No newline at end of file diff --git a/3rdparty/unittest-cpp/UnitTest++/UnitTestPP.h b/3rdparty/unittest-cpp/UnitTest++/UnitTestPP.h new file mode 100644 index 00000000000..c9bbc0ccdf7 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/UnitTestPP.h @@ -0,0 +1,11 @@ +#ifndef UNITTESTPP_H +#define UNITTESTPP_H + +#include "Config.h" +#include "TestMacros.h" +#include "CheckMacros.h" +#include "TestRunner.h" +#include "TimeConstraint.h" +#include "ReportAssert.h" + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/Win32/TimeHelpers.cpp b/3rdparty/unittest-cpp/UnitTest++/Win32/TimeHelpers.cpp new file mode 100644 index 00000000000..aa97b892b60 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Win32/TimeHelpers.cpp @@ -0,0 +1,49 @@ +#include "TimeHelpers.h" + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +namespace UnitTest { + +Timer::Timer() + : m_threadHandle(::GetCurrentThread()) + , m_startTime(0) +{ +#if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) // VC6 doesn't have DWORD_PTR + typedef unsigned long DWORD_PTR; +#endif + + DWORD_PTR systemMask; + ::GetProcessAffinityMask(GetCurrentProcess(), &m_processAffinityMask, &systemMask); + ::SetThreadAffinityMask(m_threadHandle, 1); + ::QueryPerformanceFrequency(reinterpret_cast< LARGE_INTEGER* >(&m_frequency)); + ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask); +} + +void Timer::Start() +{ + m_startTime = GetTime(); +} + +double Timer::GetTimeInMs() const +{ + __int64 const elapsedTime = GetTime() - m_startTime; + double const seconds = double(elapsedTime) / double(m_frequency); + return seconds * 1000.0; +} + +__int64 Timer::GetTime() const +{ + LARGE_INTEGER curTime; + ::SetThreadAffinityMask(m_threadHandle, 1); + ::QueryPerformanceCounter(&curTime); + ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask); + return curTime.QuadPart; +} + +void TimeHelpers::SleepMs(int ms) +{ + ::Sleep(ms); +} + +} diff --git a/3rdparty/unittest-cpp/UnitTest++/Win32/TimeHelpers.h b/3rdparty/unittest-cpp/UnitTest++/Win32/TimeHelpers.h new file mode 100644 index 00000000000..2bbe75f81f0 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/Win32/TimeHelpers.h @@ -0,0 +1,45 @@ +#ifndef UNITTEST_TIMEHELPERS_H +#define UNITTEST_TIMEHELPERS_H + +#include "../Config.h" +#include "../HelperMacros.h" + +#ifdef UNITTEST_MINGW + #ifndef __int64 + #define __int64 long long + #endif +#endif + +namespace UnitTest { + +class UNITTEST_LINKAGE Timer +{ +public: + Timer(); + void Start(); + double GetTimeInMs() const; + +private: + __int64 GetTime() const; + + void* m_threadHandle; + +#if defined(_WIN64) + unsigned __int64 m_processAffinityMask; +#else + unsigned long m_processAffinityMask; +#endif + + __int64 m_startTime; + __int64 m_frequency; +}; + + +namespace TimeHelpers +{ + UNITTEST_LINKAGE void SleepMs(int ms); +} + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/XmlTestReporter.cpp b/3rdparty/unittest-cpp/UnitTest++/XmlTestReporter.cpp new file mode 100644 index 00000000000..c3312eaa15f --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/XmlTestReporter.cpp @@ -0,0 +1,131 @@ +#include "Config.h" +#ifndef UNITTEST_NO_DEFERRED_REPORTER + +#include "XmlTestReporter.h" + +#include <iostream> +#include <sstream> +#include <string> + +using std::string; +using std::ostringstream; +using std::ostream; + +namespace { + +void ReplaceChar(string& str, char c, string const& replacement) +{ + for (size_t pos = str.find(c); pos != string::npos; pos = str.find(c, pos + 1)) + str.replace(pos, 1, replacement); +} + +string XmlEscape(string const& value) +{ + string escaped = value; + + ReplaceChar(escaped, '&', "&"); + ReplaceChar(escaped, '<', "<"); + ReplaceChar(escaped, '>', ">"); + ReplaceChar(escaped, '\'', "'"); + ReplaceChar(escaped, '\"', """); + + return escaped; +} + +string BuildFailureMessage(string const& file, int line, string const& message) +{ + ostringstream failureMessage; + failureMessage << file << "(" << line << ") : " << message; + return failureMessage.str(); +} + +} + +namespace UnitTest { + +XmlTestReporter::XmlTestReporter(ostream& ostream) + : m_ostream(ostream) +{ +} + +void XmlTestReporter::ReportSummary(int totalTestCount, int failedTestCount, + int failureCount, float secondsElapsed) +{ + AddXmlElement(m_ostream, NULL); + + BeginResults(m_ostream, totalTestCount, failedTestCount, failureCount, secondsElapsed); + + DeferredTestResultList const& results = GetResults(); + for (DeferredTestResultList::const_iterator i = results.begin(); i != results.end(); ++i) + { + BeginTest(m_ostream, *i); + + if (i->failed) + AddFailure(m_ostream, *i); + + EndTest(m_ostream, *i); + } + + EndResults(m_ostream); +} + +void XmlTestReporter::AddXmlElement(ostream& os, char const* encoding) +{ + os << "<?xml version=\"1.0\""; + + if (encoding != NULL) + os << " encoding=\"" << encoding << "\""; + + os << "?>"; +} + +void XmlTestReporter::BeginResults(std::ostream& os, int totalTestCount, int failedTestCount, + int failureCount, float secondsElapsed) +{ + os << "<unittest-results" + << " tests=\"" << totalTestCount << "\"" + << " failedtests=\"" << failedTestCount << "\"" + << " failures=\"" << failureCount << "\"" + << " time=\"" << secondsElapsed << "\"" + << ">"; +} + +void XmlTestReporter::EndResults(std::ostream& os) +{ + os << "</unittest-results>"; +} + +void XmlTestReporter::BeginTest(std::ostream& os, DeferredTestResult const& result) +{ + os << "<test" + << " suite=\"" << result.suiteName << "\"" + << " name=\"" << result.testName << "\"" + << " time=\"" << result.timeElapsed << "\""; +} + +void XmlTestReporter::EndTest(std::ostream& os, DeferredTestResult const& result) +{ + if (result.failed) + os << "</test>"; + else + os << "/>"; +} + +void XmlTestReporter::AddFailure(std::ostream& os, DeferredTestResult const& result) +{ + os << ">"; // close <test> element + + for (DeferredTestResult::FailureVec::const_iterator it = result.failures.begin(); + it != result.failures.end(); + ++it) + { + string const escapedMessage = XmlEscape(std::string(it->failureStr)); + string const message = BuildFailureMessage(result.failureFile, it->lineNumber, escapedMessage); + + os << "<failure" << " message=\"" << message << "\"" << "/>"; + } +} + +} + +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/XmlTestReporter.h b/3rdparty/unittest-cpp/UnitTest++/XmlTestReporter.h new file mode 100644 index 00000000000..63d424e8bbd --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/XmlTestReporter.h @@ -0,0 +1,38 @@ +#ifndef UNITTEST_XMLTESTREPORTER_H +#define UNITTEST_XMLTESTREPORTER_H + +#include "Config.h" +#ifndef UNITTEST_NO_DEFERRED_REPORTER + +#include "DeferredTestReporter.h" + +#include <iosfwd> + +namespace UnitTest +{ + +class UNITTEST_LINKAGE XmlTestReporter : public DeferredTestReporter +{ +public: + explicit XmlTestReporter(std::ostream& ostream); + + virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); + +private: + XmlTestReporter(XmlTestReporter const&); + XmlTestReporter& operator=(XmlTestReporter const&); + + void AddXmlElement(std::ostream& os, char const* encoding); + void BeginResults(std::ostream& os, int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); + void EndResults(std::ostream& os); + void BeginTest(std::ostream& os, DeferredTestResult const& result); + void AddFailure(std::ostream& os, DeferredTestResult const& result); + void EndTest(std::ostream& os, DeferredTestResult const& result); + + std::ostream& m_ostream; +}; + +} + +#endif +#endif diff --git a/3rdparty/unittest-cpp/UnitTest++/unittestpp_vs2005.vcproj b/3rdparty/unittest-cpp/UnitTest++/unittestpp_vs2005.vcproj new file mode 100644 index 00000000000..0c1f6aedc86 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/unittestpp_vs2005.vcproj @@ -0,0 +1,614 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="unittestpp_vs2005" + ProjectGUID="{64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6}" + RootNamespace="unittestpp" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="win32_static_vc80_md_debug|Win32" + OutputDirectory="$(SolutionDir)lib\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE" + MinimalRebuild="true" + ExceptionHandling="2" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="4" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\unittestpp.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_static_vc80_md_release|Win32" + OutputDirectory="$(SolutionDir)lib\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="1" + WholeProgramOptimization="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE" + ExceptionHandling="2" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="4" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\unittestpp.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_dll_vc80_debug|Win32" + OutputDirectory="$(SolutionDir)bin\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_USRDLL;_CRT_SECURE_NO_DEPRECATE;UNITTEST_DLL_EXPORT" + MinimalRebuild="true" + ExceptionHandling="2" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="4" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)\unittestpp.dll" + GenerateDebugInformation="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_dll_vc80_release|Win32" + OutputDirectory="$(SolutionDir)bin\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + PreprocessorDefinitions="WIN32;NDEBUG;_USRDLL;_CRT_SECURE_NO_DEPRECATE;UNITTEST_DLL_EXPORT" + ExceptionHandling="2" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="4" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)\unittestpp.dll" + GenerateDebugInformation="true" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_static_vc80_mt_debug|Win32" + OutputDirectory="$(SolutionDir)lib\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE" + MinimalRebuild="true" + ExceptionHandling="2" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="4" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\unittestpp.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_static_vc80_mt_release|Win32" + OutputDirectory="$(SolutionDir)lib\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="1" + WholeProgramOptimization="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE" + ExceptionHandling="2" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="4" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\unittestpp.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Win32" + > + <File + RelativePath=".\Win32\TimeHelpers.cpp" + > + </File> + <File + RelativePath=".\Win32\TimeHelpers.h" + > + </File> + </Filter> + <File + RelativePath=".\AssertException.cpp" + > + </File> + <File + RelativePath=".\AssertException.h" + > + </File> + <File + RelativePath=".\CheckMacros.h" + > + </File> + <File + RelativePath=".\Checks.cpp" + > + </File> + <File + RelativePath=".\Checks.h" + > + </File> + <File + RelativePath=".\CompositeTestReporter.cpp" + > + </File> + <File + RelativePath=".\CompositeTestReporter.h" + > + </File> + <File + RelativePath="..\config.h" + > + </File> + <File + RelativePath=".\CurrentTest.cpp" + > + </File> + <File + RelativePath=".\CurrentTest.h" + > + </File> + <File + RelativePath=".\DeferredTestReporter.cpp" + > + </File> + <File + RelativePath=".\DeferredTestReporter.h" + > + </File> + <File + RelativePath=".\DeferredTestResult.cpp" + > + </File> + <File + RelativePath=".\DeferredTestResult.h" + > + </File> + <File + RelativePath=".\ExceptionMacros.h" + > + </File> + <File + RelativePath=".\ExecuteTest.h" + > + </File> + <File + RelativePath=".\HelperMacros.h" + > + </File> + <File + RelativePath=".\MemoryOutStream.cpp" + > + </File> + <File + RelativePath=".\MemoryOutStream.h" + > + </File> + <File + RelativePath=".\ReportAssert.cpp" + > + </File> + <File + RelativePath=".\ReportAssert.h" + > + </File> + <File + RelativePath=".\ReportAssertImpl.h" + > + </File> + <File + RelativePath=".\Test.cpp" + > + </File> + <File + RelativePath=".\Test.h" + > + </File> + <File + RelativePath=".\TestDetails.cpp" + > + </File> + <File + RelativePath=".\TestDetails.h" + > + </File> + <File + RelativePath=".\TestList.cpp" + > + </File> + <File + RelativePath=".\TestList.h" + > + </File> + <File + RelativePath=".\TestMacros.h" + > + </File> + <File + RelativePath=".\TestReporter.cpp" + > + </File> + <File + RelativePath=".\TestReporter.h" + > + </File> + <File + RelativePath=".\TestReporterStdout.cpp" + > + </File> + <File + RelativePath=".\TestReporterStdout.h" + > + </File> + <File + RelativePath=".\TestResults.cpp" + > + </File> + <File + RelativePath=".\TestResults.h" + > + </File> + <File + RelativePath=".\TestRunner.cpp" + > + </File> + <File + RelativePath=".\TestRunner.h" + > + </File> + <File + RelativePath=".\TestSuite.h" + > + </File> + <File + RelativePath=".\TimeConstraint.cpp" + > + </File> + <File + RelativePath=".\TimeConstraint.h" + > + </File> + <File + RelativePath=".\TimeHelpers.h" + > + </File> + <File + RelativePath="..\unittestpp.h" + > + </File> + <File + RelativePath=".\XmlTestReporter.cpp" + > + </File> + <File + RelativePath=".\XmlTestReporter.h" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/3rdparty/unittest-cpp/UnitTest++/unittestpp_vs2008.vcproj b/3rdparty/unittest-cpp/UnitTest++/unittestpp_vs2008.vcproj new file mode 100644 index 00000000000..68a2ea3aab8 --- /dev/null +++ b/3rdparty/unittest-cpp/UnitTest++/unittestpp_vs2008.vcproj @@ -0,0 +1,607 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="unittestpp_vs2008" + ProjectGUID="{64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6}" + RootNamespace="unittestpp" + Keyword="Win32Proj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="win32_static_vc90_md_debug|Win32" + OutputDirectory="$(SolutionDir)lib\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE" + MinimalRebuild="true" + ExceptionHandling="2" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="4" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\unittestpp.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_static_vc90_md_release|Win32" + OutputDirectory="$(SolutionDir)lib\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="1" + WholeProgramOptimization="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE" + ExceptionHandling="2" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="4" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\unittestpp.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_dll_vc90_debug|Win32" + OutputDirectory="$(SolutionDir)bin\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_USRDLL;_CRT_SECURE_NO_DEPRECATE;UNITTEST_DLL_EXPORT" + MinimalRebuild="true" + ExceptionHandling="2" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="4" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)\unittestpp.dll" + GenerateDebugInformation="true" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_dll_vc90_release|Win32" + OutputDirectory="$(SolutionDir)bin\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + PreprocessorDefinitions="WIN32;NDEBUG;_USRDLL;_CRT_SECURE_NO_DEPRECATE;UNITTEST_DLL_EXPORT" + ExceptionHandling="2" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="4" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="$(OutDir)\unittestpp.dll" + GenerateDebugInformation="true" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_static_vc90_mt_debug|Win32" + OutputDirectory="$(SolutionDir)lib\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE" + MinimalRebuild="true" + ExceptionHandling="2" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="4" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\unittestpp.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="win32_static_vc90_mt_release|Win32" + OutputDirectory="$(SolutionDir)lib\$(ConfigurationName)" + IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)\$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="1" + WholeProgramOptimization="0" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="3" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE" + ExceptionHandling="2" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="4" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)\unittestpp.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Win32" + > + <File + RelativePath=".\Win32\TimeHelpers.cpp" + > + </File> + <File + RelativePath=".\Win32\TimeHelpers.h" + > + </File> + </Filter> + <File + RelativePath=".\AssertException.cpp" + > + </File> + <File + RelativePath=".\AssertException.h" + > + </File> + <File + RelativePath=".\CheckMacros.h" + > + </File> + <File + RelativePath=".\Checks.cpp" + > + </File> + <File + RelativePath=".\Checks.h" + > + </File> + <File + RelativePath=".\CompositeTestReporter.cpp" + > + </File> + <File + RelativePath=".\CompositeTestReporter.h" + > + </File> + <File + RelativePath="..\config.h" + > + </File> + <File + RelativePath=".\CurrentTest.cpp" + > + </File> + <File + RelativePath=".\CurrentTest.h" + > + </File> + <File + RelativePath=".\DeferredTestReporter.cpp" + > + </File> + <File + RelativePath=".\DeferredTestReporter.h" + > + </File> + <File + RelativePath=".\DeferredTestResult.cpp" + > + </File> + <File + RelativePath=".\DeferredTestResult.h" + > + </File> + <File + RelativePath=".\ExceptionMacros.h" + > + </File> + <File + RelativePath=".\ExecuteTest.h" + > + </File> + <File + RelativePath=".\HelperMacros.h" + > + </File> + <File + RelativePath=".\MemoryOutStream.cpp" + > + </File> + <File + RelativePath=".\MemoryOutStream.h" + > + </File> + <File + RelativePath=".\ReportAssert.cpp" + > + </File> + <File + RelativePath=".\ReportAssert.h" + > + </File> + <File + RelativePath=".\ReportAssertImpl.h" + > + </File> + <File + RelativePath=".\Test.cpp" + > + </File> + <File + RelativePath=".\Test.h" + > + </File> + <File + RelativePath=".\TestDetails.cpp" + > + </File> + <File + RelativePath=".\TestDetails.h" + > + </File> + <File + RelativePath=".\TestList.cpp" + > + </File> + <File + RelativePath=".\TestList.h" + > + </File> + <File + RelativePath=".\TestMacros.h" + > + </File> + <File + RelativePath=".\TestReporter.cpp" + > + </File> + <File + RelativePath=".\TestReporter.h" + > + </File> + <File + RelativePath=".\TestReporterStdout.cpp" + > + </File> + <File + RelativePath=".\TestReporterStdout.h" + > + </File> + <File + RelativePath=".\TestResults.cpp" + > + </File> + <File + RelativePath=".\TestResults.h" + > + </File> + <File + RelativePath=".\TestRunner.cpp" + > + </File> + <File + RelativePath=".\TestRunner.h" + > + </File> + <File + RelativePath=".\TestSuite.h" + > + </File> + <File + RelativePath=".\TimeConstraint.cpp" + > + </File> + <File + RelativePath=".\TimeConstraint.h" + > + </File> + <File + RelativePath=".\TimeHelpers.h" + > + </File> + <File + RelativePath="..\unittestpp.h" + > + </File> + <File + RelativePath=".\XmlTestReporter.cpp" + > + </File> + <File + RelativePath=".\XmlTestReporter.h" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> |