From c1d147616b50183e4af73c779521e433161f2956 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Fri, 3 Oct 2025 19:08:10 -0600 Subject: [PATCH 1/2] Fixed minor errors in run_tests_cppunit.h --- unit-tests/run_tests_cppunit.h | 37 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/unit-tests/run_tests_cppunit.h b/unit-tests/run_tests_cppunit.h index 2f15e988e..3c69a2e68 100644 --- a/unit-tests/run_tests_cppunit.h +++ b/unit-tests/run_tests_cppunit.h @@ -43,11 +43,13 @@ bool debug = false; #undef DBG -#define DBG(x) \ - do { \ - if (debug) \ - (x); \ - } while (false) +#define DBG(x) do { if (debug) (x); } while (false) + +bool debug2 = false; + +#undef DBG2 +#define DBG2(x) do { if (debug2) (x); } while (false) + /** * @brief Run the test(s) @@ -68,7 +70,7 @@ template bool run_tests(int argc, char *argv[]) { debug = true; // debug is a global break; case 'D': - debug = true; // debug is a global + debug2 = true; // debug is a global break; case 'h': { // help - show test names std::cerr << "Usage: the following tests can be run individually or in combination:" << std::endl; @@ -86,19 +88,20 @@ template bool run_tests(int argc, char *argv[]) { argc -= optind; argv += optind; - if (0 == argc) { // run them all + if (0 == argc) { + // run them all return runner.run(""); - } else { - bool wasSuccessful = true; - int i = 0; - while (i < argc) { - std::string test = CLASS::suite()->getName().append("::").append(argv[i++]); - if (debug) - std::cerr << "Running " << test << std::endl; - wasSuccessful = wasSuccessful && runner.run(test); - } - return wasSuccessful; } + + bool wasSuccessful = true; + int i = 0; + while (i < argc) { + std::string test = CLASS::suite()->getName().append("::").append(argv[i++]); + if (debug) + std::cerr << "Running " << test << std::endl; + wasSuccessful = wasSuccessful && runner.run(test); + } + return wasSuccessful; } #endif // HYRAX_GIT_RUN_TESTS_CPPUNIT_H From e0068be9f28e84066cb5051f35ef62b9feeca27e Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Fri, 6 Mar 2026 18:37:04 -0700 Subject: [PATCH 2/2] Fixed the DBG macros when they hold 2++ statements --- unit-tests/DmrRoundTripTest.cc | 20 -------------------- unit-tests/run_tests_cppunit.h | 13 ++++++++++--- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/unit-tests/DmrRoundTripTest.cc b/unit-tests/DmrRoundTripTest.cc index 3d8b2e4dd..49b8a5a31 100644 --- a/unit-tests/DmrRoundTripTest.cc +++ b/unit-tests/DmrRoundTripTest.cc @@ -24,9 +24,6 @@ #include "config.h" -#include -#include - #include #include "Array.h" @@ -45,23 +42,6 @@ #include "testFile.h" #include "test_config.h" -static bool debug2 = false; - -#undef DBG -#define DBG(x) \ - do { \ - if (debug) { \ - x; \ - } \ - } while (false) -#undef DBG2 -#define DBG2(x) \ - do { \ - if (debug2) { \ - x; \ - } \ - } while (false) - using namespace CppUnit; using namespace std; using namespace libdap; diff --git a/unit-tests/run_tests_cppunit.h b/unit-tests/run_tests_cppunit.h index 3c69a2e68..f4291d14d 100644 --- a/unit-tests/run_tests_cppunit.h +++ b/unit-tests/run_tests_cppunit.h @@ -43,13 +43,20 @@ bool debug = false; #undef DBG -#define DBG(x) do { if (debug) (x); } while (false) +#define DBG(x) \ + do { \ + if (debug) \ + x; \ + } while (false) bool debug2 = false; #undef DBG2 -#define DBG2(x) do { if (debug2) (x); } while (false) - +#define DBG2(x) \ + do { \ + if (debug2) \ + x; \ + } while (false) /** * @brief Run the test(s)