From 6b16f96c8ac78b1eec4fbff47a52aaa94740e417 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Sun, 4 Dec 2016 15:20:46 +0100 Subject: [PATCH] Test macros: use defensive parentheses and std::fabs() for SG_CHECK_EQUAL_EP* Some of the modules where I previously removed duplicate private definitions of these macros had these features, and since they seem wise to me, I'm applying them to the canonical SG_CHECK_EQUAL_EP() and SG_CHECK_EQUAL_EP2() macros defined in simgear/misc/test_macros.hxx. --- simgear/misc/test_macros.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/simgear/misc/test_macros.hxx b/simgear/misc/test_macros.hxx index 12ac8f43..ee4f5314 100644 --- a/simgear/misc/test_macros.hxx +++ b/simgear/misc/test_macros.hxx @@ -2,7 +2,7 @@ #ifndef SG_MISC_TEST_MACROS_HXX #define SG_MISC_TEST_MACROS_HXX -#include // for fabs() +#include // for std::fabs() #define SG_CHECK_EQUAL(a, b) \ if ((a) != (b)) { \ @@ -20,7 +20,7 @@ } #define SG_CHECK_EQUAL_EP(a, b) \ - if (fabs(a - b) > SG_EPSILON) { \ + if (std::fabs((a) - (b)) > SG_EPSILON) { \ std::cerr << "failed with epsilon:" << #a << " != " << #b << std::endl; \ std::cerr << "\tgot:'" << a << "'" << std::endl; \ std::cerr << "\tat:" << __FILE__ << ":" << __LINE__ << std::endl; \ @@ -28,7 +28,7 @@ } #define SG_CHECK_EQUAL_EP2(a, b, ep) \ - if (fabs(a - b) > ep) { \ + if (std::fabs((a) - (b)) > ep) { \ std::cerr << "failed with epsilon:" << #a << " != " << #b << std::endl; \ std::cerr << "\tgot:'" << a << "'" << std::endl; \ std::cerr << "\tat:" << __FILE__ << ":" << __LINE__ << std::endl; \