mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
34 lines
537 B
Go
34 lines
537 B
Go
package tests
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mailru/easyjson/jwriter"
|
|
)
|
|
|
|
func TestHTML(t *testing.T) {
|
|
s := Struct{
|
|
Test: "<b>test</b>",
|
|
}
|
|
|
|
j := jwriter.Writer{
|
|
NoEscapeHTML: false,
|
|
}
|
|
s.MarshalEasyJSON(&j)
|
|
|
|
data, _ := j.BuildBytes()
|
|
|
|
if string(data) != `{"Test":"\u003cb\u003etest\u003c/b\u003e"}` {
|
|
t.Fatal("EscapeHTML error:", string(data))
|
|
}
|
|
|
|
j.NoEscapeHTML = true
|
|
s.MarshalEasyJSON(&j)
|
|
|
|
data, _ = j.BuildBytes()
|
|
|
|
if string(data) != `{"Test":"<b>test</b>"}` {
|
|
t.Fatal("NoEscapeHTML error:", string(data))
|
|
}
|
|
}
|