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

strconv: make string.int() stop parsing on invalid digit

This commit is contained in:
bogen85
2019-11-28 00:46:10 -06:00
committed by Alexander Medvednikov
parent 9374168b26
commit f6ec1b29f9
3 changed files with 58 additions and 30 deletions

View File

@ -0,0 +1,11 @@
fn test_common_atoi() {
assert "70zzz".int() == 70
assert "2901issue".int() == 2901
assert '234232w'.int() == 234232
assert '-9009x'.int() == -9009
assert '0y'.int() == 0
for n in -10000 .. 100000 {
s := n.str()+"z"
assert s.int() == n
}
}