summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorNicholas-Baron <nicholas.baron.ten@gmail.com>2021-04-15 00:36:14 -0700
committerAndreas Kling <kling@serenityos.org>2021-04-16 19:01:54 +0200
commit73dd293ec4ffcfefae9db8e10eaaa84d4a4be4a8 (patch)
tree835bd47b8c14f8af6b070f1adbeef630db28d5a9 /AK
parent6606d70826b21c803742ed2b971d061b7f3497e3 (diff)
downloadserenity-73dd293ec4ffcfefae9db8e10eaaa84d4a4be4a8.zip
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.
Diffstat (limited to 'AK')
-rw-r--r--AK/TestSuite.h22
1 files changed, 11 insertions, 11 deletions
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<double>(expect_close_lhs) - static_cast<double>(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)