1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

strconv: add test_atof_converter to the tests, as suggested by the code review

This commit is contained in:
Delyan Angelov 2022-11-21 07:41:41 +02:00
parent 6cd1723deb
commit c286775d9f
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -6,6 +6,29 @@ fn test_issue_16448() {
assert float_prec < 2.01 assert float_prec < 2.01
} }
fn test_atof_converter() {
mut float_prec := 1.9999999999999999 + 0.0000000000000000005
assert float_prec == 2.0
float_prec = 3.9999999999999999 + 0.0000000000000000005
assert float_prec == 4.0
float_prec = -3.9999999999999999 - 0.0000000000000000005
assert float_prec == -4.0
float_prec = -1.9999999999999999 - 0.0000000000000000005
assert float_prec == -2.0
float_prec = 0.025 + 0.0000000000000000005
assert float_prec == 0.025
float_prec = 0.0625 + 0.0000000000000000005
assert float_prec == 0.0625
float_prec = 0.0009765625 + 0.0000000000000000005
assert float_prec > 0.00097656250 && float_prec < 0.00097656251
float_prec = -0.025 - 0.0000000000000000005
assert float_prec == -0.025
float_prec = -0.0625 - 0.0000000000000000005
assert float_prec == -0.0625
float_prec = -0.0009765625 - 0.0000000000000000005
assert float_prec < -0.00097656250 && float_prec > -0.00097656251
}
// Testing all the numbers between -100E6..100E6 takes over a minute with clang on i3 // Testing all the numbers between -100E6..100E6 takes over a minute with clang on i3
// while for just -1E5..1E5, it takes less than a second. // while for just -1E5..1E5, it takes less than a second.
// const r = i64(100_000_001) // const r = i64(100_000_001)