MCPcopy Index your code
hub / github.com/labstack/echo / TestGetRawQueryParamMatchesStdlib

Function TestGetRawQueryParamMatchesStdlib

query_fastpath_test.go:32–66  ·  view source on GitHub ↗

TestGetRawQueryParamMatchesStdlib asserts the single-key fast path returns exactly what url.Values.Get (over url.ParseQuery output) would return, across a battery of edge cases.

(t *testing.T)

Source from the content-addressed store, hash-verified

30// TestGetRawQueryParamMatchesStdlib asserts the single-key fast path returns exactly what
31// url.Values.Get (over url.ParseQuery output) would return, across a battery of edge cases.
32func TestGetRawQueryParamMatchesStdlib(t *testing.T) {
33 queries := []string{
34 "",
35 "a=1",
36 "a=1&b=2",
37 "a=1&a=2", // first match wins
38 "a=&b=2", // empty value
39 "=v", // empty key
40 "a", // key without '='
41 "a=x+y", // '+' -> space
42 "a=%20space", // percent escape
43 "a=%2", // bad value escape -> pair skipped
44 "a=%ZZ&a=2", // bad escape on first match -> skip, fall through to second
45 "%ZZ=1&a=2", // bad key escape -> pair skipped
46 "a%3Db=c", // encoded key 'a=b'
47 "a=1;b=2", // semicolon segment skipped entirely
48 "a=1&c=3;d=4&e=5",
49 "name=Jon&name=Snow&age=24",
50 "q=%E4%B8%AD%E6%96%87", // unicode value
51 "empty=&x=1",
52 "a=1&&b=2", // empty segment
53 }
54 names := []string{"a", "b", "c", "d", "e", "name", "age", "q", "empty", "x", "a=b", "missing", ""}
55
56 for _, q := range queries {
57 want, _ := url.ParseQuery(q) // url.Values; mirrors URL.Query() (error ignored)
58 for _, name := range names {
59 got := getRawQueryParam(q, name)
60 exp := want.Get(name)
61 if got != exp {
62 t.Errorf("getRawQueryParam(%q, %q) = %q; url.Values.Get = %q", q, name, got, exp)
63 }
64 }
65 }
66}

Callers

nothing calls this directly

Calls 2

getRawQueryParamFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…