From 74ca0c301f84abd7833dc9c927261e05ee04b276 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Thu, 4 Feb 2016 21:16:45 -0600 Subject: [PATCH] Merge and uncrustify. --- UnitTest++/CheckMacros.h | 54 +- UnitTest++/RequireMacros.h | 4 +- UnitTest++/RequiredCheckTestReporter.cpp | 38 +- UnitTest++/RequiredCheckTestReporter.h | 30 +- UnitTest++/TestResults.h | 6 +- UnitTest++/ThrowingTestReporter.cpp | 72 +- UnitTest++/ThrowingTestReporter.h | 32 +- tests/TestRequireMacros.cpp | 1394 +++++++++++----------- 8 files changed, 804 insertions(+), 826 deletions(-) diff --git a/UnitTest++/CheckMacros.h b/UnitTest++/CheckMacros.h index 96b98ba..82a4042 100644 --- a/UnitTest++/CheckMacros.h +++ b/UnitTest++/CheckMacros.h @@ -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; \ diff --git a/UnitTest++/RequireMacros.h b/UnitTest++/RequireMacros.h index 9fee8eb..4a107d4 100644 --- a/UnitTest++/RequireMacros.h +++ b/UnitTest++/RequireMacros.h @@ -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 \ No newline at end of file diff --git a/UnitTest++/RequiredCheckTestReporter.cpp b/UnitTest++/RequiredCheckTestReporter.cpp index cae20db..1fd2ec7 100644 --- a/UnitTest++/RequiredCheckTestReporter.cpp +++ b/UnitTest++/RequiredCheckTestReporter.cpp @@ -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; + } } \ No newline at end of file diff --git a/UnitTest++/RequiredCheckTestReporter.h b/UnitTest++/RequiredCheckTestReporter.h index 22613e9..a8c635e 100644 --- a/UnitTest++/RequiredCheckTestReporter.h +++ b/UnitTest++/RequiredCheckTestReporter.h @@ -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 diff --git a/UnitTest++/TestResults.h b/UnitTest++/TestResults.h index 024ace3..b23418c 100644 --- a/UnitTest++/TestResults.h +++ b/UnitTest++/TestResults.h @@ -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; diff --git a/UnitTest++/ThrowingTestReporter.cpp b/UnitTest++/ThrowingTestReporter.cpp index 45ccade..367a8b3 100644 --- a/UnitTest++/ThrowingTestReporter.cpp +++ b/UnitTest++/ThrowingTestReporter.cpp @@ -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; + } } diff --git a/UnitTest++/ThrowingTestReporter.h b/UnitTest++/ThrowingTestReporter.h index 0a02a51..8ed91da 100644 --- a/UnitTest++/ThrowingTestReporter.h +++ b/UnitTest++/ThrowingTestReporter.h @@ -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 diff --git a/tests/TestRequireMacros.cpp b/tests/TestRequireMacros.cpp index 46732a2..88cb128 100644 --- a/tests/TestRequireMacros.cpp +++ b/tests/TestRequireMacros.cpp @@ -9,865 +9,845 @@ using namespace std; namespace { -TEST(RequireCheckSucceedsOnTrue) -{ - bool failure = true; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); + TEST(RequireCheckSucceedsOnTrue) + { + bool failure = true; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); - - try - { + ScopedCurrentTest scopedResults(testResults); + + try + { REQUIRE CHECK(true); - } - catch(const UnitTest::AssertException&) - { + } + catch(const UnitTest::AssertException&) + { exception = true; - } - - failure = (testResults.GetFailureCount() > 0); - } + } - CHECK(!failure); - CHECK(!exception); -} + failure = (testResults.GetFailureCount() > 0); + } -TEST(RequiredCheckFailsOnFalse) -{ - bool failure = false; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); - - try - { + CHECK(!failure); + CHECK(!exception); + } + + TEST(RequiredCheckFailsOnFalse) + { + bool failure = false; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + try + { REQUIRE CHECK(false); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } - - failure = (testResults.GetFailureCount() > 0); - } + } - CHECK(failure); - CHECK(exception); -} + failure = (testResults.GetFailureCount() > 0); + } - -TEST(RequireMacroSupportsMultipleChecks) -{ - bool failure = false; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); - - try{ + CHECK(failure); + CHECK(exception); + } + + + TEST(RequireMacroSupportsMultipleChecks) + { + bool failure = false; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + try{ REQUIRE { - CHECK(true); - CHECK_EQUAL(1,1); + CHECK(true); + CHECK_EQUAL(1,1); } - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } - - failure = (testResults.GetFailureCount() > 0); - } - - CHECK(!failure); - CHECK(!exception); -} + } + + failure = (testResults.GetFailureCount() > 0); + } + + CHECK(!failure); + CHECK(!exception); + } -TEST(RequireMacroSupportsMultipleChecksWithFailingChecks) -{ - bool failure = false; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); - - try{ + TEST(RequireMacroSupportsMultipleChecksWithFailingChecks) + { + bool failure = false; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + try{ REQUIRE { - CHECK(true); - CHECK_EQUAL(1,2); + CHECK(true); + CHECK_EQUAL(1,2); } - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } - - failure = (testResults.GetFailureCount() > 0); - } - - CHECK(failure); - CHECK(exception); -} + } -TEST(RequireMacroDoesntExecuteCodeAfterAFailingCheck) -{ - bool failure = false; - bool exception = false; - bool run = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + failure = (testResults.GetFailureCount() > 0); + } - try{ + CHECK(failure); + CHECK(exception); + } + + TEST(RequireMacroDoesntExecuteCodeAfterAFailingCheck) + { + bool failure = false; + bool exception = false; + bool run = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + try{ REQUIRE { - CHECK(false); - run = true; // this shouldn't get executed. + CHECK(false); + run = true; // this shouldn't get executed. } - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } + } - failure = (testResults.GetFailureCount() > 0); - } - - CHECK(failure); - CHECK(exception); - CHECK(!run); -} + failure = (testResults.GetFailureCount() > 0); + } -TEST(FailureReportsCorrectTestName) -{ - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); - - try - { + CHECK(failure); + CHECK(exception); + CHECK(!run); + } + + TEST(FailureReportsCorrectTestName) + { + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + try + { REQUIRE CHECK(false); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK_EQUAL(m_details.testName, reporter.lastFailedTest); -} + CHECK_EQUAL(m_details.testName, reporter.lastFailedTest); + } -TEST(RequiredCheckFailureIncludesCheckContents) -{ - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); - const bool yaddayadda = false; - - try - { + TEST(RequiredCheckFailureIncludesCheckContents) + { + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + const bool yaddayadda = false; + + try + { REQUIRE CHECK(yaddayadda); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK(strstr(reporter.lastFailedMessage, "yaddayadda")); -} + CHECK(strstr(reporter.lastFailedMessage, "yaddayadda")); + } -TEST(RequiredCheckEqualSucceedsOnEqual) -{ - bool failure = true; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); - - try - { + TEST(RequiredCheckEqualSucceedsOnEqual) + { + bool failure = true; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + try + { REQUIRE CHECK_EQUAL(1,1); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } + } - failure = (testResults.GetFailureCount() > 0); - } + failure = (testResults.GetFailureCount() > 0); + } - CHECK(!failure); - CHECK(!exception); -} + CHECK(!failure); + CHECK(!exception); + } -TEST(RequiredCheckEqualFailsOnNotEqual) -{ - bool failure = false; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckEqualFailsOnNotEqual) + { + bool failure = false; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); - try - { + try + { REQUIRE CHECK_EQUAL(1, 2); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } + } - failure = (testResults.GetFailureCount() > 0); - } + failure = (testResults.GetFailureCount() > 0); + } - CHECK(failure); - CHECK(exception); -} + CHECK(failure); + CHECK(exception); + } -TEST(RequiredCheckEqualFailureContainsCorrectDetails) -{ - int line = 0; - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - UnitTest::TestDetails const testDetails("testName", "suiteName", "filename", -1); - ScopedCurrentTest scopedResults(testResults, &testDetails); + TEST(RequiredCheckEqualFailureContainsCorrectDetails) + { + int line = 0; + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + UnitTest::TestDetails const testDetails("testName", "suiteName", "filename", -1); + ScopedCurrentTest scopedResults(testResults, &testDetails); - try - { + try + { line = __LINE__; REQUIRE CHECK_EQUAL(1, 123); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK_EQUAL("testName", reporter.lastFailedTest); - CHECK_EQUAL("suiteName", reporter.lastFailedSuite); - CHECK_EQUAL("filename", reporter.lastFailedFile); - CHECK_EQUAL(line, reporter.lastFailedLine); -} + CHECK_EQUAL("testName", reporter.lastFailedTest); + CHECK_EQUAL("suiteName", reporter.lastFailedSuite); + CHECK_EQUAL("filename", reporter.lastFailedFile); + CHECK_EQUAL(line, reporter.lastFailedLine); + } -int g_sideEffect = 0; -int FunctionWithSideEffects() -{ - ++g_sideEffect; - return 1; -} + int g_sideEffect = 0; + int FunctionWithSideEffects() + { + ++g_sideEffect; + return 1; + } -TEST(RequiredCheckEqualDoesNotHaveSideEffectsWhenPassing) -{ - g_sideEffect = 0; - { - UnitTest::TestResults testResults; - ScopedCurrentTest scopedResults(testResults); - - try - { + TEST(RequiredCheckEqualDoesNotHaveSideEffectsWhenPassing) + { + g_sideEffect = 0; + { + UnitTest::TestResults testResults; + ScopedCurrentTest scopedResults(testResults); + + try + { REQUIRE CHECK_EQUAL(1, FunctionWithSideEffects()); - } - catch (const UnitTest::AssertException&) - { - } - } - CHECK_EQUAL(1, g_sideEffect); -} + } + catch (const UnitTest::AssertException&) + {} + } + CHECK_EQUAL(1, g_sideEffect); + } -TEST(RequiredCheckEqualDoesNotHaveSideEffectsWhenFailing) -{ - g_sideEffect = 0; - { - UnitTest::TestResults testResults; - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckEqualDoesNotHaveSideEffectsWhenFailing) + { + g_sideEffect = 0; + { + UnitTest::TestResults testResults; + ScopedCurrentTest scopedResults(testResults); - try - { + try + { REQUIRE CHECK_EQUAL(2, FunctionWithSideEffects()); - } - catch (const UnitTest::AssertException&) - { - } - } - CHECK_EQUAL(1, g_sideEffect); -} + } + catch (const UnitTest::AssertException&) + {} + } + CHECK_EQUAL(1, g_sideEffect); + } -TEST(RequiredCheckCloseSucceedsOnEqual) -{ - bool failure = true; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckCloseSucceedsOnEqual) + { + bool failure = true; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); - try - { + try + { REQUIRE CHECK_CLOSE(1.0f, 1.001f, 0.01f); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } + } - failure = (testResults.GetFailureCount() > 0); - } + failure = (testResults.GetFailureCount() > 0); + } - CHECK(!failure); - CHECK(!exception); -} + CHECK(!failure); + CHECK(!exception); + } -TEST(RequiredCheckCloseFailsOnNotEqual) -{ - bool failure = false; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); - - try - { + TEST(RequiredCheckCloseFailsOnNotEqual) + { + bool failure = false; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + try + { REQUIRE CHECK_CLOSE (1.0f, 1.1f, 0.01f); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } - - failure = (testResults.GetFailureCount() > 0); - } + } - CHECK(failure); - CHECK(exception); -} + failure = (testResults.GetFailureCount() > 0); + } -TEST(RequiredCheckCloseFailureContainsCorrectDetails) -{ - int line = 0; - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - UnitTest::TestDetails testDetails("test", "suite", "filename", -1); - ScopedCurrentTest scopedResults(testResults, &testDetails); + CHECK(failure); + CHECK(exception); + } - try - { + TEST(RequiredCheckCloseFailureContainsCorrectDetails) + { + int line = 0; + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + UnitTest::TestDetails testDetails("test", "suite", "filename", -1); + ScopedCurrentTest scopedResults(testResults, &testDetails); + + try + { line = __LINE__; REQUIRE CHECK_CLOSE(1.0f, 1.1f, 0.01f); CHECK(false); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK_EQUAL("test", reporter.lastFailedTest); - CHECK_EQUAL("suite", reporter.lastFailedSuite); - CHECK_EQUAL("filename", reporter.lastFailedFile); - CHECK_EQUAL(line, reporter.lastFailedLine); -} + CHECK_EQUAL("test", reporter.lastFailedTest); + CHECK_EQUAL("suite", reporter.lastFailedSuite); + CHECK_EQUAL("filename", reporter.lastFailedFile); + CHECK_EQUAL(line, reporter.lastFailedLine); + } -TEST(RequiredCheckCloseDoesNotHaveSideEffectsWhenPassing) -{ - g_sideEffect = 0; - { - UnitTest::TestResults testResults; - ScopedCurrentTest scopedResults(testResults); - - try - { + TEST(RequiredCheckCloseDoesNotHaveSideEffectsWhenPassing) + { + g_sideEffect = 0; + { + UnitTest::TestResults testResults; + ScopedCurrentTest scopedResults(testResults); + + try + { REQUIRE CHECK_CLOSE (1, FunctionWithSideEffects(), 0.1f); - } - catch (const UnitTest::AssertException&) - { - } - } - CHECK_EQUAL(1, g_sideEffect); -} + } + catch (const UnitTest::AssertException&) + {} + } + CHECK_EQUAL(1, g_sideEffect); + } -TEST(RequiredCheckCloseDoesNotHaveSideEffectsWhenFailing) -{ - g_sideEffect = 0; - { - UnitTest::TestResults testResults; - ScopedCurrentTest scopedResults(testResults); - - try - { + TEST(RequiredCheckCloseDoesNotHaveSideEffectsWhenFailing) + { + g_sideEffect = 0; + { + UnitTest::TestResults testResults; + ScopedCurrentTest scopedResults(testResults); + + try + { REQUIRE CHECK_CLOSE(2, FunctionWithSideEffects(), 0.1f); - } - catch (const UnitTest::AssertException&) - { - } - } - CHECK_EQUAL(1, g_sideEffect); -} + } + catch (const UnitTest::AssertException&) + {} + } + CHECK_EQUAL(1, g_sideEffect); + } -TEST(RequiredCheckArrayCloseSucceedsOnEqual) -{ - bool failure = true; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); - const float data[4] = { 0, 1, 2, 3 }; - - try - { + TEST(RequiredCheckArrayCloseSucceedsOnEqual) + { + bool failure = true; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + const float data[4] = { 0, 1, 2, 3 }; + + try + { REQUIRE CHECK_ARRAY_CLOSE (data, data, 4, 0.01f); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } - - failure = (testResults.GetFailureCount() > 0); - } + } - CHECK(!failure); - CHECK(!exception); -} + failure = (testResults.GetFailureCount() > 0); + } -TEST(RequiredCheckArrayCloseFailsOnNotEqual) -{ - bool failure = false; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + CHECK(!failure); + CHECK(!exception); + } - int const data1[4] = { 0, 1, 2, 3 }; - int const data2[4] = { 0, 1, 3, 3 }; - - try - { + TEST(RequiredCheckArrayCloseFailsOnNotEqual) + { + bool failure = false; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + int const data1[4] = { 0, 1, 2, 3 }; + int const data2[4] = { 0, 1, 3, 3 }; + + try + { REQUIRE CHECK_ARRAY_CLOSE (data1, data2, 4, 0.01f); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } + } - failure = (testResults.GetFailureCount() > 0); - } + failure = (testResults.GetFailureCount() > 0); + } - CHECK(failure); - CHECK(exception); -} + CHECK(failure); + CHECK(exception); + } -TEST(RequiredCheckArrayCloseFailureIncludesCheckExpectedAndActual) -{ - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArrayCloseFailureIncludesCheckExpectedAndActual) + { + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); - int const data1[4] = { 0, 1, 2, 3 }; - int const data2[4] = { 0, 1, 3, 3 }; - - try - { + int const data1[4] = { 0, 1, 2, 3 }; + int const data2[4] = { 0, 1, 3, 3 }; + + try + { REQUIRE CHECK_ARRAY_CLOSE(data1, data2, 4, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK(strstr(reporter.lastFailedMessage, "xpected [ 0 1 2 3 ]")); - CHECK(strstr(reporter.lastFailedMessage, "was [ 0 1 3 3 ]")); -} + CHECK(strstr(reporter.lastFailedMessage, "xpected [ 0 1 2 3 ]")); + CHECK(strstr(reporter.lastFailedMessage, "was [ 0 1 3 3 ]")); + } -TEST(RequiredCheckArrayCloseFailureContainsCorrectDetails) -{ - int line = 0; - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - UnitTest::TestDetails testDetails("arrayCloseTest", "arrayCloseSuite", "filename", -1); - ScopedCurrentTest scopedResults(testResults, &testDetails); + TEST(RequiredCheckArrayCloseFailureContainsCorrectDetails) + { + int line = 0; + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + UnitTest::TestDetails testDetails("arrayCloseTest", "arrayCloseSuite", "filename", -1); + ScopedCurrentTest scopedResults(testResults, &testDetails); - int const data1[4] = { 0, 1, 2, 3 }; - int const data2[4] = { 0, 1, 3, 3 }; - - try - { + int const data1[4] = { 0, 1, 2, 3 }; + int const data2[4] = { 0, 1, 3, 3 }; + + try + { line = __LINE__; REQUIRE CHECK_ARRAY_CLOSE (data1, data2, 4, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK_EQUAL("arrayCloseTest", reporter.lastFailedTest); - CHECK_EQUAL("arrayCloseSuite", reporter.lastFailedSuite); - CHECK_EQUAL("filename", reporter.lastFailedFile); - CHECK_EQUAL(line, reporter.lastFailedLine); -} + CHECK_EQUAL("arrayCloseTest", reporter.lastFailedTest); + CHECK_EQUAL("arrayCloseSuite", reporter.lastFailedSuite); + CHECK_EQUAL("filename", reporter.lastFailedFile); + CHECK_EQUAL(line, reporter.lastFailedLine); + } -TEST(RequiredCheckArrayCloseFailureIncludesTolerance) -{ - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArrayCloseFailureIncludesTolerance) + { + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); - float const data1[4] = { 0, 1, 2, 3 }; - float const data2[4] = { 0, 1, 3, 3 }; - - try - { + float const data1[4] = { 0, 1, 2, 3 }; + float const data2[4] = { 0, 1, 3, 3 }; + + try + { REQUIRE CHECK_ARRAY_CLOSE (data1, data2, 4, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK(strstr(reporter.lastFailedMessage, "0.01")); -} + CHECK(strstr(reporter.lastFailedMessage, "0.01")); + } -TEST(RequiredCheckArrayEqualSuceedsOnEqual) -{ - bool failure = true; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArrayEqualSuceedsOnEqual) + { + bool failure = true; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); - const float data[4] = { 0, 1, 2, 3 }; - - try - { + const float data[4] = { 0, 1, 2, 3 }; + + try + { REQUIRE CHECK_ARRAY_EQUAL (data, data, 4); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } - - failure = (testResults.GetFailureCount() > 0); - } + } - CHECK(!failure); - CHECK(!exception); -} + failure = (testResults.GetFailureCount() > 0); + } -TEST(RequiredCheckArrayEqualFailsOnNotEqual) -{ - bool failure = false; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + CHECK(!failure); + CHECK(!exception); + } - int const data1[4] = { 0, 1, 2, 3 }; - int const data2[4] = { 0, 1, 3, 3 }; - - try - { + TEST(RequiredCheckArrayEqualFailsOnNotEqual) + { + bool failure = false; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + int const data1[4] = { 0, 1, 2, 3 }; + int const data2[4] = { 0, 1, 3, 3 }; + + try + { REQUIRE CHECK_ARRAY_EQUAL (data1, data2, 4); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } - - failure = (testResults.GetFailureCount() > 0); - } + } - CHECK(failure); - CHECK(exception); -} + failure = (testResults.GetFailureCount() > 0); + } -TEST(RequiredCheckArrayEqualFailureIncludesCheckExpectedAndActual) -{ - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + CHECK(failure); + CHECK(exception); + } - int const data1[4] = { 0, 1, 2, 3 }; - int const data2[4] = { 0, 1, 3, 3 }; - - try - { + TEST(RequiredCheckArrayEqualFailureIncludesCheckExpectedAndActual) + { + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + int const data1[4] = { 0, 1, 2, 3 }; + int const data2[4] = { 0, 1, 3, 3 }; + + try + { REQUIRE CHECK_ARRAY_EQUAL (data1, data2, 4); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK(strstr(reporter.lastFailedMessage, "xpected [ 0 1 2 3 ]")); - CHECK(strstr(reporter.lastFailedMessage, "was [ 0 1 3 3 ]")); -} + CHECK(strstr(reporter.lastFailedMessage, "xpected [ 0 1 2 3 ]")); + CHECK(strstr(reporter.lastFailedMessage, "was [ 0 1 3 3 ]")); + } -TEST(RequiredCheckArrayEqualFailureContainsCorrectInfo) -{ - int line = 0; - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArrayEqualFailureContainsCorrectInfo) + { + int line = 0; + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); - int const data1[4] = { 0, 1, 2, 3 }; - int const data2[4] = { 0, 1, 3, 3 }; - - try - { + int const data1[4] = { 0, 1, 2, 3 }; + int const data2[4] = { 0, 1, 3, 3 }; + + try + { line = __LINE__; REQUIRE CHECK_ARRAY_EQUAL (data1, data2, 4); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK_EQUAL("RequiredCheckArrayEqualFailureContainsCorrectInfo", reporter.lastFailedTest); - CHECK_EQUAL(__FILE__, reporter.lastFailedFile); - CHECK_EQUAL(line, reporter.lastFailedLine); -} + CHECK_EQUAL("RequiredCheckArrayEqualFailureContainsCorrectInfo", reporter.lastFailedTest); + CHECK_EQUAL(__FILE__, reporter.lastFailedFile); + CHECK_EQUAL(line, reporter.lastFailedLine); + } -float const* FunctionWithSideEffects2() -{ - ++g_sideEffect; - static float const data[] = {1,2,3,4}; - return data; -} + float const* FunctionWithSideEffects2() + { + ++g_sideEffect; + static float const data[] = {1,2,3,4}; + return data; + } -TEST(RequiredCheckArrayCloseDoesNotHaveSideEffectsWhenPassing) -{ - g_sideEffect = 0; - { - UnitTest::TestResults testResults; - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArrayCloseDoesNotHaveSideEffectsWhenPassing) + { + g_sideEffect = 0; + { + UnitTest::TestResults testResults; + ScopedCurrentTest scopedResults(testResults); - const float data[] = { 0, 1, 2, 3 }; - - try - { + const float data[] = { 0, 1, 2, 3 }; + + try + { REQUIRE CHECK_ARRAY_CLOSE (data, FunctionWithSideEffects2(), 4, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } - CHECK_EQUAL(1, g_sideEffect); -} + } + catch (const UnitTest::AssertException&) + {} + } + CHECK_EQUAL(1, g_sideEffect); + } -TEST(RequiredCheckArrayCloseDoesNotHaveSideEffectsWhenFailing) -{ - g_sideEffect = 0; - { - UnitTest::TestResults testResults; - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArrayCloseDoesNotHaveSideEffectsWhenFailing) + { + g_sideEffect = 0; + { + UnitTest::TestResults testResults; + ScopedCurrentTest scopedResults(testResults); - const float data[] = { 0, 1, 3, 3 }; - - try - { + const float data[] = { 0, 1, 3, 3 }; + + try + { REQUIRE CHECK_ARRAY_CLOSE (data, FunctionWithSideEffects2(), 4, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK_EQUAL(1, g_sideEffect); -} + CHECK_EQUAL(1, g_sideEffect); + } -TEST(RequiredCheckArray2DCloseSucceedsOnEqual) -{ - bool failure = true; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArray2DCloseSucceedsOnEqual) + { + bool failure = true; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); - const float data[2][2] = { {0, 1}, {2, 3} }; - - try - { + const float data[2][2] = { {0, 1}, {2, 3} }; + + try + { REQUIRE CHECK_ARRAY2D_CLOSE(data, data, 2, 2, 0.01f); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } - - failure = (testResults.GetFailureCount() > 0); - } + } - CHECK(!failure); - CHECK(!exception); -} + failure = (testResults.GetFailureCount() > 0); + } -TEST(RequiredCheckArray2DCloseFailsOnNotEqual) -{ - bool failure = false; - bool exception = false; - { - RecordingReporter reporter; - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + CHECK(!failure); + CHECK(!exception); + } - int const data1[2][2] = { {0, 1}, {2, 3} }; - int const data2[2][2] = { {0, 1}, {3, 3} }; - - try - { + TEST(RequiredCheckArray2DCloseFailsOnNotEqual) + { + bool failure = false; + bool exception = false; + { + RecordingReporter reporter; + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); + + int const data1[2][2] = { {0, 1}, {2, 3} }; + int const data2[2][2] = { {0, 1}, {3, 3} }; + + try + { REQUIRE CHECK_ARRAY2D_CLOSE (data1, data2, 2, 2, 0.01f); - } - catch (const UnitTest::AssertException&) - { + } + catch (const UnitTest::AssertException&) + { exception = true; - } + } - failure = (testResults.GetFailureCount() > 0); - } + failure = (testResults.GetFailureCount() > 0); + } - CHECK(failure); - CHECK(exception); -} + CHECK(failure); + CHECK(exception); + } -TEST(RequiredCheckArray2DCloseFailureIncludesCheckExpectedAndActual) -{ - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArray2DCloseFailureIncludesCheckExpectedAndActual) + { + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); - int const data1[2][2] = { {0, 1}, {2, 3} }; - int const data2[2][2] = { {0, 1}, {3, 3} }; + int const data1[2][2] = { {0, 1}, {2, 3} }; + int const data2[2][2] = { {0, 1}, {3, 3} }; - try - { + try + { REQUIRE CHECK_ARRAY2D_CLOSE (data1, data2, 2, 2, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK(strstr(reporter.lastFailedMessage, "xpected [ [ 0 1 ] [ 2 3 ] ]")); - CHECK(strstr(reporter.lastFailedMessage, "was [ [ 0 1 ] [ 3 3 ] ]")); -} + CHECK(strstr(reporter.lastFailedMessage, "xpected [ [ 0 1 ] [ 2 3 ] ]")); + CHECK(strstr(reporter.lastFailedMessage, "was [ [ 0 1 ] [ 3 3 ] ]")); + } -TEST(RequiredCheckArray2DCloseFailureContainsCorrectDetails) -{ - int line = 0; - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - UnitTest::TestDetails testDetails("array2DCloseTest", "array2DCloseSuite", "filename", -1); - ScopedCurrentTest scopedResults(testResults, &testDetails); + TEST(RequiredCheckArray2DCloseFailureContainsCorrectDetails) + { + int line = 0; + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + UnitTest::TestDetails testDetails("array2DCloseTest", "array2DCloseSuite", "filename", -1); + ScopedCurrentTest scopedResults(testResults, &testDetails); - int const data1[2][2] = { {0, 1}, {2, 3} }; - int const data2[2][2] = { {0, 1}, {3, 3} }; - - try - { + int const data1[2][2] = { {0, 1}, {2, 3} }; + int const data2[2][2] = { {0, 1}, {3, 3} }; + + try + { line = __LINE__; REQUIRE CHECK_ARRAY2D_CLOSE (data1, data2, 2, 2, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK_EQUAL("array2DCloseTest", reporter.lastFailedTest); - CHECK_EQUAL("array2DCloseSuite", reporter.lastFailedSuite); - CHECK_EQUAL("filename", reporter.lastFailedFile); - CHECK_EQUAL(line, reporter.lastFailedLine); -} + CHECK_EQUAL("array2DCloseTest", reporter.lastFailedTest); + CHECK_EQUAL("array2DCloseSuite", reporter.lastFailedSuite); + CHECK_EQUAL("filename", reporter.lastFailedFile); + CHECK_EQUAL(line, reporter.lastFailedLine); + } -TEST(RequiredCheckArray2DCloseFailureIncludesTolerance) -{ - RecordingReporter reporter; - { - UnitTest::TestResults testResults(&reporter); - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArray2DCloseFailureIncludesTolerance) + { + RecordingReporter reporter; + { + UnitTest::TestResults testResults(&reporter); + ScopedCurrentTest scopedResults(testResults); - float const data1[2][2] = { {0, 1}, {2, 3} }; - float const data2[2][2] = { {0, 1}, {3, 3} }; - - try - { + float const data1[2][2] = { {0, 1}, {2, 3} }; + float const data2[2][2] = { {0, 1}, {3, 3} }; + + try + { REQUIRE CHECK_ARRAY2D_CLOSE (data1, data2, 2, 2, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } + } + catch (const UnitTest::AssertException&) + {} + } - CHECK(strstr(reporter.lastFailedMessage, "0.01")); -} + CHECK(strstr(reporter.lastFailedMessage, "0.01")); + } -float const* const* FunctionWithSideEffects3() -{ - ++g_sideEffect; - static float const data1[] = {0,1}; - static float const data2[] = {2,3}; - static const float* const data[] = {data1, data2}; - return data; -} + float const* const* FunctionWithSideEffects3() + { + ++g_sideEffect; + static float const data1[] = {0,1}; + static float const data2[] = {2,3}; + static const float* const data[] = {data1, data2}; + return data; + } -TEST(RequiredCheckArray2DCloseDoesNotHaveSideEffectsWhenPassing) -{ - g_sideEffect = 0; - { - UnitTest::TestResults testResults; - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArray2DCloseDoesNotHaveSideEffectsWhenPassing) + { + g_sideEffect = 0; + { + UnitTest::TestResults testResults; + ScopedCurrentTest scopedResults(testResults); - const float data[2][2] = { {0, 1}, {2, 3} }; - - try - { + const float data[2][2] = { {0, 1}, {2, 3} }; + + try + { REQUIRE CHECK_ARRAY2D_CLOSE (data, FunctionWithSideEffects3(), 2, 2, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } - CHECK_EQUAL(1, g_sideEffect); -} + } + catch (const UnitTest::AssertException&) + {} + } + CHECK_EQUAL(1, g_sideEffect); + } -TEST(RequiredCheckArray2DCloseDoesNotHaveSideEffectsWhenFailing) -{ - g_sideEffect = 0; - { - UnitTest::TestResults testResults; - ScopedCurrentTest scopedResults(testResults); + TEST(RequiredCheckArray2DCloseDoesNotHaveSideEffectsWhenFailing) + { + g_sideEffect = 0; + { + UnitTest::TestResults testResults; + ScopedCurrentTest scopedResults(testResults); - const float data[2][2] = { {0, 1}, {3, 3} }; - - try - { + const float data[2][2] = { {0, 1}, {3, 3} }; + + try + { REQUIRE CHECK_ARRAY2D_CLOSE (data, FunctionWithSideEffects3(), 2, 2, 0.01f); - } - catch (const UnitTest::AssertException&) - { - } - } - CHECK_EQUAL(1, g_sideEffect); -} + } + catch (const UnitTest::AssertException&) + {} + } + CHECK_EQUAL(1, g_sideEffect); + } }