diff options
author | Clay John <claynjohn@gmail.com> | 2024-10-24 19:41:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-24 19:41:43 -0700 |
commit | 33db59094729c15ce4802154b2649bc8dd18a449 (patch) | |
tree | a687c42e27347c429fdef9dff25c933256490a45 /tests/core | |
parent | a1c7998d5f1adb084d14c667c68a61dab0a368f1 (diff) | |
parent | b3b24ded19d5aeb015ab6633b2234f8c27b7c53e (diff) | |
download | redot-engine-33db59094729c15ce4802154b2649bc8dd18a449.tar.gz |
Merge pull request #98357 from yeojunh/valid-base-check-num-int64-uint64
Core: Fix String::num_int64(), uint64 for valid base check
Diffstat (limited to 'tests/core')
-rw-r--r-- | tests/core/string/test_string.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index 8559737e74..8d6137cf62 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -460,11 +460,27 @@ TEST_CASE("[String] Number to string") { CHECK(String::num(-0.0) == "-0"); // Includes sign even for zero. CHECK(String::num(3.141593) == "3.141593"); CHECK(String::num(3.141593, 3) == "3.142"); + CHECK(String::num(42.100023, 4) == "42.1"); // No trailing zeros. CHECK(String::num_scientific(30000000) == "3e+07"); + + // String::num_int64 tests. CHECK(String::num_int64(3141593) == "3141593"); + CHECK(String::num_int64(-3141593) == "-3141593"); CHECK(String::num_int64(0xA141593, 16) == "a141593"); CHECK(String::num_int64(0xA141593, 16, true) == "A141593"); - CHECK(String::num(42.100023, 4) == "42.1"); // No trailing zeros. + ERR_PRINT_OFF; + CHECK(String::num_int64(3141593, 1) == ""); // Invalid base < 2. + CHECK(String::num_int64(3141593, 37) == ""); // Invalid base > 36. + ERR_PRINT_ON; + + // String::num_uint64 tests. + CHECK(String::num_uint64(4294967295) == "4294967295"); + CHECK(String::num_uint64(0xF141593, 16) == "f141593"); + CHECK(String::num_uint64(0xF141593, 16, true) == "F141593"); + ERR_PRINT_OFF; + CHECK(String::num_uint64(4294967295, 1) == ""); // Invalid base < 2. + CHECK(String::num_uint64(4294967295, 37) == ""); // Invalid base > 36. + ERR_PRINT_ON; // String::num_real tests. CHECK(String::num_real(1.0) == "1.0"); |