1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

int/float/bool

This commit is contained in:
Tao Wen
2016-12-04 22:15:12 +08:00
parent fafa785306
commit d8153db791
3 changed files with 84 additions and 0 deletions

View File

@ -124,6 +124,36 @@ func Test_reflect_byte(t *testing.T) {
}
}
func Test_reflect_float32(t *testing.T) {
iter := ParseString(`1.23`)
val := float32(0)
iter.Read(&val)
if val != 1.23 {
fmt.Println(iter.Error)
t.Fatal(val)
}
}
func Test_reflect_float64(t *testing.T) {
iter := ParseString(`1.23`)
val := float64(0)
iter.Read(&val)
if val != 1.23 {
fmt.Println(iter.Error)
t.Fatal(val)
}
}
func Test_reflect_bool(t *testing.T) {
iter := ParseString(`true`)
val := false
iter.Read(&val)
if val != true {
fmt.Println(iter.Error)
t.Fatal(val)
}
}
type StructOfString struct {
field1 string
field2 string