1
0
mirror of https://github.com/json-iterator/go.git synced 2025-03-26 21:12:40 +02:00
json-iterator/jsoniter_demo_test.go
2017-06-02 16:52:20 +08:00

25 lines
441 B
Go

package jsoniter
import (
"fmt"
"testing"
"github.com/json-iterator/go/require"
)
func Test_bind_api_demo(t *testing.T) {
should := require.New(t)
val := []int{}
err := UnmarshalFromString(`[0,1,2,3] `, &val)
should.Nil(err)
should.Equal([]int{0, 1, 2, 3}, val)
}
func Test_iterator_api_demo(t *testing.T) {
iter := ParseString(`[0,1,2,3]`)
total := 0
for iter.ReadArray() {
total += iter.ReadInt()
}
fmt.Println(total)
}