Skip to content

Commit 286828e

Browse files
add a test for AppendQuotedArg (#1255)
1 parent 2044e1e commit 286828e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bytesconv_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,28 @@ import (
66
"fmt"
77
"html"
88
"net"
9+
"net/url"
910
"testing"
1011
"time"
1112

1213
"github.com/valyala/bytebufferpool"
1314
)
1415

16+
func TestAppendQuotedArg(t *testing.T) {
17+
t.Parallel()
18+
19+
// Sync with url.QueryEscape
20+
allcases := make([]byte, 256)
21+
for i := 0; i < 256; i++ {
22+
allcases[i] = byte(i)
23+
}
24+
res := string(AppendQuotedArg(nil, allcases))
25+
expect := url.QueryEscape(string(allcases))
26+
if res != expect {
27+
t.Fatalf("unexpected string %q. Expecting %q.", res, expect)
28+
}
29+
}
30+
1531
func TestAppendHTMLEscape(t *testing.T) {
1632
t.Parallel()
1733

0 commit comments

Comments
 (0)