1
0
mirror of https://github.com/json-iterator/go.git synced 2025-08-07 21:52:55 +02:00

fix #37: add SkipAndAppendBytes iterator method

This commit is contained in:
Aleksandr Razumov
2019-06-07 18:50:27 +03:00
parent 0039f4ac3d
commit 459f0e30ae
2 changed files with 22 additions and 12 deletions

View File

@ -105,6 +105,15 @@ func Test_skip_and_return_bytes_with_reader(t *testing.T) {
should.Equal(`{"a" : [{"stream": "c"}], "d": 102 }`, string(skipped))
}
func Test_append_skip_and_return_bytes_with_reader(t *testing.T) {
should := require.New(t)
iter := jsoniter.Parse(jsoniter.ConfigDefault, bytes.NewBufferString(`[ {"a" : [{"stream": "c"}], "d": 102 }, "stream"]`), 4)
iter.ReadArray()
buf := make([]byte, 0, 1024)
buf = iter.SkipAndAppendBytes(buf)
should.Equal(`{"a" : [{"stream": "c"}], "d": 102 }`, string(buf))
}
func Test_skip_empty(t *testing.T) {
should := require.New(t)
should.NotNil(jsoniter.Get([]byte("")).LastError())