Skip to content

Commit

Permalink
test(enc.str): add BadUnicodeAfterSafeEscape test
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Nov 2, 2021
1 parent 3c1755b commit 37ab60a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion enc_str_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ func TestEncoder_String(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "a�z", v)
})
t.Run("BadNonSelf", func(t *testing.T) {
t.Run("Emoji", func(t *testing.T) {
e := GetEncoder()
e.Str(string([]byte{240, 159, 144, 152}))
v, err := DecodeBytes(e.Bytes()).Str()
require.NoError(t, err)
require.Equal(t, "🐘", v)
})
t.Run("BadUnicodeAfterSafeEscape", func(t *testing.T) {
e := GetEncoder()
e.StrEscape("<f\xed\xa0\x80")
require.Equal(t, `"\u003cf\ufffd\ufffd\ufffd"`, e.String())
})
}

0 comments on commit 37ab60a

Please sign in to comment.