1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-27 08:30:57 +02:00
json-iterator/jsoniter_demo_test.go
2017-05-23 18:32:39 +08:00

24 lines
440 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)
}