From 185b3d5086d4e369bdb7da23abfda23bd248866f Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Fri, 6 May 2016 23:44:02 -0500 Subject: [PATCH 01/45] Add UNITTEST_ versions of all CHECK macros UNITTEST_ now prefixes the implementation of all CHECK macros. Additionally, the build option UNITTEST_ENABLE_SHORT_MACROS can be shut off, disabling the creation of the existing short forms. This is helpful for users who may have conflicts with their projects or other libs. --- UnitTest++/CheckMacros.h | 92 ++++++++++++++++++++++++++-------------- UnitTest++/Config.h | 8 +++- 2 files changed, 67 insertions(+), 33 deletions(-) diff --git a/UnitTest++/CheckMacros.h b/UnitTest++/CheckMacros.h index e9dae64..b5c6858 100644 --- a/UnitTest++/CheckMacros.h +++ b/UnitTest++/CheckMacros.h @@ -11,31 +11,7 @@ #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) \ +#define UNITTEST_CHECK(value) \ UNITTEST_MULTILINE_MACRO_BEGIN \ UT_TRY \ ({ \ @@ -57,7 +33,7 @@ }) \ UNITTEST_MULTILINE_MACRO_END -#define CHECK_EQUAL(expected, actual) \ +#define UNITTEST_CHECK_EQUAL(expected, actual) \ UNITTEST_MULTILINE_MACRO_BEGIN \ UT_TRY \ ({ \ @@ -78,7 +54,7 @@ }) \ UNITTEST_MULTILINE_MACRO_END -#define CHECK_CLOSE(expected, actual, tolerance) \ +#define UNITTEST_CHECK_CLOSE(expected, actual, tolerance) \ UNITTEST_MULTILINE_MACRO_BEGIN \ UT_TRY \ ({ \ @@ -99,7 +75,7 @@ }) \ UNITTEST_MULTILINE_MACRO_END -#define CHECK_ARRAY_EQUAL(expected, actual, count) \ +#define UNITTEST_CHECK_ARRAY_EQUAL(expected, actual, count) \ UNITTEST_MULTILINE_MACRO_BEGIN \ UT_TRY \ ({ \ @@ -120,7 +96,7 @@ }) \ UNITTEST_MULTILINE_MACRO_END -#define CHECK_ARRAY_CLOSE(expected, actual, count, tolerance) \ +#define UNITTEST_CHECK_ARRAY_CLOSE(expected, actual, count, tolerance) \ UNITTEST_MULTILINE_MACRO_BEGIN \ UT_TRY \ ({ \ @@ -141,7 +117,7 @@ }) \ UNITTEST_MULTILINE_MACRO_END -#define CHECK_ARRAY2D_CLOSE(expected, actual, rows, columns, tolerance) \ +#define UNITTEST_CHECK_ARRAY2D_CLOSE(expected, actual, rows, columns, tolerance) \ UNITTEST_MULTILINE_MACRO_BEGIN \ UT_TRY \ ({ \ @@ -162,11 +138,48 @@ }) \ UNITTEST_MULTILINE_MACRO_END +#if UNITTEST_ENABLE_SHORT_MACROS + #ifdef CHECK + #error CHECK already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK instead + #else + #define CHECK UNITTEST_CHECK + #endif + + #ifdef CHECK_EQUAL + #error CHECK_EQUAL already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_EQUAL instead + #else + #define CHECK_EQUAL UNITTEST_CHECK_EQUAL + #endif + + #ifdef CHECK_CLOSE + #error CHECK_CLOSE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_CLOSE instead + #else + #define CHECK_CLOSE UNITTEST_CHECK_CLOSE + #endif + + #ifdef CHECK_ARRAY_EQUAL + #error CHECK_ARRAY_EQUAL already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_ARRAY_EQUAL instead + #else + #define CHECK_ARRAY_EQUAL UNITTEST_CHECK_ARRAY_EQUAL + #endif + + #ifdef CHECK_ARRAY_CLOSE + #error CHECK_ARRAY_CLOSE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_ARRAY_CLOSE instead + #else + #define CHECK_ARRAY_CLOSE UNITTEST_CHECK_ARRAY_CLOSE + #endif + + #ifdef CHECK_ARRAY2D_CLOSE + #error CHECK_ARRAY2D_CLOSE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_ARRAY2D_CLOSE instead + #else + #define CHECK_ARRAY2D_CLOSE UNITTEST_CHECK_ARRAY2D_CLOSE + #endif +#endif // 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) \ +#define UNITTEST_CHECK_THROW(expression, ExpectedExceptionType) \ UNITTEST_MULTILINE_MACRO_BEGIN \ bool caught_ = false; \ try { expression; } \ @@ -177,7 +190,7 @@ UNITTEST_MULTILINE_MACRO_END -#define CHECK_ASSERT(expression) \ +#define UNITTEST_CHECK_ASSERT(expression) \ UNITTEST_MULTILINE_MACRO_BEGIN \ UnitTest::Detail::ExpectAssert(true); \ CHECK_THROW(expression, UnitTest::AssertException); \ @@ -185,4 +198,19 @@ UNITTEST_MULTILINE_MACRO_END #endif +#if UNITTEST_ENABLE_SHORT_MACROS + #ifdef CHECK_THROW + #error CHECK_THROW already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_THROW instead + #else + #define CHECK_THROW UNITTEST_CHECK_THROW + #endif + + #ifdef CHECK_ASSERT + #error CHECK_ASSERT already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_ASSERT instead + #else + #define CHECK_ASSERT UNITTEST_CHECK_ASSERT + #endif +#endif + #endif + diff --git a/UnitTest++/Config.h b/UnitTest++/Config.h index ff62b4e..f0e23d3 100644 --- a/UnitTest++/Config.h +++ b/UnitTest++/Config.h @@ -16,7 +16,7 @@ #ifdef _USRDLL #define UNITTEST_WIN32_DLL #endif - + #define UNITTEST_WIN32 #endif @@ -71,4 +71,10 @@ #define UNIITEST_NS_QUAL_STD(x) ::std::x #endif +// By default, UnitTest++ will attempt to define "short" macro names like CHECK, CHECK_EQUAL, +// etc. Setting UNITTEST_ENABLE_SHORT_MACROS to 0 will disable this behavior, leaving +// only the longer macros "namespaced" with the UNITTEST_ prefix. + +#define UNITTEST_ENABLE_SHORT_MACROS 1 + #endif From c96bf526136997ff97ef81e8d74b59cc502c6b20 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Fri, 6 May 2016 23:57:59 -0500 Subject: [PATCH 02/45] Replace UT_ macro prefix with UNITTEST_IMPL_ The UT_ prefix was primarily for "internal" macros. This commit seeks to more consistently "namespace" UnitTest++ macros with the UNITTEST_ prefix, while also marking these particular macros as "private" implementation details with the IMPL_ wart. --- UnitTest++/CheckMacros.h | 48 ++++++++++++++++++------------------ UnitTest++/Config.h | 8 +++--- UnitTest++/ExceptionMacros.h | 20 +++++++-------- UnitTest++/ExecuteTest.h | 12 ++++----- UnitTest++/TestMacros.h | 8 +++--- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/UnitTest++/CheckMacros.h b/UnitTest++/CheckMacros.h index b5c6858..bb45964 100644 --- a/UnitTest++/CheckMacros.h +++ b/UnitTest++/CheckMacros.h @@ -13,20 +13,20 @@ #define UNITTEST_CHECK(value) \ UNITTEST_MULTILINE_MACRO_BEGIN \ - UT_TRY \ + UNITTEST_IMPL_TRY \ ({ \ if (!UnitTest::Check(value)) \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \ }) \ - UT_RETHROW (UnitTest::RequiredCheckException) \ - UT_CATCH (std::exception, e, \ + UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \ + UNITTEST_IMPL_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_IMPL_CATCH_ALL \ ({ \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ "Unhandled exception in CHECK(" #value ")"); \ @@ -35,19 +35,19 @@ #define UNITTEST_CHECK_EQUAL(expected, actual) \ UNITTEST_MULTILINE_MACRO_BEGIN \ - UT_TRY \ + UNITTEST_IMPL_TRY \ ({ \ UnitTest::CheckEqual(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ }) \ - UT_RETHROW (UnitTest::RequiredCheckException) \ - UT_CATCH (std::exception, e, \ + UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \ + UNITTEST_IMPL_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_IMPL_CATCH_ALL \ ({ \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ "Unhandled exception in CHECK_EQUAL(" #expected ", " #actual ")"); \ @@ -56,19 +56,19 @@ #define UNITTEST_CHECK_CLOSE(expected, actual, tolerance) \ UNITTEST_MULTILINE_MACRO_BEGIN \ - UT_TRY \ + UNITTEST_IMPL_TRY \ ({ \ UnitTest::CheckClose(*UnitTest::CurrentTest::Results(), expected, actual, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ }) \ - UT_RETHROW (UnitTest::RequiredCheckException) \ - UT_CATCH (std::exception, e, \ + UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \ + UNITTEST_IMPL_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_IMPL_CATCH_ALL \ ({ \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ "Unhandled exception in CHECK_CLOSE(" #expected ", " #actual ")"); \ @@ -77,19 +77,19 @@ #define UNITTEST_CHECK_ARRAY_EQUAL(expected, actual, count) \ UNITTEST_MULTILINE_MACRO_BEGIN \ - UT_TRY \ + UNITTEST_IMPL_TRY \ ({ \ UnitTest::CheckArrayEqual(*UnitTest::CurrentTest::Results(), expected, actual, count, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ }) \ - UT_RETHROW (UnitTest::RequiredCheckException) \ - UT_CATCH (std::exception, e, \ + UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \ + UNITTEST_IMPL_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_IMPL_CATCH_ALL \ ({ \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ "Unhandled exception in CHECK_ARRAY_EQUAL(" #expected ", " #actual ")"); \ @@ -98,19 +98,19 @@ #define UNITTEST_CHECK_ARRAY_CLOSE(expected, actual, count, tolerance) \ UNITTEST_MULTILINE_MACRO_BEGIN \ - UT_TRY \ + UNITTEST_IMPL_TRY \ ({ \ UnitTest::CheckArrayClose(*UnitTest::CurrentTest::Results(), expected, actual, count, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ }) \ - UT_RETHROW (UnitTest::RequiredCheckException) \ - UT_CATCH (std::exception, e, \ + UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \ + UNITTEST_IMPL_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_IMPL_CATCH_ALL \ ({ \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ "Unhandled exception in CHECK_ARRAY_CLOSE(" #expected ", " #actual ")"); \ @@ -119,19 +119,19 @@ #define UNITTEST_CHECK_ARRAY2D_CLOSE(expected, actual, rows, columns, tolerance) \ UNITTEST_MULTILINE_MACRO_BEGIN \ - UT_TRY \ + UNITTEST_IMPL_TRY \ ({ \ UnitTest::CheckArray2DClose(*UnitTest::CurrentTest::Results(), expected, actual, rows, columns, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \ }) \ - UT_RETHROW (UnitTest::RequiredCheckException) \ - UT_CATCH (std::exception, e, \ + UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \ + UNITTEST_IMPL_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_IMPL_CATCH_ALL \ ({ \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ "Unhandled exception in CHECK_ARRAY2D_CLOSE(" #expected ", " #actual ")"); \ diff --git a/UnitTest++/Config.h b/UnitTest++/Config.h index f0e23d3..364fe8d 100644 --- a/UnitTest++/Config.h +++ b/UnitTest++/Config.h @@ -71,10 +71,10 @@ #define UNIITEST_NS_QUAL_STD(x) ::std::x #endif -// By default, UnitTest++ will attempt to define "short" macro names like CHECK, CHECK_EQUAL, -// etc. Setting UNITTEST_ENABLE_SHORT_MACROS to 0 will disable this behavior, leaving -// only the longer macros "namespaced" with the UNITTEST_ prefix. - +// By default, UnitTest++ will attempt to define "short" macro names like CHECK and CHECK_EQUAL +// for "public" interface macros etc. Setting UNITTEST_ENABLE_SHORT_MACROS to 0 will disable +// this behavior, leaving only the longer macros "namespaced" with the UNITTEST_ prefix. +// "Internal" utility macros will only have the UNITTEST_IMPL_ prefix. #define UNITTEST_ENABLE_SHORT_MACROS 1 #endif diff --git a/UnitTest++/ExceptionMacros.h b/UnitTest++/ExceptionMacros.h index c3b1e30..9b2bad4 100644 --- a/UnitTest++/ExceptionMacros.h +++ b/UnitTest++/ExceptionMacros.h @@ -4,17 +4,17 @@ #include "Config.h" #ifndef UNITTEST_NO_EXCEPTIONS - #define UT_TRY(x) try x - #define UT_THROW(x) throw x - #define UT_RETHROW(ExceptionType) catch(ExceptionType&) { throw; } - #define UT_CATCH(ExceptionType, ExceptionName, CatchBody) catch(ExceptionType& ExceptionName) CatchBody - #define UT_CATCH_ALL(CatchBody) catch(...) CatchBody + #define UNITTEST_IMPL_TRY(x) try x + #define UNITTEST_IMPL_THROW(x) throw x + #define UNITTEST_IMPL_RETHROW(ExceptionType) catch(ExceptionType&) { throw; } + #define UNITTEST_IMPL_CATCH(ExceptionType, ExceptionName, CatchBody) catch(ExceptionType& ExceptionName) CatchBody + #define UNITTEST_IMPL_CATCH_ALL(CatchBody) catch(...) CatchBody #else - #define UT_TRY(x) x - #define UT_THROW(x) - #define UT_RETHROW(ExceptionType) - #define UT_CATCH(ExceptionType, ExceptionName, CatchBody) - #define UT_CATCH_ALL(CatchBody) + #define UNITTEST_IMPL_TRY(x) x + #define UNITTEST_IMPL_THROW(x) + #define UNITTEST_IMPL_RETHROW(ExceptionType) + #define UNITTEST_IMPL_CATCH(ExceptionType, ExceptionName, CatchBody) + #define UNITTEST_IMPL_CATCH_ALL(CatchBody) #endif #endif diff --git a/UnitTest++/ExecuteTest.h b/UnitTest++/ExecuteTest.h index 8e516db..2759aad 100644 --- a/UnitTest++/ExecuteTest.h +++ b/UnitTest++/ExecuteTest.h @@ -31,23 +31,23 @@ namespace UnitTest { { #endif #ifndef UNITTEST_POSIX - UT_TRY({ testObject.RunImpl(); }) + UNITTEST_IMPL_TRY({ testObject.RunImpl(); }) #else - UT_TRY + UNITTEST_IMPL_TRY ({ UNITTEST_THROW_SIGNALS_POSIX_ONLY testObject.RunImpl(); }) #endif - UT_CATCH(RequiredCheckException, e, { (void)e; }) - UT_CATCH(AssertException, e, { (void)e; }) - UT_CATCH(std::exception, e, + UNITTEST_IMPL_CATCH(RequiredCheckException, e, { (void)e; }) + UNITTEST_IMPL_CATCH(AssertException, e, { (void)e; }) + UNITTEST_IMPL_CATCH(std::exception, e, { MemoryOutStream stream; stream << "Unhandled exception: " << e.what(); CurrentTest::Results()->OnTestFailure(details, stream.GetText()); }) - UT_CATCH_ALL + UNITTEST_IMPL_CATCH_ALL ({ CurrentTest::Results()->OnTestFailure(details, "Unhandled exception: test crashed"); }) diff --git a/UnitTest++/TestMacros.h b/UnitTest++/TestMacros.h index 738c56b..efe455e 100644 --- a/UnitTest++/TestMacros.h +++ b/UnitTest++/TestMacros.h @@ -79,23 +79,23 @@ void Test ## Fixture ## Name::RunImpl() const \ { \ volatile bool ctorOk = false; \ - UT_TRY \ + UNITTEST_IMPL_TRY \ ({ \ Fixture ## Name ## Helper fixtureHelper(m_details); \ ctorOk = true; \ UnitTest::ExecuteTest(fixtureHelper, m_details, false); \ }) \ - UT_CATCH (UnitTest::AssertException, e, \ + UNITTEST_IMPL_CATCH (UnitTest::AssertException, e, \ { \ (void)e; \ }) \ - UT_CATCH (std::exception, e, \ + UNITTEST_IMPL_CATCH (std::exception, e, \ { \ UnitTest::MemoryOutStream stream; \ stream << "Unhandled exception: " << e.what(); \ UnitTest::CurrentTest::Results()->OnTestFailure(m_details, stream.GetText()); \ }) \ - UT_CATCH_ALL \ + UNITTEST_IMPL_CATCH_ALL \ ({ \ if (ctorOk) \ { \ From df386f189f3b5c60ffa15a195194edbb011857da Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 7 May 2016 00:12:09 -0500 Subject: [PATCH 03/45] Add UNITTEST_ prefixes to remaining macros TEST, SUITE, and REQUIRE macros now have UNITTEST_ and UNITTEST_IMPL_ prefixes like the others, completing the set. --- UnitTest++/RequireMacros.h | 12 +++++++---- UnitTest++/TestMacros.h | 41 ++++++++++++++++++++++---------------- tests/TestTestMacros.cpp | 14 ++++++------- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/UnitTest++/RequireMacros.h b/UnitTest++/RequireMacros.h index 0830e99..f25899b 100644 --- a/UnitTest++/RequireMacros.h +++ b/UnitTest++/RequireMacros.h @@ -3,10 +3,14 @@ #include "RequiredCheckTestReporter.h" -#ifdef REQUIRE - #error UnitTest++ redefines REQUIRE -#endif +#define UNITTEST_REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(*UnitTest::CurrentTest::Results()); decoratedReporter.Next(); ) -#define REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(*UnitTest::CurrentTest::Results()); decoratedReporter.Next(); ) +#if UNITTEST_ENABLE_SHORT_MACROS + #ifdef REQUIRE + #error REQUIRE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_REQUIRE instead + #else + #define REQUIRE UNITTEST_REQUIRE + #endif +#endif #endif diff --git a/UnitTest++/TestMacros.h b/UnitTest++/TestMacros.h index efe455e..03cf3bb 100644 --- a/UnitTest++/TestMacros.h +++ b/UnitTest++/TestMacros.h @@ -15,19 +15,7 @@ #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) \ +#define UNITTEST_SUITE(Name) \ namespace Suite ## Name { \ namespace UnitTestSuite { \ inline char const* GetSuiteName () { \ @@ -37,7 +25,7 @@ } \ namespace Suite ## Name -#define TEST_EX(Name, List) \ +#define UNITTEST_IMPL_TEST(Name, List) \ class Test ## Name : public UnitTest::Test \ { \ public: \ @@ -51,10 +39,10 @@ void Test ## Name::RunImpl() const -#define TEST(Name) TEST_EX(Name, UnitTest::Test::GetTestList()) +#define UNITTEST_TEST(Name) UNITTEST_IMPL_TEST(Name, UnitTest::Test::GetTestList()) -#define TEST_FIXTURE_EX(Fixture, Name, List) \ +#define UNITTEST_IMPL_TEST_FIXTURE(Fixture, Name, List) \ class Fixture ## Name ## Helper : public Fixture \ { \ public: \ @@ -111,7 +99,26 @@ } \ void Fixture ## Name ## Helper::RunImpl() -#define TEST_FIXTURE(Fixture,Name) TEST_FIXTURE_EX(Fixture, Name, UnitTest::Test::GetTestList()) +#define UNITTEST_TEST_FIXTURE(Fixture,Name) UNITTEST_IMPL_TEST_FIXTURE(Fixture, Name, UnitTest::Test::GetTestList()) + +#if UNITTEST_ENABLE_SHORT_MACROS + #ifdef SUITE + #error SUITE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_SUITE instead + #else + #define SUITE UNITTEST_SUITE + #endif + #ifdef TEST + #error TEST already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_TEST instead + #else + #define TEST UNITTEST_TEST + #endif + + #ifdef TEST_FIXTURE + #error TEST_FIXTURE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_TEST_FIXTURE instead + #else + #define TEST_FIXTURE UNITTEST_TEST_FIXTURE + #endif +#endif #endif diff --git a/tests/TestTestMacros.cpp b/tests/TestTestMacros.cpp index 4a13316..e66bfb6 100644 --- a/tests/TestTestMacros.cpp +++ b/tests/TestTestMacros.cpp @@ -46,7 +46,7 @@ using namespace std; namespace { TestList list1; - TEST_EX(DummyTest, list1) + UNITTEST_IMPL_TEST(DummyTest, list1) {} TEST (TestsAreAddedToTheListThroughMacro) @@ -69,7 +69,7 @@ namespace { }; TestList list2; - TEST_FIXTURE_EX(ThrowingThingie, DummyTestName, list2) + UNITTEST_IMPL_TEST_FIXTURE(ThrowingThingie, DummyTestName, list2) {} TEST (ExceptionsInFixtureAreReportedAsHappeningInTheFixture) @@ -113,7 +113,7 @@ namespace { } TestList macroTestList1; - TEST_EX(MacroTestHelper1, macroTestList1) + UNITTEST_IMPL_TEST(MacroTestHelper1, macroTestList1) {} TEST(TestAddedWithTEST_EXMacroGetsDefaultSuite) @@ -124,7 +124,7 @@ namespace { } TestList macroTestList2; - TEST_FIXTURE_EX(DummyFixture, MacroTestHelper2, macroTestList2) + UNITTEST_IMPL_TEST_FIXTURE(DummyFixture, MacroTestHelper2, macroTestList2) {} TEST(TestAddedWithTEST_FIXTURE_EXMacroGetsDefaultSuite) @@ -144,7 +144,7 @@ namespace { }; TestList throwingFixtureTestList1; - TEST_FIXTURE_EX(FixtureCtorThrows, FixtureCtorThrowsTestName, throwingFixtureTestList1) + UNITTEST_IMPL_TEST_FIXTURE(FixtureCtorThrows, FixtureCtorThrowsTestName, throwingFixtureTestList1) {} TEST(FixturesWithThrowingCtorsAreFailures) @@ -170,7 +170,7 @@ namespace { }; TestList throwingFixtureTestList2; - TEST_FIXTURE_EX(FixtureDtorThrows, FixtureDtorThrowsTestName, throwingFixtureTestList2) + UNITTEST_IMPL_TEST_FIXTURE(FixtureDtorThrows, FixtureDtorThrowsTestName, throwingFixtureTestList2) {} TEST(FixturesWithThrowingDtorsAreFailures) @@ -200,7 +200,7 @@ namespace { }; TestList ctorAssertFixtureTestList; - TEST_FIXTURE_EX(FixtureCtorAsserts, CorrectlyReportsAssertFailureInCtor, ctorAssertFixtureTestList) + UNITTEST_IMPL_TEST_FIXTURE(FixtureCtorAsserts, CorrectlyReportsAssertFailureInCtor, ctorAssertFixtureTestList) {} TEST(CorrectlyReportsFixturesWithCtorsThatAssert) From 910381fadc6674089c3eb9e9be5911464273b7bc Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 7 May 2016 01:02:20 -0500 Subject: [PATCH 04/45] Change UNITTEST_ENABLE_SHORT_MACROS to DISABLE Also add a test file. --- UnitTest++/CheckMacros.h | 4 ++-- UnitTest++/Config.h | 9 +++++--- UnitTest++/RequireMacros.h | 2 +- UnitTest++/TestMacros.h | 2 +- tests/TestLongMacros.cpp | 45 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 tests/TestLongMacros.cpp diff --git a/UnitTest++/CheckMacros.h b/UnitTest++/CheckMacros.h index bb45964..261afbb 100644 --- a/UnitTest++/CheckMacros.h +++ b/UnitTest++/CheckMacros.h @@ -138,7 +138,7 @@ }) \ UNITTEST_MULTILINE_MACRO_END -#if UNITTEST_ENABLE_SHORT_MACROS +#ifndef UNITTEST_DISABLE_SHORT_MACROS #ifdef CHECK #error CHECK already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK instead #else @@ -198,7 +198,7 @@ UNITTEST_MULTILINE_MACRO_END #endif -#if UNITTEST_ENABLE_SHORT_MACROS +#ifndef UNITTEST_DISABLE_SHORT_MACROS #ifdef CHECK_THROW #error CHECK_THROW already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_THROW instead #else diff --git a/UnitTest++/Config.h b/UnitTest++/Config.h index 364fe8d..a653e45 100644 --- a/UnitTest++/Config.h +++ b/UnitTest++/Config.h @@ -72,9 +72,12 @@ #endif // By default, UnitTest++ will attempt to define "short" macro names like CHECK and CHECK_EQUAL -// for "public" interface macros etc. Setting UNITTEST_ENABLE_SHORT_MACROS to 0 will disable -// this behavior, leaving only the longer macros "namespaced" with the UNITTEST_ prefix. +// for "public" interface macros etc. Defining UNITTEST_DISABLE_SHORT_MACROS in your project +// will disable this behavior, leaving only the longer macros "namespaced" with the UNITTEST_ +// prefix. +// // "Internal" utility macros will only have the UNITTEST_IMPL_ prefix. -#define UNITTEST_ENABLE_SHORT_MACROS 1 + +// #define UNITTEST_DISABLE_SHORT_MACROS #endif diff --git a/UnitTest++/RequireMacros.h b/UnitTest++/RequireMacros.h index f25899b..7fe793b 100644 --- a/UnitTest++/RequireMacros.h +++ b/UnitTest++/RequireMacros.h @@ -5,7 +5,7 @@ #define UNITTEST_REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(*UnitTest::CurrentTest::Results()); decoratedReporter.Next(); ) -#if UNITTEST_ENABLE_SHORT_MACROS +#ifndef UNITTEST_DISABLE_SHORT_MACROS #ifdef REQUIRE #error REQUIRE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_REQUIRE instead #else diff --git a/UnitTest++/TestMacros.h b/UnitTest++/TestMacros.h index 03cf3bb..d6bc204 100644 --- a/UnitTest++/TestMacros.h +++ b/UnitTest++/TestMacros.h @@ -101,7 +101,7 @@ #define UNITTEST_TEST_FIXTURE(Fixture,Name) UNITTEST_IMPL_TEST_FIXTURE(Fixture, Name, UnitTest::Test::GetTestList()) -#if UNITTEST_ENABLE_SHORT_MACROS +#ifndef UNITTEST_DISABLE_SHORT_MACROS #ifdef SUITE #error SUITE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_SUITE instead #else diff --git a/tests/TestLongMacros.cpp b/tests/TestLongMacros.cpp new file mode 100644 index 0000000..6720a97 --- /dev/null +++ b/tests/TestLongMacros.cpp @@ -0,0 +1,45 @@ +#define UNITTEST_DISABLE_SHORT_MACROS + +#include "UnitTest++/UnitTestPP.h" + +// This file is not intended to test every little thing, just a few basics to hopefully ensure +// the macros are working and the short macros are not defined. +UNITTEST_SUITE(LongMacros) +{ + UNITTEST_TEST(LongCheckMacroWorks) + { + UNITTEST_CHECK(true); + } + + class Fixture + { + public: + Fixture() : sanity_(true) {} + protected: + bool sanity_; + }; + + UNITTEST_TEST_FIXTURE(Fixture, LongFixtureMacroWorks) + { + UNITTEST_REQUIRE UNITTEST_CHECK(sanity_); + } + + UNITTEST_TEST(ShortMacrosAreNotDefined) + { +#if defined(CHECK) || \ + defined(CHECK_EQUAL) || \ + defined(CHECK_CLOSE) || \ + defined(CHECK_ARRAY_EQUAL) || \ + defined(CHECK_ARRAY_CLOSE) || \ + defined(CHECK_ARRAY2D_CLOSE) || \ + defined(CHECK_THROW) || \ + defined(CHECK_ASSERT) || \ + defined(SUITE) || \ + defined(TEST) || \ + defined(TEST_FIXTURE) || \ + defined(REQUIRE) + + UNITTEST_CHECK(false); +#endif + } +} From 27317ec0773157ba1d479d0f78fc402ada323336 Mon Sep 17 00:00:00 2001 From: JonChesterfield Date: Mon, 16 May 2016 11:13:51 +0100 Subject: [PATCH 05/45] Prefix local variable message in CHECK macros with UnitTest_ to reduce the risk of name collisions with application code --- UnitTest++/CheckMacros.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/UnitTest++/CheckMacros.h b/UnitTest++/CheckMacros.h index e9dae64..3bfbaf8 100644 --- a/UnitTest++/CheckMacros.h +++ b/UnitTest++/CheckMacros.h @@ -45,10 +45,10 @@ UT_RETHROW (UnitTest::RequiredCheckException) \ UT_CATCH (std::exception, e, \ { \ - UnitTest::MemoryOutStream message; \ - message << "Unhandled exception (" << e.what() << ") in CHECK(" #value ")"; \ + UnitTest::MemoryOutStream UnitTest_message; \ + UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK(" #value ")"; \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ - message.GetText()); \ + UnitTest_message.GetText()); \ }) \ UT_CATCH_ALL \ ({ \ @@ -66,10 +66,10 @@ UT_RETHROW (UnitTest::RequiredCheckException) \ UT_CATCH (std::exception, e, \ { \ - UnitTest::MemoryOutStream message; \ - message << "Unhandled exception (" << e.what() << ") in CHECK_EQUAL(" #expected ", " #actual ")"; \ + UnitTest::MemoryOutStream UnitTest_message; \ + UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_EQUAL(" #expected ", " #actual ")"; \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ - message.GetText()); \ + UnitTest_message.GetText()); \ }) \ UT_CATCH_ALL \ ({ \ @@ -87,10 +87,10 @@ UT_RETHROW (UnitTest::RequiredCheckException) \ UT_CATCH (std::exception, e, \ { \ - UnitTest::MemoryOutStream message; \ - message << "Unhandled exception (" << e.what() << ") in CHECK_CLOSE(" #expected ", " #actual ")"; \ + UnitTest::MemoryOutStream UnitTest_message; \ + UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_CLOSE(" #expected ", " #actual ")"; \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ - message.GetText()); \ + UnitTest_message.GetText()); \ }) \ UT_CATCH_ALL \ ({ \ @@ -108,10 +108,10 @@ UT_RETHROW (UnitTest::RequiredCheckException) \ UT_CATCH (std::exception, e, \ { \ - UnitTest::MemoryOutStream message; \ - message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY_EQUAL(" #expected ", " #actual ")"; \ + UnitTest::MemoryOutStream UnitTest_message; \ + UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY_EQUAL(" #expected ", " #actual ")"; \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ - message.GetText()); \ + UnitTest_message.GetText()); \ }) \ UT_CATCH_ALL \ ({ \ @@ -129,10 +129,10 @@ UT_RETHROW (UnitTest::RequiredCheckException) \ UT_CATCH (std::exception, e, \ { \ - UnitTest::MemoryOutStream message; \ - message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY_CLOSE(" #expected ", " #actual ")"; \ + UnitTest::MemoryOutStream UnitTest_message; \ + UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY_CLOSE(" #expected ", " #actual ")"; \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ - message.GetText()); \ + UnitTest_message.GetText()); \ }) \ UT_CATCH_ALL \ ({ \ @@ -150,10 +150,10 @@ UT_RETHROW (UnitTest::RequiredCheckException) \ UT_CATCH (std::exception, e, \ { \ - UnitTest::MemoryOutStream message; \ - message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY2D_CLOSE(" #expected ", " #actual ")"; \ + UnitTest::MemoryOutStream UnitTest_message; \ + UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY2D_CLOSE(" #expected ", " #actual ")"; \ UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \ - message.GetText()); \ + UnitTest_message.GetText()); \ }) \ UT_CATCH_ALL \ ({ \ From 053bcfc9c7760fbaecaa9c882a6f0bcf11c318fd Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Thu, 2 Jun 2016 19:49:48 +0200 Subject: [PATCH 06/45] Add support for Haiku. --- UnitTest++/Config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UnitTest++/Config.h b/UnitTest++/Config.h index ff62b4e..4bd31fe 100644 --- a/UnitTest++/Config.h +++ b/UnitTest++/Config.h @@ -21,7 +21,8 @@ #endif #if defined(unix) || defined(__unix__) || defined(__unix) || defined(linux) || \ - defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) + defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) \ + || defined (__HAIKU__) #define UNITTEST_POSIX #endif From 21589e561214664249d2872c13642ced555cd23a Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Fri, 15 Jul 2016 23:23:45 -0500 Subject: [PATCH 07/45] Take UnitTest::Check parameter by const reference Fixes #119 and #7 --- UnitTest++/Checks.h | 2 +- tests/TestChecks.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/UnitTest++/Checks.h b/UnitTest++/Checks.h index 5b09768..70bd51b 100644 --- a/UnitTest++/Checks.h +++ b/UnitTest++/Checks.h @@ -9,7 +9,7 @@ namespace UnitTest { template< typename Value > - bool Check(Value const value) + bool Check(Value const& value) { return !!value; // doing double negative to avoid silly VS warnings } diff --git a/tests/TestChecks.cpp b/tests/TestChecks.cpp index 1ec64ee..233b8a8 100644 --- a/tests/TestChecks.cpp +++ b/tests/TestChecks.cpp @@ -315,4 +315,32 @@ namespace { CHECK_EQUAL(1234, reporter.lastFailedLine); } + TEST(CheckProperlyDealsWithOperatorBoolOverrides) + { + class TruthyUnlessCopied + { + public: + TruthyUnlessCopied() + : truthy_(true) + { + } + + TruthyUnlessCopied(const TruthyUnlessCopied& orig) + : truthy_(false) + { + } + + operator bool() const + { + return truthy_; + } + + private: + bool truthy_; + }; + + TruthyUnlessCopied objectThatShouldBeTruthy; + CHECK(objectThatShouldBeTruthy); + } + } From bec6ba56ec0988815034656cfb8a7957e728d6d6 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Fri, 15 Jul 2016 23:54:59 -0500 Subject: [PATCH 08/45] Attempted fix for Travis build. --- tests/TestChecks.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/TestChecks.cpp b/tests/TestChecks.cpp index 233b8a8..645c3d9 100644 --- a/tests/TestChecks.cpp +++ b/tests/TestChecks.cpp @@ -315,30 +315,30 @@ namespace { CHECK_EQUAL(1234, reporter.lastFailedLine); } - TEST(CheckProperlyDealsWithOperatorBoolOverrides) + class TruthyUnlessCopied { - class TruthyUnlessCopied + public: + TruthyUnlessCopied() + : truthy_(true) + { + } + + TruthyUnlessCopied(const TruthyUnlessCopied& orig) + : truthy_(false) + { + } + + operator bool() const { - public: - TruthyUnlessCopied() - : truthy_(true) - { - } - - TruthyUnlessCopied(const TruthyUnlessCopied& orig) - : truthy_(false) - { - } - - operator bool() const - { - return truthy_; - } - - private: - bool truthy_; - }; + return truthy_; + } + + private: + bool truthy_; + }; + TEST(CheckProperlyDealsWithOperatorBoolOverrides) + { TruthyUnlessCopied objectThatShouldBeTruthy; CHECK(objectThatShouldBeTruthy); } From de915185f6f40a3c25bef51eecddab22c40d045d Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Fri, 15 Jul 2016 23:58:48 -0500 Subject: [PATCH 09/45] Remove unused variable from test copy constructor --- tests/TestChecks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestChecks.cpp b/tests/TestChecks.cpp index 645c3d9..2c0ac04 100644 --- a/tests/TestChecks.cpp +++ b/tests/TestChecks.cpp @@ -323,7 +323,7 @@ namespace { { } - TruthyUnlessCopied(const TruthyUnlessCopied& orig) + TruthyUnlessCopied(const TruthyUnlessCopied&) : truthy_(false) { } From fa971526199acfa5a36ae7e85fcd668a1685d582 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 7 May 2016 02:19:02 -0500 Subject: [PATCH 10/45] Add UTPP_SKIP_TESTS_AS_BUILD_STEP CMake option Helps address #104. --- CMakeLists.txt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b5aa7e..03f3063 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,12 @@ cmake_minimum_required(VERSION 2.8.1) project(UnitTest++) -option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" ON) +option(UTPP_USE_PLUS_SIGN + "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" + ON) +option(UTPP_SKIP_TESTS_AS_BUILD_STEP + "Set this to ON if you do not wish unit tests to run as part of cmake --build" + OFF) if(MSVC14 OR MSVC12) # has the support we need @@ -55,10 +60,15 @@ endif() target_link_libraries(TestUnitTest++ UnitTest++) -# run unit tests as post build step -add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND TestUnitTest++ - COMMENT "Running unit tests") +if(${UTPP_SKIP_TESTS_AS_BUILD_STEP}) + add_custom_command(TARGET TestUnitTest++ + POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_SKIP_TESTS_AS_BUILD_STEP is ON") +else() + # run unit tests as post build step + add_custom_command(TARGET TestUnitTest++ + POST_BUILD COMMAND TestUnitTest++ + COMMENT "Running unit tests") +endif() # add install targets # need a custom install path? From 14f317c40c98835d10b0b6072e667dc1911c3b93 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 7 May 2016 02:29:16 -0500 Subject: [PATCH 11/45] Eliminate double-negative in option name / value UTPP_SKIP_TESTS_AS_BUILD_STEP with a default value of OFF was an unfortunate choice, so this changes it to UTPP_RUN_TESTS_AS_BUILD_STEP with a default value of ON. --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03f3063..447f4ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,9 @@ project(UnitTest++) option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" ON) -option(UTPP_SKIP_TESTS_AS_BUILD_STEP - "Set this to ON if you do not wish unit tests to run as part of cmake --build" - OFF) +option(UTPP_RUN_TESTS_AS_BUILD_STEP + "Set this to OFF if you do not wish unit tests to run as part of cmake --build" + ON) if(MSVC14 OR MSVC12) # has the support we need @@ -60,14 +60,14 @@ endif() target_link_libraries(TestUnitTest++ UnitTest++) -if(${UTPP_SKIP_TESTS_AS_BUILD_STEP}) +if(${UTPP_RUN_TESTS_AS_BUILD_STEP}) + # run unit tests as post build step add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_SKIP_TESTS_AS_BUILD_STEP is ON") + POST_BUILD COMMAND TestUnitTest++ + COMMENT "Running unit tests") else() - # run unit tests as post build step add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND TestUnitTest++ - COMMENT "Running unit tests") + POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_RUN_TESTS_AS_BUILD_STEP is OFF") endif() # add install targets From 6b69ed78bae727246a6f2e1308feabaf28ded093 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Mon, 18 Jul 2016 21:13:03 -0500 Subject: [PATCH 12/45] Skip test build with same option as run As part of this, changed the option name to `UTPP_INCLUDE_TESTS_IN_BUILD`. The test target is still added to the build and can be built/run separately using the CMake --target option. --- CMakeLists.txt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 447f4ce..e99ee13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,8 @@ project(UnitTest++) option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" ON) -option(UTPP_RUN_TESTS_AS_BUILD_STEP - "Set this to OFF if you do not wish unit tests to run as part of cmake --build" +option(UTPP_INCLUDE_TESTS_IN_BUILD + "Set this to OFF if you do not wish to automatically build or run unit tests as part of the default cmake --build" ON) if(MSVC14 OR MSVC12) @@ -60,14 +60,13 @@ endif() target_link_libraries(TestUnitTest++ UnitTest++) -if(${UTPP_RUN_TESTS_AS_BUILD_STEP}) - # run unit tests as post build step - add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND TestUnitTest++ - COMMENT "Running unit tests") -else() - add_custom_command(TARGET TestUnitTest++ - POST_BUILD COMMAND echo "TestUnitTest++ was not run as a build step because UTPP_RUN_TESTS_AS_BUILD_STEP is OFF") +# run unit tests as post build step +add_custom_command(TARGET TestUnitTest++ + POST_BUILD COMMAND TestUnitTest++ + COMMENT "Running unit tests") + +if(NOT ${UTPP_INCLUDE_TESTS_IN_BUILD}) + set_target_properties(TestUnitTest++ PROPERTIES EXCLUDE_FROM_ALL 1) endif() # add install targets From 7c159427516124ba8c01262b15f492b6b6789dce Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 27 Aug 2016 08:26:05 -0500 Subject: [PATCH 13/45] Up warning level to /W4 /WX for MSVC-like compilers Also adds a CMake option, UTPP_AMPLIFY_WARNINGS, that can be turned OFF to disable the new behavior. --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e99ee13..89e61f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ option(UTPP_USE_PLUS_SIGN option(UTPP_INCLUDE_TESTS_IN_BUILD "Set this to OFF if you do not wish to automatically build or run unit tests as part of the default cmake --build" ON) +option(UTPP_AMPLIFY_WARNINGS + "Set this to OFF if you wish to use CMake default warning levels; should generally only use to work around support issues for your specific compiler" + ON) if(MSVC14 OR MSVC12) # has the support we need @@ -23,6 +26,15 @@ else() endif() endif() +# up warning level for project +if (${UTPP_AMPLIFY_WARNINGS}) + # instead of getting compiler specific, we're going to try making an assumption that an existing /W# means + # we are dealing with an MSVC or MSVC-like compiler (e.g. Intel on Windows) + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") + endif() +endif() + # get the main sources file(GLOB headers_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.h) file(GLOB sources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.cpp) From 7e4fff3bb420820b67562ccd1d706e17d795cf8d Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 27 Aug 2016 08:27:15 -0500 Subject: [PATCH 14/45] Fix "assignment operator could not be generated" warning This shows up with /W4 on MSVC. Fixes #107. --- UnitTest++/RequiredCheckTestReporter.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/UnitTest++/RequiredCheckTestReporter.h b/UnitTest++/RequiredCheckTestReporter.h index 117ae01..99d9cdd 100644 --- a/UnitTest++/RequiredCheckTestReporter.h +++ b/UnitTest++/RequiredCheckTestReporter.h @@ -19,6 +19,9 @@ namespace UnitTest { bool Next(); private: + RequiredCheckTestReporter(RequiredCheckTestReporter const&); + RequiredCheckTestReporter& operator =(RequiredCheckTestReporter const&); + TestResults& m_results; TestReporter* m_originalTestReporter; ThrowingTestReporter m_throwingReporter; From f0044e919dcae4a171d2db45f2aea92850df2b0c Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 27 Aug 2016 09:54:32 -0500 Subject: [PATCH 15/45] Up warning level to -Wall/extra/error for non-MSVC UTPP_AMPLIFY_WARNINGS can be turned OFF to disable the new behavior. --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89e61f5..76c8665 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,8 @@ if (${UTPP_AMPLIFY_WARNINGS}) # we are dealing with an MSVC or MSVC-like compiler (e.g. Intel on Windows) if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") + else() + string(CONCAT CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" " -Wall -Wextra -Werror -Wno-ignored-qualifiers") endif() endif() From 2e2475fa5401c4ef123b3ca26f7a8e60ee5eb425 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 27 Aug 2016 09:55:37 -0500 Subject: [PATCH 16/45] Fix unused variable warnings --- UnitTest++/Posix/SignalTranslator.cpp | 4 ++-- UnitTest++/Posix/SignalTranslator.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/UnitTest++/Posix/SignalTranslator.cpp b/UnitTest++/Posix/SignalTranslator.cpp index 4039896..69cc194 100644 --- a/UnitTest++/Posix/SignalTranslator.cpp +++ b/UnitTest++/Posix/SignalTranslator.cpp @@ -28,12 +28,12 @@ namespace UnitTest { 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 ); + sigaction( SIGILL, &action, &m_old_SIGILL_action ); } SignalTranslator::~SignalTranslator() { - sigaction( SIGILL, &m_old_SIGBUS_action, 0 ); + sigaction( SIGILL, &m_old_SIGILL_action, 0 ); sigaction( SIGBUS, &m_old_SIGBUS_action, 0 ); sigaction( SIGTRAP, &m_old_SIGTRAP_action, 0 ); sigaction( SIGFPE, &m_old_SIGFPE_action, 0 ); diff --git a/UnitTest++/Posix/SignalTranslator.h b/UnitTest++/Posix/SignalTranslator.h index efb3618..66d388d 100644 --- a/UnitTest++/Posix/SignalTranslator.h +++ b/UnitTest++/Posix/SignalTranslator.h @@ -22,8 +22,7 @@ namespace UnitTest { 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; + struct sigaction m_old_SIGILL_action; }; #if !defined (__GNUC__) From e161d44077646e63e8956ce0c70002cecda3d2be Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 27 Aug 2016 10:04:54 -0500 Subject: [PATCH 17/45] Use CMake SET instead of string CONCAT string(CONCAT...) was not available in older versions of CMake targeted by this project. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76c8665..32023b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ if (${UTPP_AMPLIFY_WARNINGS}) if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") else() - string(CONCAT CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" " -Wall -Wextra -Werror -Wno-ignored-qualifiers") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-ignored-qualifiers") endif() endif() From 7d7ba0aba44d5a9d76442e5e8286686e01eaf222 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Sat, 27 Aug 2016 20:41:41 -0500 Subject: [PATCH 18/45] Re-enable ignored-qualifiers warning and fix --- CMakeLists.txt | 2 +- tests/TestMemoryOutStream.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32023b9..a7411bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ if (${UTPP_AMPLIFY_WARNINGS}) if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-ignored-qualifiers") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") endif() endif() diff --git a/tests/TestMemoryOutStream.cpp b/tests/TestMemoryOutStream.cpp index 7c1ffbc..854277e 100644 --- a/tests/TestMemoryOutStream.cpp +++ b/tests/TestMemoryOutStream.cpp @@ -11,7 +11,7 @@ using namespace std; namespace { - const char* const maxSignedIntegralStr(size_t nBytes) + const char* maxSignedIntegralStr(size_t nBytes) { switch(nBytes) { @@ -28,7 +28,7 @@ namespace { } } - const char* const minSignedIntegralStr(size_t nBytes) + const char* minSignedIntegralStr(size_t nBytes) { switch(nBytes) { @@ -45,7 +45,7 @@ namespace { } } - const char* const maxUnsignedIntegralStr(size_t nBytes) + const char* maxUnsignedIntegralStr(size_t nBytes) { switch(nBytes) { From eca039304b7e93ee40e3d733a0c051af7e7943e2 Mon Sep 17 00:00:00 2001 From: Gabriel Schlozer Date: Mon, 29 Aug 2016 22:36:31 +0200 Subject: [PATCH 19/45] Used size_t for CHECK macros --- UnitTest++/Checks.h | 30 +++++++++++++++--------------- tests/TestExceptions.cpp | 8 ++++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/UnitTest++/Checks.h b/UnitTest++/Checks.h index 70bd51b..7c37691 100644 --- a/UnitTest++/Checks.h +++ b/UnitTest++/Checks.h @@ -57,10 +57,10 @@ namespace UnitTest { template< typename Expected, typename Actual > void CheckArrayEqual(TestResults& results, Expected const& expected, Actual const& actual, - int const count, TestDetails const& details) + size_t const count, TestDetails const& details) { bool equal = true; - for (int i = 0; i < count; ++i) + for (size_t i = 0; i < count; ++i) equal &= (expected[i] == actual[i]); if (!equal) @@ -69,12 +69,12 @@ namespace UnitTest { stream << "Expected [ "; - for (int expectedIndex = 0; expectedIndex < count; ++expectedIndex) + for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex) stream << expected[expectedIndex] << " "; stream << "] but was [ "; - for (int actualIndex = 0; actualIndex < count; ++actualIndex) + for (size_t actualIndex = 0; actualIndex < count; ++actualIndex) stream << actual[actualIndex] << " "; stream << "]"; @@ -84,17 +84,17 @@ namespace UnitTest { } template< typename Expected, typename Actual, typename Tolerance > - bool ArrayAreClose(Expected const& expected, Actual const& actual, int const count, Tolerance const& tolerance) + bool ArrayAreClose(Expected const& expected, Actual const& actual, size_t const count, Tolerance const& tolerance) { bool equal = true; - for (int i = 0; i < count; ++i) + for (size_t 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) + size_t const count, Tolerance const& tolerance, TestDetails const& details) { bool equal = ArrayAreClose(expected, actual, count, tolerance); @@ -103,11 +103,11 @@ namespace UnitTest { UnitTest::MemoryOutStream stream; stream << "Expected [ "; - for (int expectedIndex = 0; expectedIndex < count; ++expectedIndex) + for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex) stream << expected[expectedIndex] << " "; stream << "] +/- " << tolerance << " but was [ "; - for (int actualIndex = 0; actualIndex < count; ++actualIndex) + for (size_t actualIndex = 0; actualIndex < count; ++actualIndex) stream << actual[actualIndex] << " "; stream << "]"; @@ -117,10 +117,10 @@ namespace UnitTest { 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) + size_t const rows, size_t const columns, Tolerance const& tolerance, TestDetails const& details) { bool equal = true; - for (int i = 0; i < rows; ++i) + for (size_t i = 0; i < rows; ++i) equal &= ArrayAreClose(expected[i], actual[i], columns, tolerance); if (!equal) @@ -129,20 +129,20 @@ namespace UnitTest { stream << "Expected [ "; - for (int expectedRow = 0; expectedRow < rows; ++expectedRow) + for (size_t expectedRow = 0; expectedRow < rows; ++expectedRow) { stream << "[ "; - for (int expectedColumn = 0; expectedColumn < columns; ++expectedColumn) + for (size_t expectedColumn = 0; expectedColumn < columns; ++expectedColumn) stream << expected[expectedRow][expectedColumn] << " "; stream << "] "; } stream << "] +/- " << tolerance << " but was [ "; - for (int actualRow = 0; actualRow < rows; ++actualRow) + for (size_t actualRow = 0; actualRow < rows; ++actualRow) { stream << "[ "; - for (int actualColumn = 0; actualColumn < columns; ++actualColumn) + for (size_t actualColumn = 0; actualColumn < columns; ++actualColumn) stream << actual[actualRow][actualColumn] << " "; stream << "] "; } diff --git a/tests/TestExceptions.cpp b/tests/TestExceptions.cpp index 972e64d..08f6547 100644 --- a/tests/TestExceptions.cpp +++ b/tests/TestExceptions.cpp @@ -253,7 +253,7 @@ namespace { class ThrowingObject { public: - float operator[](int) const + float operator[](size_t) const { throw "Test throw"; } @@ -262,7 +262,7 @@ namespace { class StdThrowingObject { public: - float operator[](int) const + float operator[](size_t) const { throw std::runtime_error("Test throw"); } @@ -451,7 +451,7 @@ namespace { class ThrowingObject2D { public: - float* operator[](int) const + float* operator[](size_t) const { throw "Test throw"; } @@ -460,7 +460,7 @@ namespace { class StdThrowingObject2D { public: - float* operator[](int) const + float* operator[](size_t) const { throw std::runtime_error("Test throw"); } From 0d77b1ae10622d39450d905b8aec23267a1085c3 Mon Sep 17 00:00:00 2001 From: Julien Monat Rodier Date: Tue, 11 Oct 2016 13:00:40 -0700 Subject: [PATCH 20/45] Update docs reference to avoid bad path names on windows --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 14495a3..a6963b7 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 14495a3a81568e9ce187231b629e4eb7bc7e0350 +Subproject commit a6963b798400df760e148a6e15e9c13db965a3ec From 40f90dc601eb2107c3e4786a3ebe16e7fd273075 Mon Sep 17 00:00:00 2001 From: Evan Danaher Date: Thu, 1 Dec 2016 12:22:54 -0500 Subject: [PATCH 21/45] Build pkgconfig file with CMake, not just with autoconf. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7411bc..fb10f47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,3 +100,11 @@ install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION}) install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_}) install(FILES cmake/UnitTest++Config.cmake DESTINATION "${config_install_dir_}") install(EXPORT "${targets_export_name_}" DESTINATION "${config_install_dir_}") + +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) +set(libdir ${CMAKE_INSTALL_PREFIX}/lib) +set(includedir ${CMAKE_INSTALL_PREFIX}/include/UnitTest++) +configure_file("UnitTest++.pc.in" "UnitTest++.pc" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/UnitTest++.pc" + DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") From 9eba823269fffa8f1a5c780c937c202672b636fe Mon Sep 17 00:00:00 2001 From: Gabriel Hare Date: Wed, 14 Dec 2016 23:11:20 -0800 Subject: [PATCH 22/45] Demonstrate that compiler is identified as MSVC when VS2014 Clang extension is used --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7411bc..2d6c28c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,15 +11,19 @@ option(UTPP_AMPLIFY_WARNINGS "Set this to OFF if you wish to use CMake default warning levels; should generally only use to work around support issues for your specific compiler" ON) +message(STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}") if(MSVC14 OR MSVC12) + message(STATUS "Using MSVC compiler") # has the support we need else() include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX14) + message(STATUS "Specify C++14") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") elseif(COMPILER_SUPPORTS_CXX11) + message(STATUS "Specify C++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") From 8f7a2634462011b9b366704e480d25fe7fc2f626 Mon Sep 17 00:00:00 2001 From: Gabriel Hare Date: Thu, 15 Dec 2016 00:31:56 -0800 Subject: [PATCH 23/45] Increase CMake version to resolve developer warnings regarding implicit quoted dereference in STREQUAL comparison --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d6c28c..4f8c8db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.1) +cmake_minimum_required(VERSION 3.1.0) project(UnitTest++) option(UTPP_USE_PLUS_SIGN From c4ab9d31ed98da89bf1f07738129139eb0034dd8 Mon Sep 17 00:00:00 2001 From: Gabriel Hare Date: Thu, 15 Dec 2016 00:40:03 -0800 Subject: [PATCH 24/45] Identify Clang compiler when used as an MSVC extension --- CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f8c8db..000fd6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,22 +11,24 @@ option(UTPP_AMPLIFY_WARNINGS "Set this to OFF if you wish to use CMake default warning levels; should generally only use to work around support issues for your specific compiler" ON) -message(STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}") -if(MSVC14 OR MSVC12) - message(STATUS "Using MSVC compiler") - # has the support we need +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # CHECK_CXX_COMPILER_FLAG could be used + # but MSVC version is preferred for feature requirements + if (MSVC14 OR MSVC12) + # has the support we need + else() + message(WARNING "The MSVC compiler version does not support required C++11 features. Please use a different C++ compiler.") + endif() else() include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX14) - message(STATUS "Specify C++14") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") elseif(COMPILER_SUPPORTS_CXX11) - message(STATUS "Specify C++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + message(WARNING "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() endif() From bb495391070e2a87503f9d3dba723b62a90a5032 Mon Sep 17 00:00:00 2001 From: Gabriel Hare Date: Thu, 15 Dec 2016 02:46:13 -0800 Subject: [PATCH 25/45] Revert "Increase CMake version to resolve developer warnings regarding implicit quoted dereference in STREQUAL comparison" This reverts commit 8f7a2634462011b9b366704e480d25fe7fc2f626. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 000fd6b..f075074 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1.0) +cmake_minimum_required(VERSION 2.8.1) project(UnitTest++) option(UTPP_USE_PLUS_SIGN From a2fe23887a793c42b35c7be54bd9e06023bc36b7 Mon Sep 17 00:00:00 2001 From: Gabriel Hare Date: Thu, 15 Dec 2016 02:50:09 -0800 Subject: [PATCH 26/45] =?UTF-8?q?Use=20=E2=80=9CMATCHES=E2=80=9D=20instead?= =?UTF-8?q?=20of=20=E2=80=9CSTREQUAL=E2=80=9D=20to=20avoid=20ambiguous=20c?= =?UTF-8?q?omparison.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NOTE: Unlike STREQUAL this comparison is supported pre and post CMake v3.1.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f075074..4c39baf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ option(UTPP_AMPLIFY_WARNINGS "Set this to OFF if you wish to use CMake default warning levels; should generally only use to work around support issues for your specific compiler" ON) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") +if(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") # CHECK_CXX_COMPILER_FLAG could be used # but MSVC version is preferred for feature requirements if (MSVC14 OR MSVC12) From 8d70dff05bbf19bd72ab198e3d4d14a244891123 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Fri, 13 Jan 2017 14:35:21 -0600 Subject: [PATCH 27/45] Delete unused ChangeLog file Closes #138 --- ChangeLog | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ChangeLog diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index e69de29..0000000 From 8e5968bb05b03e024c4d783e703e1f416762177d Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Fri, 13 Jan 2017 14:36:38 -0600 Subject: [PATCH 28/45] Roll version number to 2.0.0 --- README.md | 12 +++++++++--- appveyor.yml | 2 +- configure.ac | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8a49c3d..7c138a8 100644 --- a/README.md +++ b/README.md @@ -30,17 +30,17 @@ Via svn: svn checkout https://github.com/unittest-cpp/unittest-cpp/trunk unittest-cpp -### Latest release (v1.6.1) ### +### Latest release (v2.0.0) ### Via git: git clone https://github.com/unittest-cpp/unittest-cpp cd unittest-cpp - git checkout v1.6.1 + git checkout v2.0.0 Via svn: - svn checkout https://github.com/unittest-cpp/unittest-cpp/tags/v1.6.1 unittest-cpp + svn checkout https://github.com/unittest-cpp/unittest-cpp/tags/v2.0.0 unittest-cpp License --------- @@ -77,6 +77,12 @@ Contributors Historic release notes ---------------------- +### Version 2.0.0 (2017-01-13) ### +- Change Check method supporting CHECK macro to accept argument by reference +- Introduce long macro forms (e.g. UNITTEST_CHECK); make short forms optional +- Improved Visual Studio 2015 support +- [Full List](https://github.com/unittest-cpp/unittest-cpp/issues?q=milestone%3A2.0.0+) + ### Version 1.6.0 (2016-02-29) ### - Add REQUIRE macro to end tests early when selected checks fail - [Full List](https://github.com/unittest-cpp/unittest-cpp/issues?q=milestone%3A1.6.0+) diff --git a/appveyor.yml b/appveyor.yml index 71e4398..bebe4f5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.6.1.{build} +version: 2.0.0.{build} os: - Windows Server 2012 R2 diff --git a/configure.ac b/configure.ac index 6b81131..56300a6 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ AM_CONDITIONAL([WINDOWS], LT_INIT() -AC_SUBST([LIBUNITTEST_SO_VERSION], [1:6:0]) +AC_SUBST([LIBUNITTEST_SO_VERSION], [2:0:0]) # Checks for programs. AC_PROG_CXX From 615b6cdd0fa614ab4276c2382889355dd698b556 Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Fri, 13 Jan 2017 14:51:19 -0600 Subject: [PATCH 29/45] Add note re: autotools to INSTALL file --- INSTALL | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/INSTALL b/INSTALL index 6e90e07..6c99c94 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,9 @@ + +Preamble: If you are installing UnitTest++ from source, or from a +release prior to 1.6.1, you will need to have autotools installed and +run `autoreconf -i; autoconf` prior to following the standard +instructions below. + Installation Instructions ************************* From 85bade33f596a4dab33eb6d44f662d64fc20f510 Mon Sep 17 00:00:00 2001 From: Iblis Lin Date: Sat, 14 Jan 2017 23:00:24 +0800 Subject: [PATCH 30/45] cmake: fix pkgconfig dir path on FreeBSD --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb10f47..a0f5511 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,5 +106,10 @@ set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) set(libdir ${CMAKE_INSTALL_PREFIX}/lib) set(includedir ${CMAKE_INSTALL_PREFIX}/include/UnitTest++) configure_file("UnitTest++.pc.in" "UnitTest++.pc" @ONLY) +if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig) +else() + set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) +endif() install(FILES "${CMAKE_CURRENT_BINARY_DIR}/UnitTest++.pc" - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") + DESTINATION "${pkgconfdir}") From 0757ba8f903fc94ac852c8ba394cd96358b0e2c7 Mon Sep 17 00:00:00 2001 From: Christoph Willing Date: Mon, 23 Jan 2017 17:49:12 +1000 Subject: [PATCH 31/45] Add support for LIB_SUFFIX Signed-off-by: Christoph Willing --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0f5511..6b490ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ option(UTPP_AMPLIFY_WARNINGS "Set this to OFF if you wish to use CMake default warning levels; should generally only use to work around support issues for your specific compiler" ON) +set(LIB_SUFFIX "" CACHE STRING "Identifier to add to end of lib directory name e.g. 64 for lib64") + if(MSVC14 OR MSVC12) # has the support we need else() @@ -92,10 +94,10 @@ else() set (UTPP_INSTALL_DESTINATION "include/UnitTestPP") endif() -set(config_install_dir_ lib/cmake/${PROJECT_NAME}) +set(config_install_dir_ lib${LIB_SUFFIX}/cmake/${PROJECT_NAME}) set(targets_export_name_ "${PROJECT_NAME}Targets") -install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib) +install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib${LIB_SUFFIX}) install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION}) install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_}) install(FILES cmake/UnitTest++Config.cmake DESTINATION "${config_install_dir_}") @@ -103,13 +105,13 @@ install(EXPORT "${targets_export_name_}" DESTINATION "${config_install_dir_}") set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) -set(libdir ${CMAKE_INSTALL_PREFIX}/lib) +set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) set(includedir ${CMAKE_INSTALL_PREFIX}/include/UnitTest++) configure_file("UnitTest++.pc.in" "UnitTest++.pc" @ONLY) if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig) else() - set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) + set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig) endif() install(FILES "${CMAKE_CURRENT_BINARY_DIR}/UnitTest++.pc" DESTINATION "${pkgconfdir}") From d7bd757862916cca0c4888070c9c929a8a9bd089 Mon Sep 17 00:00:00 2001 From: timdave13 Date: Thu, 2 Feb 2017 17:14:27 -0500 Subject: [PATCH 32/45] fix clang warning fix clang warning: 'X' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Wweak-vtables] --- UnitTest++/TestMacros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/UnitTest++/TestMacros.h b/UnitTest++/TestMacros.h index d6bc204..8ff87f8 100644 --- a/UnitTest++/TestMacros.h +++ b/UnitTest++/TestMacros.h @@ -49,10 +49,12 @@ explicit Fixture ## Name ## Helper(UnitTest::TestDetails const& details) : m_details(details) {} \ void RunImpl(); \ UnitTest::TestDetails const& m_details; \ + virtual ~Fixture ## Name ## Helper(); \ private: \ Fixture ## Name ## Helper(Fixture ## Name ## Helper const&); \ Fixture ## Name ## Helper& operator =(Fixture ## Name ## Helper const&); \ }; \ + Fixture ## Name ## Helper::~Fixture ## Name ## Helper(){}; \ \ class Test ## Fixture ## Name : public UnitTest::Test \ { \ @@ -60,9 +62,9 @@ Test ## Fixture ## Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \ private: \ virtual void RunImpl() const; \ - } test ## Fixture ## Name ## Instance; \ + } static test ## Fixture ## Name ## Instance; \ \ - UnitTest::ListAdder adder ## Fixture ## Name (List, &test ## Fixture ## Name ## Instance); \ + static UnitTest::ListAdder adder ## Fixture ## Name (List, &test ## Fixture ## Name ## Instance); \ \ void Test ## Fixture ## Name::RunImpl() const \ { \ From 0a6857e3883175a5682bc2a7df9e7b53f73f53a9 Mon Sep 17 00:00:00 2001 From: Tim Bochenek Date: Thu, 2 Feb 2017 18:03:59 -0500 Subject: [PATCH 33/45] fix clang warning fix clang warning 'extra ';' outside function is c++11 extension --- UnitTest++/TestMacros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTest++/TestMacros.h b/UnitTest++/TestMacros.h index 8ff87f8..dbe3430 100644 --- a/UnitTest++/TestMacros.h +++ b/UnitTest++/TestMacros.h @@ -54,7 +54,7 @@ Fixture ## Name ## Helper(Fixture ## Name ## Helper const&); \ Fixture ## Name ## Helper& operator =(Fixture ## Name ## Helper const&); \ }; \ - Fixture ## Name ## Helper::~Fixture ## Name ## Helper(){}; \ + Fixture ## Name ## Helper::~Fixture ## Name ## Helper(){} \ \ class Test ## Fixture ## Name : public UnitTest::Test \ { \ From 0b15459ee4fbee824c6a699d4c64fba8e49b8339 Mon Sep 17 00:00:00 2001 From: Gabriel Hare Date: Thu, 2 Feb 2017 21:56:48 -0800 Subject: [PATCH 34/45] Downgrade message to STATUS and do not declare C++11 as a requirement. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c39baf..2ed7b67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") if (MSVC14 OR MSVC12) # has the support we need else() - message(WARNING "The MSVC compiler version does not support required C++11 features. Please use a different C++ compiler.") + message(STATUS "The MSVC compiler version does not support UnitTest++ C++11 features.") endif() else() include(CheckCXXCompilerFlag) @@ -28,7 +28,7 @@ else() elseif(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() - message(WARNING "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") endif() endif() From 07d4872076b3b7d824149186a230f54ef5cd04df Mon Sep 17 00:00:00 2001 From: Tim Bochenek Date: Fri, 3 Feb 2017 08:19:17 -0500 Subject: [PATCH 35/45] fix clang warnings fix clang warning warning: no previous extern declaration for non-static variable 'X' [-Wmissing-variable-declarations] --- UnitTest++/TestMacros.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UnitTest++/TestMacros.h b/UnitTest++/TestMacros.h index dbe3430..0c8e903 100644 --- a/UnitTest++/TestMacros.h +++ b/UnitTest++/TestMacros.h @@ -25,16 +25,16 @@ } \ namespace Suite ## Name -#define UNITTEST_IMPL_TEST(Name, List) \ +#define UNITTEST_IMPL_TEST(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; \ + } static test ## Name ## Instance; \ \ - UnitTest::ListAdder adder ## Name (List, &test ## Name ## Instance); \ + static UnitTest::ListAdder adder ## Name (List, &test ## Name ## Instance); \ \ void Test ## Name::RunImpl() const @@ -62,9 +62,9 @@ Test ## Fixture ## Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \ private: \ virtual void RunImpl() const; \ - } static test ## Fixture ## Name ## Instance; \ + } static test ## Fixture ## Name ## Instance; \ \ - static UnitTest::ListAdder adder ## Fixture ## Name (List, &test ## Fixture ## Name ## Instance); \ + static UnitTest::ListAdder adder ## Fixture ## Name (List, &test ## Fixture ## Name ## Instance); \ \ void Test ## Fixture ## Name::RunImpl() const \ { \ From 33e63147539750304216b22b01c8968432c959b8 Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Mon, 22 May 2017 00:22:38 +0900 Subject: [PATCH 36/45] Added autogen.sh file to ease autotools installation --- autogen.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 autogen.sh diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..347366d --- /dev/null +++ b/autogen.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +test -e ./.autotools_aux || mkdir .autotools_aux + +libtoolize -cq +aclocal -I m4 --install # Generate aclocal +autoconf # Generate configure script +autoheader # Generate config.h +automake --add-missing --copy # Generate Makefile.in and other scripts From a6fdaeef1269e50c8777989d4338cc39a5a0f6a3 Mon Sep 17 00:00:00 2001 From: Martin Moene Date: Sat, 8 Jul 2017 11:09:38 +0200 Subject: [PATCH 37/45] Use if (MSVC) as per issue #160 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e60f81b..a683ea1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ option(UTPP_AMPLIFY_WARNINGS set(LIB_SUFFIX "" CACHE STRING "Identifier to add to end of lib directory name e.g. 64 for lib64") -if(${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") +if (MSVC) # CHECK_CXX_COMPILER_FLAG could be used # but MSVC version is preferred for feature requirements if (MSVC14 OR MSVC12) From a7d506d7ebbea35cc089b319443cd899d440132c Mon Sep 17 00:00:00 2001 From: Flow86 Date: Wed, 20 Mar 2019 13:19:15 +0100 Subject: [PATCH 38/45] add support to build unittest cpp on AIX (IBM) --- UnitTest++/Config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTest++/Config.h b/UnitTest++/Config.h index 4bebf1a..14429ee 100644 --- a/UnitTest++/Config.h +++ b/UnitTest++/Config.h @@ -22,7 +22,7 @@ #if defined(unix) || defined(__unix__) || defined(__unix) || defined(linux) || \ defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) \ - || defined (__HAIKU__) + || defined (__HAIKU__) || defined(_AIX) #define UNITTEST_POSIX #endif From bdef2bdd62598afc31e17b24349b47d3813eed57 Mon Sep 17 00:00:00 2001 From: Dan Huantes Date: Wed, 14 Aug 2019 11:32:00 -0500 Subject: [PATCH 39/45] UnitTest++ now correctly supports CMake's find_package config mode [CMakeLists.txt] - Bumped cmake minimum requirement to go to 3.0 as this appears to be earliest version that transitive usage requirements are supported. - Added version to project so that is evident when looking at CMakeLists.txt - Removed include_directories as that command affects more than just UnitTest++ in favor of target_include_directories. - The target_include_directories uses the generator expressions to do the same thing for the BUILD_INTERFACE condition but only affects UnitTest++. The INSTALL_INTERFACE ensures that when UnitTest++ is installed client applications calling find_package for UnitTest++ only have to add the UnitTest++ target to the target_link_libraries and will get the correct include path for UnitTest++ added to their include paths. - Added DEBUG_POSTFIX to both library and unit test to distinguish them from each other as they are installed into the same directory and would otherwise overwrite one another. - Added Versioning using write_basic_package_version_file to the install so that a client can call find_package(UnitTest++ 2.1 REQUIRED) and it will be able to confirm the version. If the version is updated you could theoretically ahve a version 2.2, 2.3 ,etc... and the find_package mechanism will find the correct one. the SameMajorVersion option in that call indicates that 2.3 is compatible with 2.1 or in other words if find_package(UnitTest++ 2.1 REQUIRED) is called and 2.3 is installed that satisfies the condition but if only 3.0 was installed it will fail because of 'SameMajorVersion'. - Also added installation for the Version file. --- CMakeLists.txt | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a683ea1..03a4f62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8.1) -project(UnitTest++) +cmake_minimum_required(VERSION 3.0) +project(UnitTest++ VERSION 2.1) option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" @@ -74,7 +74,7 @@ endif() file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h) source_group( "" FILES ${TEST_SRCS}) add_executable(TestUnitTest++ ${TEST_SRCS}) -include_directories(.) + if(${UTPP_USE_PLUS_SIGN}) set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++) @@ -100,13 +100,30 @@ else() set (UTPP_INSTALL_DESTINATION "include/UnitTestPP") endif() +target_include_directories( UnitTest++ + PUBLIC + $ + $ + ) +set_target_properties(UnitTest++ PROPERTIES DEBUG_POSTFIX "-d") +set_target_properties(TestUnitTest++ PROPERTIES DEBUG_POSTFIX "-d") + set(config_install_dir_ lib${LIB_SUFFIX}/cmake/${PROJECT_NAME}) set(targets_export_name_ "${PROJECT_NAME}Targets") +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + cmake/UnitTest++ConfigVersion.cmake + VERSION ${UnitTest++_VERSION} + COMPATIBILITY SameMajorVersion + ) install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib${LIB_SUFFIX}) install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION}) install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_}) -install(FILES cmake/UnitTest++Config.cmake DESTINATION "${config_install_dir_}") +install(FILES + cmake/UnitTest++Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/cmake/UnitTest++ConfigVersion.cmake + DESTINATION "${config_install_dir_}") install(EXPORT "${targets_export_name_}" DESTINATION "${config_install_dir_}") set(prefix ${CMAKE_INSTALL_PREFIX}) From 2423fcac7668aa9c331a2dcf024c3ca06742942d Mon Sep 17 00:00:00 2001 From: Dan Huantes Date: Thu, 15 Aug 2019 08:26:41 -0500 Subject: [PATCH 40/45] CrasingTestsAreReportedAsFailures no longer core dumps on Clang Release Found that Crashing tests at some point in Clang history were actually caught but testing on Clang 6.0 and Clang 7.0 this is not the case. So added Clang to the list of compilers that don't run this tests. Noted that several other Pull Requests were failing for the same reason. --- tests/TestTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestTest.cpp b/tests/TestTest.cpp index 5a4e1ca..0db0650 100644 --- a/tests/TestTest.cpp +++ b/tests/TestTest.cpp @@ -72,7 +72,7 @@ namespace { CHECK_EQUAL(1, results.GetFailureCount()); } -#if !defined(UNITTEST_MINGW) && !defined(UNITTEST_WIN32) +#if !defined(UNITTEST_MINGW) && !defined(UNITTEST_WIN32) && !defined(__clang__) // Skip this test in debug because some debuggers don't like it. #if defined(NDEBUG) TEST(CrashingTestsAreReportedAsFailures) From c26966668191029f50d3e9f7318e176e5bbd74fc Mon Sep 17 00:00:00 2001 From: Dan Huantes Date: Thu, 17 Oct 2019 08:23:46 -0500 Subject: [PATCH 41/45] Version made explicitly 3 parts - Updated to appveyor.yml and configure.ac to 2.1.0 to match CMake project version. --- CMakeLists.txt | 2 +- appveyor.yml | 2 +- configure.ac | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03a4f62..7a3fb55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.0) -project(UnitTest++ VERSION 2.1) +project(UnitTest++ VERSION 2.1.0) option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" diff --git a/appveyor.yml b/appveyor.yml index bebe4f5..3a4637d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 2.0.0.{build} +version: 2.1.0.{build} os: - Windows Server 2012 R2 diff --git a/configure.ac b/configure.ac index 56300a6..372f576 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ AM_CONDITIONAL([WINDOWS], LT_INIT() -AC_SUBST([LIBUNITTEST_SO_VERSION], [2:0:0]) +AC_SUBST([LIBUNITTEST_SO_VERSION], [2:1:0]) # Checks for programs. AC_PROG_CXX From f871471d9020788eb0c05582f6430cca36397424 Mon Sep 17 00:00:00 2001 From: Dan Huantes Date: Tue, 7 Apr 2020 18:07:24 -0500 Subject: [PATCH 42/45] Added Namespace to Exported Target [CMakeLists.txt] - It is standard practice to have a namespace for an imported target. Added UnitTest++:: as the namespace argument so that find_package(UnitTest++) will result in UnitTest++::UnitTest++ target that will be used in target_link_libraries. - Updated target_link_libraries for TestUnitTest++ as an example --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a3fb55..b4c75c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,8 @@ source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_}) # create the lib add_library(UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_}) +add_library(UnitTest++::UnitTest++ ALIAS UnitTest++) + if(${UTPP_USE_PLUS_SIGN}) set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++) @@ -80,7 +82,10 @@ if(${UTPP_USE_PLUS_SIGN}) set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++) endif() -target_link_libraries(TestUnitTest++ UnitTest++) +target_link_libraries(TestUnitTest++ + PUBLIC + UnitTest++::UnitTest++ + ) # run unit tests as post build step add_custom_command(TARGET TestUnitTest++ @@ -124,7 +129,7 @@ install(FILES cmake/UnitTest++Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake/UnitTest++ConfigVersion.cmake DESTINATION "${config_install_dir_}") -install(EXPORT "${targets_export_name_}" DESTINATION "${config_install_dir_}") +install(EXPORT "${targets_export_name_}" NAMESPACE "UnitTest++::" DESTINATION "${config_install_dir_}") set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) From 37df68be21fd3bcadea0c54fe5e7d5176c1801ce Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Mon, 17 Aug 2020 19:53:58 -0500 Subject: [PATCH 43/45] Add hiatus note & link to issue --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7c138a8..e0b2978 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +> ### Maintenance of UnitTest++, recently sporadic, is officially on hiatus until 1 October 2020. Subscribe to https://github.com/unittest-cpp/unittest-cpp/issues/180 for updates. + + [![Build Status](https://travis-ci.org/unittest-cpp/unittest-cpp.svg?branch=master)](https://travis-ci.org/unittest-cpp/unittest-cpp) [![Build status](https://ci.appveyor.com/api/projects/status/ffs2k8dddts5cyok/branch/master?svg=true)](https://ci.appveyor.com/project/pjohnmeyer/unittest-cpp/branch/master) From 854cae2518d280f732b593cbc9a1c305cb6a753a Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Thu, 1 Oct 2020 19:56:11 -0500 Subject: [PATCH 44/45] Extend hiatus to 15 October See #180 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e0b2978..8de8c90 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -> ### Maintenance of UnitTest++, recently sporadic, is officially on hiatus until 1 October 2020. Subscribe to https://github.com/unittest-cpp/unittest-cpp/issues/180 for updates. +> ### Maintenance of UnitTest++, recently sporadic, is officially on hiatus until 15 October 2020. Subscribe to https://github.com/unittest-cpp/unittest-cpp/issues/180 for updates. [![Build Status](https://travis-ci.org/unittest-cpp/unittest-cpp.svg?branch=master)](https://travis-ci.org/unittest-cpp/unittest-cpp) From 10e50ad70c696002b1d5bbefd0ea04b3ea92a03b Mon Sep 17 00:00:00 2001 From: Patrick Johnmeyer Date: Thu, 12 Nov 2020 23:26:38 -0600 Subject: [PATCH 45/45] Extend hiatus to 26 November --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8de8c90..6ece10e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -> ### Maintenance of UnitTest++, recently sporadic, is officially on hiatus until 15 October 2020. Subscribe to https://github.com/unittest-cpp/unittest-cpp/issues/180 for updates. +> ### Maintenance of UnitTest++, recently sporadic, is officially on hiatus until 26 November 2020. Subscribe to https://github.com/unittest-cpp/unittest-cpp/issues/180 for updates. [![Build Status](https://travis-ci.org/unittest-cpp/unittest-cpp.svg?branch=master)](https://travis-ci.org/unittest-cpp/unittest-cpp)