mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-26 16:19:30 +03:00
Merge and uncrustify.
This commit is contained in:
parent
89ff2596ee
commit
74ca0c301f
8 changed files with 804 additions and 826 deletions
|
|
@ -41,10 +41,10 @@
|
|||
if (!UnitTest::Check(value)) \
|
||||
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
UT_CATCH (std::exception, e, \
|
||||
{ \
|
||||
UnitTest::MemoryOutStream message; \
|
||||
|
|
@ -64,11 +64,11 @@
|
|||
UT_TRY \
|
||||
({ \
|
||||
UnitTest::CheckEqual(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
UT_CATCH (std::exception, e, \
|
||||
{ \
|
||||
UnitTest::MemoryOutStream message; \
|
||||
|
|
@ -89,10 +89,10 @@
|
|||
({ \
|
||||
UnitTest::CheckClose(*UnitTest::CurrentTest::Results(), expected, actual, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
UT_CATCH (std::exception, e, \
|
||||
{ \
|
||||
UnitTest::MemoryOutStream message; \
|
||||
|
|
@ -112,11 +112,11 @@
|
|||
UT_TRY \
|
||||
({ \
|
||||
UnitTest::CheckArrayEqual(*UnitTest::CurrentTest::Results(), expected, actual, count, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
UT_CATCH (std::exception, e, \
|
||||
{ \
|
||||
UnitTest::MemoryOutStream message; \
|
||||
|
|
@ -137,10 +137,10 @@
|
|||
({ \
|
||||
UnitTest::CheckArrayClose(*UnitTest::CurrentTest::Results(), expected, actual, count, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
UT_CATCH (std::exception, e, \
|
||||
{ \
|
||||
UnitTest::MemoryOutStream message; \
|
||||
|
|
@ -160,11 +160,11 @@
|
|||
UT_TRY \
|
||||
({ \
|
||||
UnitTest::CheckArray2DClose(*UnitTest::CurrentTest::Results(), expected, actual, rows, columns, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
}) \
|
||||
UT_CATCH (UnitTest::AssertException, , \
|
||||
{ \
|
||||
UT_THROW(); \
|
||||
}) \
|
||||
UT_CATCH (std::exception, e, \
|
||||
{ \
|
||||
UnitTest::MemoryOutStream message; \
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@
|
|||
#endif
|
||||
|
||||
#ifndef UNITTEST_NO_EXCEPTIONS
|
||||
#define REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(UnitTest::CurrentTest::Results()); decoratedReporter.next(); )
|
||||
#define REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(UnitTest::CurrentTest::Results()); decoratedReporter.next(); )
|
||||
#endif
|
||||
|
||||
#ifdef UNITTEST_NO_EXCEPTIONS
|
||||
#define REQUIRE
|
||||
#define REQUIRE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -5,25 +5,25 @@
|
|||
|
||||
namespace UnitTest {
|
||||
|
||||
RequiredCheckTestReporter::RequiredCheckTestReporter(TestResults* results)
|
||||
: m_results(results)
|
||||
, m_throwingReporter(0)
|
||||
, m_continue(0)
|
||||
{
|
||||
if(m_results)
|
||||
{
|
||||
m_throwingReporter.setDecorated(m_results->m_testReporter);
|
||||
m_results->m_testReporter = &m_throwingReporter;
|
||||
}
|
||||
}
|
||||
RequiredCheckTestReporter::RequiredCheckTestReporter(TestResults* results)
|
||||
: m_results(results)
|
||||
, m_throwingReporter(0)
|
||||
, m_continue(0)
|
||||
{
|
||||
if(m_results)
|
||||
{
|
||||
m_throwingReporter.setDecorated(m_results->m_testReporter);
|
||||
m_results->m_testReporter = &m_throwingReporter;
|
||||
}
|
||||
}
|
||||
|
||||
RequiredCheckTestReporter::~RequiredCheckTestReporter()
|
||||
{
|
||||
if(m_results) m_results->m_testReporter = m_throwingReporter.getDecorated();
|
||||
}
|
||||
RequiredCheckTestReporter::~RequiredCheckTestReporter()
|
||||
{
|
||||
if(m_results) m_results->m_testReporter = m_throwingReporter.getDecorated();
|
||||
}
|
||||
|
||||
bool RequiredCheckTestReporter::next()
|
||||
{
|
||||
return m_continue++ == 0;
|
||||
}
|
||||
bool RequiredCheckTestReporter::next()
|
||||
{
|
||||
return m_continue++ == 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,23 +6,23 @@
|
|||
|
||||
namespace UnitTest {
|
||||
|
||||
class TestResults;
|
||||
class TestResults;
|
||||
|
||||
// This RAII class decorates the current TestReporter with
|
||||
// a version that throws after reporting a failure.
|
||||
class UNITTEST_LINKAGE RequiredCheckTestReporter
|
||||
{
|
||||
public:
|
||||
explicit RequiredCheckTestReporter(TestResults* results);
|
||||
~RequiredCheckTestReporter();
|
||||
// This RAII class decorates the current TestReporter with
|
||||
// a version that throws after reporting a failure.
|
||||
class UNITTEST_LINKAGE RequiredCheckTestReporter
|
||||
{
|
||||
public:
|
||||
explicit RequiredCheckTestReporter(TestResults* results);
|
||||
~RequiredCheckTestReporter();
|
||||
|
||||
bool next();
|
||||
|
||||
private:
|
||||
TestResults* m_results;
|
||||
ThrowingTestReporter m_throwingReporter;
|
||||
int m_continue;
|
||||
};
|
||||
bool next();
|
||||
|
||||
private:
|
||||
TestResults* m_results;
|
||||
ThrowingTestReporter m_throwingReporter;
|
||||
int m_continue;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace UnitTest {
|
||||
|
||||
class RequiredCheckTestReporter;
|
||||
class RequiredCheckTestReporter;
|
||||
class TestReporter;
|
||||
class TestDetails;
|
||||
|
||||
|
|
@ -23,9 +23,9 @@ class RequiredCheckTestReporter;
|
|||
int GetFailureCount() const;
|
||||
|
||||
private:
|
||||
friend class RequiredCheckTestReporter;
|
||||
friend class RequiredCheckTestReporter;
|
||||
|
||||
private:
|
||||
private:
|
||||
TestReporter* m_testReporter;
|
||||
int m_totalTestCount;
|
||||
int m_failedTestCount;
|
||||
|
|
|
|||
|
|
@ -3,49 +3,47 @@
|
|||
|
||||
namespace UnitTest {
|
||||
|
||||
ThrowingTestReporter::ThrowingTestReporter(TestReporter* decoratedReporter)
|
||||
: m_decoratedReporter(decoratedReporter)
|
||||
{
|
||||
}
|
||||
ThrowingTestReporter::ThrowingTestReporter(TestReporter* decoratedReporter)
|
||||
: m_decoratedReporter(decoratedReporter)
|
||||
{}
|
||||
|
||||
//virtual
|
||||
ThrowingTestReporter::~ThrowingTestReporter()
|
||||
{
|
||||
}
|
||||
//virtual
|
||||
ThrowingTestReporter::~ThrowingTestReporter()
|
||||
{}
|
||||
|
||||
//virtual
|
||||
void ThrowingTestReporter::ReportTestStart(TestDetails const& test)
|
||||
{
|
||||
if(m_decoratedReporter) m_decoratedReporter->ReportTestStart(test);
|
||||
}
|
||||
//virtual
|
||||
void ThrowingTestReporter::ReportTestStart(TestDetails const& test)
|
||||
{
|
||||
if(m_decoratedReporter) m_decoratedReporter->ReportTestStart(test);
|
||||
}
|
||||
|
||||
//virtual
|
||||
void ThrowingTestReporter::ReportFailure(TestDetails const& test, char const* failure)
|
||||
{
|
||||
if(m_decoratedReporter) m_decoratedReporter->ReportFailure(test, failure);
|
||||
throw AssertException();
|
||||
}
|
||||
//virtual
|
||||
void ThrowingTestReporter::ReportFailure(TestDetails const& test, char const* failure)
|
||||
{
|
||||
if(m_decoratedReporter) m_decoratedReporter->ReportFailure(test, failure);
|
||||
throw AssertException();
|
||||
}
|
||||
|
||||
//virtual
|
||||
void ThrowingTestReporter::ReportTestFinish(TestDetails const& test, float secondsElapsed)
|
||||
{
|
||||
if(m_decoratedReporter) m_decoratedReporter->ReportTestFinish(test, secondsElapsed);
|
||||
}
|
||||
//virtual
|
||||
void ThrowingTestReporter::ReportTestFinish(TestDetails const& test, float secondsElapsed)
|
||||
{
|
||||
if(m_decoratedReporter) m_decoratedReporter->ReportTestFinish(test, secondsElapsed);
|
||||
}
|
||||
|
||||
//virtual
|
||||
void ThrowingTestReporter::ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed)
|
||||
{
|
||||
if(m_decoratedReporter) m_decoratedReporter->ReportSummary(totalTestCount, failedTestCount, failureCount, secondsElapsed);
|
||||
}
|
||||
//virtual
|
||||
void ThrowingTestReporter::ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed)
|
||||
{
|
||||
if(m_decoratedReporter) m_decoratedReporter->ReportSummary(totalTestCount, failedTestCount, failureCount, secondsElapsed);
|
||||
}
|
||||
|
||||
TestReporter* ThrowingTestReporter::getDecorated() const
|
||||
{
|
||||
return m_decoratedReporter;
|
||||
}
|
||||
TestReporter* ThrowingTestReporter::getDecorated() const
|
||||
{
|
||||
return m_decoratedReporter;
|
||||
}
|
||||
|
||||
void ThrowingTestReporter::setDecorated(TestReporter* reporter)
|
||||
{
|
||||
m_decoratedReporter = reporter;
|
||||
}
|
||||
void ThrowingTestReporter::setDecorated(TestReporter* reporter)
|
||||
{
|
||||
m_decoratedReporter = reporter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,25 +5,25 @@
|
|||
|
||||
namespace UnitTest {
|
||||
|
||||
// A TestReporter that throws when ReportFailure is called. Otherwise it
|
||||
// forwards the calls to a decorated TestReporter
|
||||
class ThrowingTestReporter : public TestReporter
|
||||
{
|
||||
public:
|
||||
explicit ThrowingTestReporter(TestReporter* reporter);
|
||||
// A TestReporter that throws when ReportFailure is called. Otherwise it
|
||||
// forwards the calls to a decorated TestReporter
|
||||
class ThrowingTestReporter : public TestReporter
|
||||
{
|
||||
public:
|
||||
explicit ThrowingTestReporter(TestReporter* reporter);
|
||||
|
||||
virtual ~ThrowingTestReporter();
|
||||
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);
|
||||
virtual ~ThrowingTestReporter();
|
||||
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);
|
||||
|
||||
TestReporter* getDecorated() const;
|
||||
void setDecorated(TestReporter* reporter);
|
||||
TestReporter* getDecorated() const;
|
||||
void setDecorated(TestReporter* reporter);
|
||||
|
||||
private:
|
||||
TestReporter* m_decoratedReporter;
|
||||
};
|
||||
private:
|
||||
TestReporter* m_decoratedReporter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue