1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-24 23:16:47 +02:00

#53 test compatibility without html escape

This commit is contained in:
Tao Wen
2017-06-16 16:03:02 +08:00
parent a6ea770365
commit e0e2423e9a
2 changed files with 60 additions and 58 deletions

View File

@ -137,6 +137,24 @@ func Test_string_encode_with_std(t *testing.T) {
}
}
func Test_string_encode_with_std_without_html_escape(t *testing.T) {
should := require.New(t)
for i := 0; i < utf8.RuneSelf; i++ {
input := string([]byte{byte(i)})
buf := &bytes.Buffer{}
encoder := json.NewEncoder(buf)
encoder.SetEscapeHTML(false)
err := encoder.Encode(input)
should.Nil(err)
stdOutput := buf.String()
stdOutput = stdOutput[:len(stdOutput) - 1]
jsoniterOutputBytes, err := Marshal(input)
should.Nil(err)
jsoniterOutput := string(jsoniterOutputBytes)
should.Equal(stdOutput, jsoniterOutput)
}
}
func Benchmark_jsoniter_unicode(b *testing.B) {
for n := 0; n < b.N; n++ {
iter := ParseString(ConfigOfDefault, `"\ud83d\udc4a"`)