tests: fix f32_f64_to_string_test.v
parent
e4fac6ff97
commit
a989e017fe
|
@ -3,7 +3,7 @@
|
||||||
* Float to string Test
|
* Float to string Test
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
import strconv.ftoa
|
import strconv
|
||||||
import math
|
import math
|
||||||
|
|
||||||
union Ufloat32 {
|
union Ufloat32 {
|
||||||
|
@ -140,7 +140,7 @@ fn test_float_to_str() {
|
||||||
// test f32
|
// test f32
|
||||||
for c,x in test_cases_f32 {
|
for c,x in test_cases_f32 {
|
||||||
println(x)
|
println(x)
|
||||||
s := ftoa.f32_to_str(x,8)
|
s := strconv.f32_to_str(x,8)
|
||||||
s1 := exp_result_f32[c]
|
s1 := exp_result_f32[c]
|
||||||
//println("$s1 $s")
|
//println("$s1 $s")
|
||||||
assert s == s1
|
assert s == s1
|
||||||
|
@ -148,7 +148,7 @@ fn test_float_to_str() {
|
||||||
|
|
||||||
// test f64
|
// test f64
|
||||||
for c,x in test_cases_f64 {
|
for c,x in test_cases_f64 {
|
||||||
s := ftoa.f64_to_str(x,17)
|
s := strconv.f64_to_str(x,17)
|
||||||
s1 := exp_result_f64[c]
|
s1 := exp_result_f64[c]
|
||||||
//println("$s1 $s")
|
//println("$s1 $s")
|
||||||
assert s == s1
|
assert s == s1
|
||||||
|
@ -156,11 +156,11 @@ fn test_float_to_str() {
|
||||||
|
|
||||||
// test long format
|
// test long format
|
||||||
for exp := 1 ; exp < 120 ; exp++ {
|
for exp := 1 ; exp < 120 ; exp++ {
|
||||||
a := ftoa.f64_to_str_l(("1e"+exp.str()).f64())
|
a := strconv.f64_to_str_l(("1e"+exp.str()).f64())
|
||||||
//println(a)
|
//println(a)
|
||||||
assert a.len == exp + 1
|
assert a.len == exp + 1
|
||||||
|
|
||||||
b := ftoa.f64_to_str_l(("1e-"+exp.str()).f64())
|
b := strconv.f64_to_str_l(("1e-"+exp.str()).f64())
|
||||||
//println(b)
|
//println(b)
|
||||||
assert b.len == exp + 2
|
assert b.len == exp + 2
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue