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

Function TestUnmarshalDictionary

dictionary_test.go:88–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestUnmarshalDictionary(t *testing.T) {
89 t.Parallel()
90
91 d1 := NewDictionary()
92 d1.Add("a", NewItem(false))
93 d1.Add("b", NewItem(true))
94
95 c := NewItem(true)
96 c.Params.Add("foo", Token("bar"))
97 d1.Add("c", c)
98
99 data := []struct {
100 in []string
101 expected *Dictionary
102 valid bool
103 }{
104 {[]string{"a=?0, b, c; foo=bar"}, d1, false},
105 {[]string{"a="}, nil, false},
106 {[]string{"a=?0, b", "c; foo=bar"}, d1, false},
107 {[]string{""}, NewDictionary(), false},
108 {[]string{"é"}, nil, true},
109 {[]string{`foo="é"`}, nil, true},
110 {[]string{`foo;é`}, nil, true},
111 {[]string{`f="foo" é`}, nil, true},
112 {[]string{`f="foo",`}, nil, true},
113 }
114
115 for _, d := range data {
116 l, err := UnmarshalDictionary(d.in)
117 if d.valid && err == nil {
118 t.Errorf("UnmarshalDictionary(%s): error expected", d.in)
119 }
120
121 if !d.valid && !reflect.DeepEqual(d.expected, l) {
122 t.Errorf("UnmarshalDictionary(%s) = %v, %v; %v, <nil> expected", d.in, l, err, d.expected)
123 }
124 }
125}

Callers

nothing calls this directly

Calls 6

AddMethod · 0.95
NewDictionaryFunction · 0.85
NewItemFunction · 0.85
TokenTypeAlias · 0.85
UnmarshalDictionaryFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…