mirror of https://github.com/golang/go.git
encoding/json: add test for HTMLEscape
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/38220044
This commit is contained in:
parent
33580e8305
commit
aa20d26292
|
|
@ -425,3 +425,13 @@ func TestIssue6458(t *testing.T) {
|
||||||
t.Errorf("Marshal(x) = %#q; want %#q", b, want)
|
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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue