diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-01-17 16:55:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-17 16:55:34 +0100 |
commit | 24f8a5979c5cfab3f7b3bccdfb27973918d3ae0c (patch) | |
tree | 8c68dbbdacd2a7e028d4a0e12007c0c331abca09 /tests/core/string/test_string.h | |
parent | b315295ffcd53b74af8c36fa2abac5e957f88613 (diff) | |
parent | 13939734e05e231f63e5bd7275d182491600e206 (diff) | |
download | redot-engine-24f8a5979c5cfab3f7b3bccdfb27973918d3ae0c.tar.gz |
Merge pull request #56809 from aaronfranke/replace-num-real
Diffstat (limited to 'tests/core/string/test_string.h')
-rw-r--r-- | tests/core/string/test_string.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index 2f611c26a9..baab5ddfe7 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -355,11 +355,17 @@ TEST_CASE("[String] Number to string") { CHECK(String::num(42.100023, 4) == "42.1"); // No trailing zeros. // String::num_real tests. + CHECK(String::num_real(1.0) == "1.0"); + CHECK(String::num_real(1.0, false) == "1"); + CHECK(String::num_real(9.9) == "9.9"); + CHECK(String::num_real(9.99) == "9.99"); + CHECK(String::num_real(9.999) == "9.999"); + CHECK(String::num_real(9.9999) == "9.9999"); 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(Math_PI) == "3.14159265358979", "Prints the appropriate amount of digits for real_t = double."); - CHECK_MESSAGE(String::num_real(3.1415f) == "3.14149999618530", "Prints more digits of 32-bit float when real_t = double (ones that would be reliable for 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(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."); |