From 97cf2421deb9ebd3daa128a1d93d4f2173eae24b Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sat, 3 Feb 2024 20:33:20 +0800 Subject: [PATCH] chore: add more tests (#3888) --- rest/httpx/requests_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rest/httpx/requests_test.go b/rest/httpx/requests_test.go index 57fe136f..a1d3f6a8 100644 --- a/rest/httpx/requests_test.go +++ b/rest/httpx/requests_test.go @@ -410,6 +410,18 @@ func TestParseWithFloatPtr(t *testing.T) { }) } +func TestParseWithEscapedParams(t *testing.T) { + t.Run("escaped", func(t *testing.T) { + var v struct { + Dev string `form:"dev"` + } + r := httptest.NewRequest(http.MethodGet, "http://127.0.0.1/api/v2/dev/test?dev=se205%5fy1205%5fj109%26verRelease=v01%26iid1=863494061186673%26iid2=863494061186681%26mcc=636%26mnc=1", http.NoBody) + if assert.NoError(t, Parse(r, &v)) { + assert.Equal(t, "se205_y1205_j109&verRelease=v01&iid1=863494061186673&iid2=863494061186681&mcc=636&mnc=1", v.Dev) + } + }) +} + func BenchmarkParseRaw(b *testing.B) { r, err := http.NewRequest(http.MethodGet, "http://hello.com/a?name=hello&age=18&percent=3.4", http.NoBody) if err != nil {