aboutsummaryrefslogtreecommitdiff
path: root/bytesconv_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-02-15 16:53:44 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-02-15 16:53:44 +0200
commit394c20fdc5cdf3ae65415218705b6e59b8a7c344 (patch)
tree817a0b4d3c352c289a643f05c9c209bfbf229f90 /bytesconv_test.go
parentIssue #52: updated client benchmark results in readme (diff)
downloadfasthttp-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.go15
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, "<", "&lt;")
+ testAppendHTMLEscape(t, "a", "a")
+ testAppendHTMLEscape(t, `><"''`, "&gt;&lt;&quot;&#39;&#39;")
+ testAppendHTMLEscape(t, "fo<b x='ss'>a</b>xxx", "fo&lt;b x=&#39;ss&#39;&gt;a&lt;/b&gt;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)