1
0
mirror of https://github.com/json-iterator/go.git synced 2025-07-15 23:54:21 +02:00

fix unicode and escape

This commit is contained in:
Tao Wen
2017-06-22 16:00:47 +08:00
parent caaa04195e
commit ebed7df895
2 changed files with 24 additions and 7 deletions

@ -144,6 +144,26 @@ func Test_unicode(t *testing.T) {
should.Equal(`{"a":"数字山谷"}`, output)
}
func Test_unicode_and_escape(t *testing.T) {
should := require.New(t)
output , err := MarshalToString(`"数字山谷"`)
should.Nil(err)
should.Equal(`"\"数字山谷\""`, output)
output , err = ConfigFastest.MarshalToString(`"数字山谷"`)
should.Nil(err)
should.Equal(`"\"数字山谷\""`, output)
}
func Test_unsafe_unicode(t *testing.T) {
should := require.New(t)
output , err := MarshalToString("he\u2029\u2028he")
should.Nil(err)
should.Equal(`"he\u2029\u2028he"`, output)
output , err = ConfigFastest.MarshalToString("he\u2029\u2028he")
should.Nil(err)
should.Equal("\"he\u2029\u2028he\"", output)
}
func Benchmark_jsoniter_unicode(b *testing.B) {
for n := 0; n < b.N; n++ {
iter := ParseString(ConfigDefault, `"\ud83d\udc4a"`)