diff options
author | Jacob Abel <jacobabel@nullpo.dev> | 2022-05-21 22:34:11 -0400 |
---|---|---|
committer | Jacob Abel <jacobabel@nullpo.dev> | 2022-10-23 17:50:20 -0400 |
commit | febff1dccd2c173472fe4a6bed2e620429c5b1ba (patch) | |
tree | 4d66beccb6704f2f897b5de7afcf22aa3d8ca70b /lib/tests | |
parent | 86ad681303d9bc567cca762b239f3fde0b951d64 (diff) |
lib/strings: allow toInt to parse zero-padded strings
Diffstat (limited to 'lib/tests')
-rw-r--r-- | lib/tests/misc.nix | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 8e0cf1f45bb60..ef4483219f7eb 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -327,6 +327,34 @@ runTests { expected = "Hello\\x20World"; }; + testToInt = testAllTrue [ + # Naive + (123 == toInt "123") + (0 == toInt "0") + # Whitespace Padding + (123 == toInt " 123") + (123 == toInt "123 ") + (123 == toInt " 123 ") + (123 == toInt " 123 ") + (0 == toInt " 0") + (0 == toInt "0 ") + (0 == toInt " 0 ") + # Zero Padding + (123 == toInt "0123") + (123 == toInt "0000123") + (0 == toInt "000000") + # Whitespace and Zero Padding + (123 == toInt " 0123") + (123 == toInt "0123 ") + (123 == toInt " 0123 ") + (123 == toInt " 0000123") + (123 == toInt "0000123 ") + (123 == toInt " 0000123 ") + (0 == toInt " 000000") + (0 == toInt "000000 ") + (0 == toInt " 000000 ") + ]; + # LISTS testFilter = { |