mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-23 11:33:37 +08:00
test(render): satisfy testifylint for AsciiJSON non-BMP check
Use assert.Contains for the exact UTF-16 surrogate pair wire encoding and assert.JSONEq for semantic equality, instead of assert.Equal on a JSON string which testifylint rejects.
This commit is contained in:
parent
e89c60b4e4
commit
9aeac9b417
@ -277,8 +277,10 @@ func TestRenderAsciiJSONNonBMP(t *testing.T) {
|
||||
err := (AsciiJSON{Data: data}).Render(w)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Non-BMP characters must be encoded as UTF-16 surrogate pairs
|
||||
assert.Equal(t, `{"msg":"\ud83d\ude00"}`, w.Body.String())
|
||||
body := w.Body.String()
|
||||
// Non-BMP characters must be encoded as UTF-16 surrogate pairs on the wire.
|
||||
assert.Contains(t, body, `\ud83d\ude00`)
|
||||
assert.JSONEq(t, `{"msg":"😀"}`, body)
|
||||
|
||||
// Verify round-trip: json.Unmarshal should recover the original emoji
|
||||
var decoded map[string]string
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user