1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-12 22:47:42 +02:00

array encoder

This commit is contained in:
Tao Wen
2017-01-09 19:48:57 +08:00
parent 552afb3625
commit 90fc0b822f
5 changed files with 74 additions and 12 deletions

View File

@ -134,6 +134,22 @@ func Test_write_array(t *testing.T) {
should.Equal("[\n 1,\n 2\n]", buf.String())
}
func Test_write_val_array(t *testing.T) {
should := require.New(t)
val := []int{1,2,3}
str, err := MarshalToString(val)
should.Nil(err)
should.Equal("[1,2,3]", str)
}
func Test_write_val_empty_array(t *testing.T) {
should := require.New(t)
val := []int{}
str, err := MarshalToString(val)
should.Nil(err)
should.Equal("[]", str)
}
func Benchmark_jsoniter_array(b *testing.B) {
b.ReportAllocs()
input := []byte(`[1,2,3,4,5,6,7,8,9]`)