You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
support float
This commit is contained in:
36
jsoniter_float_test.go
Normal file
36
jsoniter_float_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func Test_float64_0(t *testing.T) {
|
||||
iter := ParseString(`0`)
|
||||
val := iter.ReadFloat64()
|
||||
if val != 0 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_float64_1_dot_1(t *testing.T) {
|
||||
iter := ParseString(`1.1`)
|
||||
val := iter.ReadFloat64()
|
||||
if val != 1.1 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_jsoniter_float(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
iter := ParseString(`1.1`)
|
||||
iter.ReadFloat64()
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_json_float(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
result := float64(0)
|
||||
json.Unmarshal([]byte(`1.1`), &result)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user