MCPcopy Index your code
hub / github.com/dunglas/httpsfv / TestParseParameters

Function TestParseParameters

params_test.go:82–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func TestParseParameters(t *testing.T) {
83 t.Parallel()
84
85 p0 := NewParams()
86 p0.Add("foo", true)
87 p0.Add("*bar", "baz")
88
89 data := []struct {
90 in string
91 out *Params
92 err bool
93 }{
94 {`;foo=?1;*bar="baz" foo`, p0, false},
95 {`;foo;*bar="baz" foo`, p0, false},
96 {`;é=?0`, p0, true},
97 {`;foo=é`, p0, true},
98 }
99
100 for _, d := range data {
101 s := &scanner{data: d.in}
102
103 p, err := parseParams(s)
104 if d.err && err == nil {
105 t.Errorf("parseParameters(%s): error expected", d.in)
106 }
107
108 if !d.err && !reflect.DeepEqual(p, d.out) {
109 t.Errorf("parseParameters(%s) = %v, %v; %v, <nil> expected", d.in, p, err, d.out)
110 }
111 }
112}

Callers

nothing calls this directly

Calls 3

AddMethod · 0.95
NewParamsFunction · 0.85
parseParamsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…