From 73dd293ec4ffcfefae9db8e10eaaa84d4a4be4a8 Mon Sep 17 00:00:00 2001 From: Nicholas-Baron Date: Thu, 15 Apr 2021 00:36:14 -0700 Subject: Everywhere: Add `-Wdouble-promotion` warning This warning informs of float-to-double conversions. The best solution seems to be to do math *either* in 32-bit *or* in 64-bit, and only to cross over when absolutely necessary. --- AK/TestSuite.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'AK') diff --git a/AK/TestSuite.h b/AK/TestSuite.h index 60819694b3..c2cac55543 100644 --- a/AK/TestSuite.h +++ b/AK/TestSuite.h @@ -325,15 +325,15 @@ using AK::TestSuite; } \ } while (false) -#define EXPECT_APPROXIMATE(a, b) \ - do { \ - auto expect_close_lhs = a; \ - auto expect_close_rhs = b; \ - auto expect_close_diff = expect_close_lhs - expect_close_rhs; \ - if (fabs(expect_close_diff) >= 0.000001) { \ - warnln("\033[31;1mFAIL\033[0m: {}:{}: EXPECT_APPROXIMATE({}, {})" \ - " failed with lhs={}, rhs={}, (lhs-rhs)={}", \ - __FILE__, __LINE__, #a, #b, expect_close_lhs, expect_close_rhs, expect_close_diff); \ - current_test_case_did_fail(); \ - } \ +#define EXPECT_APPROXIMATE(a, b) \ + do { \ + auto expect_close_lhs = a; \ + auto expect_close_rhs = b; \ + auto expect_close_diff = static_cast(expect_close_lhs) - static_cast(expect_close_rhs); \ + if (abs(expect_close_diff) >= 0.000001) { \ + warnln("\033[31;1mFAIL\033[0m: {}:{}: EXPECT_APPROXIMATE({}, {})" \ + " failed with lhs={}, rhs={}, (lhs-rhs)={}", \ + __FILE__, __LINE__, #a, #b, expect_close_lhs, expect_close_rhs, expect_close_diff); \ + current_test_case_did_fail(); \ + } \ } while (false) -- cgit v1.2.3