diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-17 17:31:47 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-17 17:31:47 +0200 |
commit | fde8838316f3f73e91ddc4e203a9a2a6c0ac327b (patch) | |
tree | cfa05453dd13f308222de4b017bbe8ef8566b32e /tests | |
parent | 69bcda3dd2d9c181c0f5d72a57b49eed4a10f54c (diff) | |
parent | c60ac64e8fa16ffc092c6c773ebe49a1312045cd (diff) |
Merge pull request #67463 from aaronfranke/num-real-negative
Fix big negative numbers printing incorrect decimals in `num_real`
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/string/test_string.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index cf34caac28..cd1b421ce8 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -411,9 +411,13 @@ TEST_CASE("[String] Number to string") { CHECK(String::num_real(3.141593) == "3.141593"); CHECK(String::num_real(3.141) == "3.141"); // No trailing zeros. #ifdef REAL_T_IS_DOUBLE + CHECK_MESSAGE(String::num_real(123.456789) == "123.456789", "Prints the appropriate amount of digits for real_t = double."); + CHECK_MESSAGE(String::num_real(-123.456789) == "-123.456789", "Prints the appropriate amount of digits for real_t = double."); CHECK_MESSAGE(String::num_real(Math_PI) == "3.14159265358979", "Prints the appropriate amount of digits for real_t = double."); CHECK_MESSAGE(String::num_real(3.1415f) == "3.1414999961853", "Prints more digits of 32-bit float when real_t = double (ones that would be reliable for double) and no trailing zero."); #else + CHECK_MESSAGE(String::num_real(123.456789) == "123.4568", "Prints the appropriate amount of digits for real_t = float."); + CHECK_MESSAGE(String::num_real(-123.456789) == "-123.4568", "Prints the appropriate amount of digits for real_t = float."); CHECK_MESSAGE(String::num_real(Math_PI) == "3.141593", "Prints the appropriate amount of digits for real_t = float."); CHECK_MESSAGE(String::num_real(3.1415f) == "3.1415", "Prints only reliable digits of 32-bit float when real_t = float."); #endif // REAL_T_IS_DOUBLE |