From cf2491a9c2062af1da61c128e45cfe14869c5edf Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 7 Jan 2022 18:45:16 +0000 Subject: Don't invoke CHECK parameters multiple times --- test/test-helpers.hpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/test-helpers.hpp b/test/test-helpers.hpp index d99e1fa..5ebbea9 100644 --- a/test/test-helpers.hpp +++ b/test/test-helpers.hpp @@ -3,13 +3,19 @@ #include #include -#define BOOST_CHECK_CLOSE_VEC(a, b) \ - BOOST_TEST_CONTEXT("BOOST_CHECK_CLOSE_VEC(" << a << ", " << b << ")") { \ - BOOST_CHECK_LT(glm::length(a - b), 0.1F); \ +#define BOOST_CHECK_CLOSE_VEC(a_, b_) \ + { \ + const auto a {a_}, b {b_}; \ + BOOST_TEST_CONTEXT("BOOST_CHECK_CLOSE_VEC(" << a << ", " << b << ")") { \ + BOOST_CHECK_LT(glm::length(a - b), 0.1F); \ + } \ } -#define BOOST_CHECK_BETWEEN(a, b, c) \ - BOOST_TEST_CONTEXT("BOOST_CHECK_BETWEEN(" << a << ", " << b << ", " << c << ")") { \ - BOOST_CHECK_LE(b, a); \ - BOOST_CHECK_GE(c, a); \ +#define BOOST_CHECK_BETWEEN(a_, b_, c_) \ + { \ + const auto a {a_}, b {b_}, c {c_}; \ + BOOST_TEST_CONTEXT("BOOST_CHECK_BETWEEN(" << a << ", " << b << ", " << c << ")") { \ + BOOST_CHECK_LE(b, a); \ + BOOST_CHECK_GE(c, a); \ + } \ } -- cgit v1.2.3