string: test i64() and u64()

pull/2349/head
Alexander Medvednikov 2019-10-15 04:26:19 +03:00
parent 10ed65bc12
commit 4b176ba855
2 changed files with 6 additions and 1 deletions

View File

@ -206,7 +206,7 @@ pub fn (s string) u32() u32 {
pub fn (s string) u64() u64 { pub fn (s string) u64() u64 {
$if tinyc { $if tinyc {
return u64(s.int()) // TODO return u64(s.i64()) // TODO
} $else { } $else {
return C.strtoull(*char(s.str), 0, 0) return C.strtoull(*char(s.str), 0, 0)
} }

View File

@ -276,6 +276,7 @@ fn test_arr_contains() {
fn test_to_num() { fn test_to_num() {
s := '7' s := '7'
assert s.int() == 7 assert s.int() == 7
assert s.u64() == 7
f := '71.5 hasdf' f := '71.5 hasdf'
assert f.f32() == 71.5 assert f.f32() == 71.5
b := 1.52345 b := 1.52345
@ -285,6 +286,9 @@ fn test_to_num() {
a = '${num:03d}' a = '${num:03d}'
vals := ['9'] vals := ['9']
assert vals[0].int() == 9 assert vals[0].int() == 9
big := '93993993939322'
assert big.u64() == 93993993939322
assert big.i64() == 93993993939322
} }
fn test_hash() { fn test_hash() {
@ -477,3 +481,4 @@ fn test_escape() {
//a := 10 //a := 10
//println("\"$a") //println("\"$a")
} }