mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
strconv: make string.int() stop parsing on invalid digit
This commit is contained in:
parent
9374168b26
commit
f6ec1b29f9
3 changed files with 58 additions and 30 deletions
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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue