1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-24 08:22:14 +02:00

report error when string end not found

This commit is contained in:
Tao Wen 2017-06-08 09:46:19 +08:00
parent d75b539bad
commit 26708bccc9
2 changed files with 8 additions and 0 deletions

View File

@ -92,6 +92,7 @@ func (iter *Iterator) readStringSlowPath() (ret string) {
str = append(str, c) str = append(str, c)
} }
} }
iter.reportError("ReadString", "unexpected end of input")
return return
} }

View File

@ -105,6 +105,13 @@ func Test_write_val_string(t *testing.T) {
should.Equal(`"hello"`, buf.String()) should.Equal(`"hello"`, buf.String())
} }
func Test_decode_slash(t *testing.T) {
should := require.New(t)
var obj interface{}
should.NotNil(json.Unmarshal([]byte(`"\"`), &obj))
should.NotNil(UnmarshalFromString(`"\"`, &obj))
}
func Benchmark_jsoniter_unicode(b *testing.B) { func Benchmark_jsoniter_unicode(b *testing.B) {
for n := 0; n < b.N; n++ { for n := 0; n < b.N; n++ {
iter := ParseString(`"\ud83d\udc4a"`) iter := ParseString(`"\ud83d\udc4a"`)