From 2f1573237b02d1ef0e71991ce5834f30f60311f2 Mon Sep 17 00:00:00 2001 From: Metin Cakircali Date: Fri, 14 Jun 2024 18:55:12 +0200 Subject: [PATCH 1/2] test(macros): use ref instead of value in EXPECT_EQUAL macro --- src/eckit/testing/Test.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/eckit/testing/Test.h b/src/eckit/testing/Test.h index 23bf9d4bb..ffae4dd18 100644 --- a/src/eckit/testing/Test.h +++ b/src/eckit/testing/Test.h @@ -460,13 +460,13 @@ int run_tests(int argc, char* argv[], bool initEckitMain = true) { } while (false) #define EXPECT_EQUAL(a, b) \ - EXPECT_MSG(a == b, [=]() { \ + EXPECT_MSG(a == b, [&]() { \ std::cerr << eckit::Colour::red << "FAILED " << #a " == " << #b << " evaluated as [" << a << "] == [" << b \ << "]" << eckit::Colour::reset << std::endl; \ };) #define EXPECT_NOT_EQUAL(a, b) \ - EXPECT_MSG(a != b, [=]() { \ + EXPECT_MSG(a != b, [&]() { \ std::cerr << eckit::Colour::red << "FAILED " << #a " != " << #b << " evaluated as [" << a << "] != [" << b \ << "]" << eckit::Colour::reset << std::endl; \ };) From d6bb784241387baa5ef7a193fa5aa1e23763a144 Mon Sep 17 00:00:00 2001 From: Metin Cakircali Date: Fri, 14 Jun 2024 18:56:54 +0200 Subject: [PATCH 2/2] test(macros): variable 'msg' may shadow --- src/eckit/testing/Test.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/eckit/testing/Test.h b/src/eckit/testing/Test.h index ffae4dd18..da725534c 100644 --- a/src/eckit/testing/Test.h +++ b/src/eckit/testing/Test.h @@ -453,8 +453,8 @@ int run_tests(int argc, char* argv[], bool initEckitMain = true) { #define EXPECT_MSG(expr, msg_callback) \ do { \ if (!(expr)) { \ - auto msg = msg_callback; \ - msg(); \ + auto _msg = msg_callback; \ + _msg(); \ throw eckit::testing::TestException("Condition failed: " #expr, Here()); \ } \ } while (false)