From d0af34f23a47ad3ea5238eb88585479f6c6f7bd6 Mon Sep 17 00:00:00 2001 From: ZhangYunHao Date: Fri, 18 Mar 2022 15:19:58 +0800 Subject: [PATCH] add a test for AppendQuotedArg (#1255) --- bytesconv_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bytesconv_test.go b/bytesconv_test.go index 297b4a1626..cf4a12ec2a 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()