diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibTest/Macros.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibTest/Macros.h b/Userland/Libraries/LibTest/Macros.h index dff131fccc..ee500be688 100644 --- a/Userland/Libraries/LibTest/Macros.h +++ b/Userland/Libraries/LibTest/Macros.h @@ -98,12 +98,12 @@ void current_test_case_did_fail(); } \ } while (false) -#define EXPECT_APPROXIMATE(a, b) \ +#define EXPECT_APPROXIMATE_WITH_ERROR(a, b, err) \ 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 (AK::fabs(expect_close_diff) > 0.0000005) { \ + if (AK::fabs(expect_close_diff) > (err)) { \ ::AK::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); \ @@ -111,6 +111,8 @@ void current_test_case_did_fail(); } \ } while (false) +#define EXPECT_APPROXIMATE(a, b) EXPECT_APPROXIMATE_WITH_ERROR(a, b, 0.0000005) + #define FAIL(message) \ do { \ ::AK::warnln("\033[31;1mFAIL\033[0m: {}:{}: {}", __FILE__, __LINE__, message); \ |