Skip to content

Commit

Permalink
strconv: more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Jul 16, 2020
1 parent f1b4af3 commit cb1009d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions vlib/strconv/atof_test.v
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module strconv
/**********************************************************************
*
* String to float Test
Expand Down
10 changes: 5 additions & 5 deletions vlib/strconv/f32_f64_to_string_test.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module strconv
/**********************************************************************
*
* Float to string Test
*
**********************************************************************/
import strconv
import math

union Ufloat32 {
Expand Down Expand Up @@ -140,27 +140,27 @@ fn test_float_to_str() {
// test f32
for c,x in test_cases_f32 {
println(x)
s := strconv.f32_to_str(x,8)
s := f32_to_str(x,8)
s1 := exp_result_f32[c]
//println("$s1 $s")
assert s == s1
}

// test f64
for c,x in test_cases_f64 {
s := strconv.f64_to_str(x,17)
s := f64_to_str(x,17)
s1 := exp_result_f64[c]
//println("$s1 $s")
assert s == s1
}

// test long format
for exp := 1 ; exp < 120 ; exp++ {
a := strconv.f64_to_str_l(("1e"+exp.str()).f64())
a := f64_to_str_l(("1e"+exp.str()).f64())
//println(a)
assert a.len == exp + 1

b := strconv.f64_to_str_l(("1e-"+exp.str()).f64())
b := f64_to_str_l(("1e-"+exp.str()).f64())
//println(b)
assert b.len == exp + 2
}
Expand Down

0 comments on commit cb1009d

Please sign in to comment.