diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2016-02-15 16:53:44 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-02-15 16:53:44 +0200 |
commit | 394c20fdc5cdf3ae65415218705b6e59b8a7c344 (patch) | |
tree | 817a0b4d3c352c289a643f05c9c209bfbf229f90 /bytesconv_test.go | |
parent | Issue #52: updated client benchmark results in readme (diff) | |
download | fasthttp-394c20fdc5cdf3ae65415218705b6e59b8a7c344.tar.gz fasthttp-394c20fdc5cdf3ae65415218705b6e59b8a7c344.tar.bz2 fasthttp-394c20fdc5cdf3ae65415218705b6e59b8a7c344.zip |
Added AppendHTMLEscape helper function
Diffstat (limited to 'bytesconv_test.go')
-rw-r--r-- | bytesconv_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bytesconv_test.go b/bytesconv_test.go index 83eb3d8..fde6f26 100644 --- a/bytesconv_test.go +++ b/bytesconv_test.go @@ -9,6 +9,21 @@ import ( "time" ) +func TestAppendHTMLEscape(t *testing.T) { + testAppendHTMLEscape(t, "", "") + testAppendHTMLEscape(t, "<", "<") + testAppendHTMLEscape(t, "a", "a") + testAppendHTMLEscape(t, `><"''`, "><"''") + testAppendHTMLEscape(t, "fo<b x='ss'>a</b>xxx", "fo<b x='ss'>a</b>xxx") +} + +func testAppendHTMLEscape(t *testing.T, s, expectedS string) { + buf := AppendHTMLEscapeBytes(nil, []byte(s)) + if string(buf) != expectedS { + t.Fatalf("unexpected html-escaped string %q. Expecting %q. Original string %q", buf, expectedS, s) + } +} + func TestParseIPv4(t *testing.T) { testParseIPv4(t, "0.0.0.0", true) testParseIPv4(t, "255.255.255.255", true) |