diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx index 88b62e5416..880f3ee4e7 100644 --- a/Tests/CMakeLib/testArgumentParser.cxx +++ b/Tests/CMakeLib/testArgumentParser.cxx @@ -16,6 +16,8 @@ #include "cmArgumentParser.h" #include "cmArgumentParserTypes.h" +#include "testCommon.h" + namespace { struct Result : public ArgumentParser::ParseResult @@ -182,14 +184,6 @@ bool verifyResult(Result const& result, static std::vector const unparsed = { "pos2", "bar", "ign1", "ign2", "ign4" }; -#define ASSERT_TRUE(x) \ - do { \ - if (!(x)) { \ - std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ - return false; \ - } \ - } while (false) - ASSERT_TRUE(!result); ASSERT_TRUE(result.Option1); diff --git a/Tests/CMakeLib/testJSONHelpers.cxx b/Tests/CMakeLib/testJSONHelpers.cxx index 50f0386567..68237ac6c1 100644 --- a/Tests/CMakeLib/testJSONHelpers.cxx +++ b/Tests/CMakeLib/testJSONHelpers.cxx @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -12,13 +11,7 @@ #include "cmJSONHelpers.h" #include "cmJSONState.h" -#define ASSERT_TRUE(x) \ - do { \ - if (!(x)) { \ - std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ - return false; \ - } \ - } while (false) +#include "testCommon.h" namespace { struct ObjectStruct diff --git a/Tests/CMakeLib/testOptional.cxx b/Tests/CMakeLib/testOptional.cxx index 933ab70504..eba2dd564a 100644 --- a/Tests/CMakeLib/testOptional.cxx +++ b/Tests/CMakeLib/testOptional.cxx @@ -4,6 +4,8 @@ #include #include +#include "testCommon.h" + class EventLogger; class Event @@ -93,14 +95,6 @@ public: NoMoveAssignEventLogger& operator=(NoMoveAssignEventLogger&&) = delete; }; -#define ASSERT_TRUE(x) \ - do { \ - if (!(x)) { \ - std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ - return false; \ - } \ - } while (false) - // Certain builds of GCC generate false -Wmaybe-uninitialized warnings when // doing a release build with the system version of std::optional. These // warnings do not manifest when using our own cm::optional implementation. diff --git a/Tests/CMakeLib/testRange.cxx b/Tests/CMakeLib/testRange.cxx index 36c1e18e47..64bc3d756c 100644 --- a/Tests/CMakeLib/testRange.cxx +++ b/Tests/CMakeLib/testRange.cxx @@ -1,19 +1,12 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include #include #include #include "cmRange.h" -#define ASSERT_TRUE(x) \ - do { \ - if (!(x)) { \ - std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ - return -1; \ - } \ - } while (false) +#include "testCommon.h" int testRange(int /*unused*/, char* /*unused*/[]) { diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx index 350926620c..d49f65f471 100644 --- a/Tests/CMakeLib/testString.cxx +++ b/Tests/CMakeLib/testString.cxx @@ -14,13 +14,7 @@ #include "cmString.hxx" -#define ASSERT_TRUE(x) \ - do { \ - if (!(x)) { \ - std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ - return false; \ - } \ - } while (false) +#include "testCommon.h" static bool testConstructDefault() {