diff options
author | ZhangYunHao <zhangyunhao116@gmail.com> | 2022-03-18 15:19:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-18 08:19:58 +0100 |
commit | 286828e256e332055084551dff5606cf61d13dfa (patch) | |
tree | 5c6dc7945ca2c356f65d584e7641284be659e0d9 /bytesconv_test.go | |
parent | reduce unnessary type assart (#1254) (diff) | |
download | fasthttp-286828e256e332055084551dff5606cf61d13dfa.tar.gz fasthttp-286828e256e332055084551dff5606cf61d13dfa.tar.bz2 fasthttp-286828e256e332055084551dff5606cf61d13dfa.zip |
add a test for AppendQuotedArg (#1255)
Diffstat (limited to 'bytesconv_test.go')
-rw-r--r-- | bytesconv_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bytesconv_test.go b/bytesconv_test.go index 297b4a1..cf4a12e 100644 --- a/bytesconv_test.go +++ b/bytesconv_test.go @@ -6,12 +6,28 @@ import ( "fmt" "html" "net" + "net/url" "testing" "time" "github.com/valyala/bytebufferpool" ) +func TestAppendQuotedArg(t *testing.T) { + t.Parallel() + + // Sync with url.QueryEscape + allcases := make([]byte, 256) + for i := 0; i < 256; i++ { + allcases[i] = byte(i) + } + res := string(AppendQuotedArg(nil, allcases)) + expect := url.QueryEscape(string(allcases)) + if res != expect { + t.Fatalf("unexpected string %q. Expecting %q.", res, expect) + } +} + func TestAppendHTMLEscape(t *testing.T) { t.Parallel() |