From: Shawn Smith Date: Wed, 18 Dec 2013 18:18:35 +0000 (-0800) Subject: encoding/json: add test for HTMLEscape X-Git-Tag: go1.3beta1~1173 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=aa20d2629284ee73637598c9635ae2f8f7530d04;p=gostls13.git encoding/json: add test for HTMLEscape R=golang-dev, rsc CC=golang-dev https://golang.org/cl/38220044 --- diff --git a/src/pkg/encoding/json/encode_test.go b/src/pkg/encoding/json/encode_test.go index 9395db7cb6..c4a199a1bd 100644 --- a/src/pkg/encoding/json/encode_test.go +++ b/src/pkg/encoding/json/encode_test.go @@ -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":"foo &` + "\xe2\x80\xa8 \xe2\x80\xa9" + `"}` + 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()) + } +}