1
0
mirror of https://github.com/golang/go synced 2024-11-24 06:00:11 -07:00

encoding/json: add test for HTMLEscape

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/38220044
This commit is contained in:
Shawn Smith 2013-12-18 10:18:35 -08:00 committed by Brad Fitzpatrick
parent 33580e8305
commit aa20d26292

View File

@ -425,3 +425,13 @@ func TestIssue6458(t *testing.T) {
t.Errorf("Marshal(x) = %#q; want %#q", b, want)
}
}
func TestHTMLEscape(t *testing.T) {
var b, want bytes.Buffer
m := `{"M":"<html>foo &` + "\xe2\x80\xa8 \xe2\x80\xa9" + `</html>"}`
want.Write([]byte(`{"M":"\u003chtml\u003efoo \u0026\u2028 \u2029\u003c/html\u003e"}`))
HTMLEscape(&b, []byte(m))
if !bytes.Equal(b.Bytes(), want.Bytes()) {
t.Errorf("HTMLEscape(&b, []byte(m)) = %s; want %s", b.Bytes(), want.Bytes())
}
}