You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-11-29 22:47:28 +02:00
support int/string encode
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
func Test_reflect_str(t *testing.T) {
|
||||
iter := ParseString(`"hello"`)
|
||||
str := ""
|
||||
iter.Read(&str)
|
||||
iter.ReadVal(&str)
|
||||
if str != "hello" {
|
||||
fmt.Println(iter.Error)
|
||||
t.Fatal(str)
|
||||
@@ -18,7 +18,7 @@ func Test_reflect_str(t *testing.T) {
|
||||
func Test_reflect_ptr_str(t *testing.T) {
|
||||
iter := ParseString(`"hello"`)
|
||||
var str *string
|
||||
iter.Read(&str)
|
||||
iter.ReadVal(&str)
|
||||
if *str != "hello" {
|
||||
t.Fatal(str)
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func Test_reflect_ptr_str(t *testing.T) {
|
||||
func Test_reflect_int(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := int(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func Test_reflect_int(t *testing.T) {
|
||||
func Test_reflect_int8(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := int8(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func Test_reflect_int8(t *testing.T) {
|
||||
func Test_reflect_int16(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := int16(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func Test_reflect_int16(t *testing.T) {
|
||||
func Test_reflect_int32(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := int32(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func Test_reflect_int32(t *testing.T) {
|
||||
func Test_reflect_int64(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := int64(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func Test_reflect_int64(t *testing.T) {
|
||||
func Test_reflect_uint(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := uint(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func Test_reflect_uint(t *testing.T) {
|
||||
func Test_reflect_uint8(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := uint8(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -90,7 +90,7 @@ func Test_reflect_uint8(t *testing.T) {
|
||||
func Test_reflect_uint16(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := uint16(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func Test_reflect_uint16(t *testing.T) {
|
||||
func Test_reflect_uint32(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := uint32(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -108,7 +108,7 @@ func Test_reflect_uint32(t *testing.T) {
|
||||
func Test_reflect_uint64(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := uint64(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func Test_reflect_uint64(t *testing.T) {
|
||||
func Test_reflect_byte(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
val := byte(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 123 {
|
||||
t.Fatal(val)
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func Test_reflect_byte(t *testing.T) {
|
||||
func Test_reflect_float32(t *testing.T) {
|
||||
iter := ParseString(`1.23`)
|
||||
val := float32(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 1.23 {
|
||||
fmt.Println(iter.Error)
|
||||
t.Fatal(val)
|
||||
@@ -136,7 +136,7 @@ func Test_reflect_float32(t *testing.T) {
|
||||
func Test_reflect_float64(t *testing.T) {
|
||||
iter := ParseString(`1.23`)
|
||||
val := float64(0)
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != 1.23 {
|
||||
fmt.Println(iter.Error)
|
||||
t.Fatal(val)
|
||||
@@ -146,7 +146,7 @@ func Test_reflect_float64(t *testing.T) {
|
||||
func Test_reflect_bool(t *testing.T) {
|
||||
iter := ParseString(`true`)
|
||||
val := false
|
||||
iter.Read(&val)
|
||||
iter.ReadVal(&val)
|
||||
if val != true {
|
||||
fmt.Println(iter.Error)
|
||||
t.Fatal(val)
|
||||
|
||||
Reference in New Issue
Block a user