1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-18 22:57:33 +02:00

fix write string

This commit is contained in:
Tao Wen
2017-01-22 00:04:08 +08:00
parent 102cd8748e
commit 1163c348f6
2 changed files with 77 additions and 17 deletions

View File

@ -67,12 +67,12 @@ func Test_read_string_via_read(t *testing.T) {
func Test_write_string(t *testing.T) {
should := require.New(t)
buf := &bytes.Buffer{}
stream := NewStream(buf, 4096)
stream.WriteString("hello")
stream.Flush()
should.Nil(stream.Error)
should.Equal(`"hello"`, buf.String())
str, err := MarshalToString("hello")
should.Equal(`"hello"`, str)
should.Nil(err)
str, err = MarshalToString(`hel"lo`)
should.Equal(`"hel\"lo"`, str)
should.Nil(err)
}
func Test_write_val_string(t *testing.T) {