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:

committed by
Alexander Medvednikov

parent
9374168b26
commit
f6ec1b29f9
11
vlib/builtin/string_int_test.v
Normal file
11
vlib/builtin/string_int_test.v
Normal 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user