From 55b7b72806ad5df79cf84e367b02330d6a1e0bb9 Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 16 Aug 2024 16:10:56 +0200 Subject: [PATCH] testrunner: removed pointless and barely used `CHECK_EQUALS` and `EXPECT_EQ` --- test/fixture.h | 6 +++--- test/testsuppressions.cpp | 6 +++--- test/testvarid.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/fixture.h b/test/fixture.h index 465a249ebbfe..5ceb8699e661 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -295,11 +295,11 @@ class TestInstance { std::unique_ptr impl; }; -// TODO: the asserts do not actually assert i.e. do stop executing the test #define TEST_CASE( NAME ) do { if (prepareTest(#NAME)) { setVerbose(false); try { NAME(); teardownTest(); } catch (...) { assertNoThrowFail(__FILE__, __LINE__); } } } while (false) + +// TODO: the asserts do not actually assert i.e. do stop executing the test #define ASSERT( CONDITION ) assert_(__FILE__, __LINE__, (CONDITION)) #define ASSERT_LOC( CONDITION, FILE_, LINE_ ) assert_(FILE_, LINE_, (CONDITION)) -#define CHECK_EQUALS( EXPECTED, ACTUAL ) assertEquals(__FILE__, __LINE__, (EXPECTED), (ACTUAL)) // *INDENT-OFF* #define ASSERT_EQUALS( EXPECTED, ACTUAL ) do { try { assertEquals(__FILE__, __LINE__, (EXPECTED), (ACTUAL)); } catch (...) { assertNoThrowFail(__FILE__, __LINE__); } } while (false) // *INDENT-ON* @@ -317,7 +317,7 @@ class TestInstance { #define TODO_ASSERT_THROW( CMD, EXCEPTION ) do { try { (void)(CMD); } catch (const EXCEPTION&) {} catch (...) { assertThrow(__FILE__, __LINE__); } } while (false) #define TODO_ASSERT( CONDITION ) do { const bool condition=(CONDITION); todoAssertEquals(__FILE__, __LINE__, true, false, condition); } while (false) #define TODO_ASSERT_EQUALS( WANTED, CURRENT, ACTUAL ) todoAssertEquals(__FILE__, __LINE__, WANTED, CURRENT, ACTUAL) -#define EXPECT_EQ( EXPECTED, ACTUAL ) assertEquals(__FILE__, __LINE__, EXPECTED, ACTUAL) + #define REGISTER_TEST( CLASSNAME ) namespace { class CLASSNAME ## Instance : public TestInstance { public: CLASSNAME ## Instance() : TestInstance(#CLASSNAME) {} TestFixture* create() override { impl.reset(new CLASSNAME); return impl.get(); } }; CLASSNAME ## Instance instance_ ## CLASSNAME; } #define PLATFORM( P, T ) do { std::string errstr; assertEquals(__FILE__, __LINE__, true, P.set(Platform::toString(T), errstr, {exename}), errstr); } while (false) diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 4fa552679ec6..b05d23726008 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -245,7 +245,7 @@ class TestSuppressions : public TestFixture { if (suppression == "unusedFunction") settings.checks.setEnabled(Checks::unusedFunction, true); if (!suppression.empty()) { - EXPECT_EQ("", settings.supprs.nomsg.addSuppressionLine(suppression)); + ASSERT_EQUALS("", settings.supprs.nomsg.addSuppressionLine(suppression)); } std::vector> scopedfiles; @@ -288,7 +288,7 @@ class TestSuppressions : public TestFixture { $.inlineSuppressions = true); settings.severity.enable(Severity::information); if (!suppression.empty()) { - EXPECT_EQ("", settings.supprs.nomsg.addSuppressionLine(suppression)); + ASSERT_EQUALS("", settings.supprs.nomsg.addSuppressionLine(suppression)); } std::vector> scopedfiles; @@ -332,7 +332,7 @@ class TestSuppressions : public TestFixture { $.inlineSuppressions = true); settings.severity.enable(Severity::information); if (!suppression.empty()) { - EXPECT_EQ("", settings.supprs.nomsg.addSuppressionLine(suppression)); + ASSERT_EQUALS("", settings.supprs.nomsg.addSuppressionLine(suppression)); } std::vector> scopedfiles; diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 222906177d70..9522ffee101a 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -275,7 +275,7 @@ class TestVarID : public TestFixture { Tokenizer tokenizer(settings, *this); std::istringstream istr(code); ASSERT_LOC(tokenizer.list.createTokens(istr, filename), file, line); - EXPECT_EQ(true, tokenizer.simplifyTokens1("")); + ASSERT_EQUALS(true, tokenizer.simplifyTokens1("")); // result.. Token::stringifyOptions options = Token::stringifyOptions::forDebugVarId();