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

Function TestUnmarshalItem

item_test.go:68–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestUnmarshalItem(t *testing.T) {
69 t.Parallel()
70
71 i1 := NewItem(true)
72 i1.Params.Add("foo", true)
73 i1.Params.Add("*bar", Token("tok"))
74
75 data := []struct {
76 in []string
77 expected Item
78 valid bool
79 }{
80 {[]string{"?1;foo;*bar=tok"}, i1, false},
81 {[]string{" ?1;foo;*bar=tok "}, i1, false},
82 {[]string{`"foo`, `bar"`}, NewItem("foo,bar"), false},
83 {[]string{"é", ""}, Item{}, true},
84 {[]string{"tok;é"}, Item{}, true},
85 {[]string{" ?1;foo;*bar=tok é"}, Item{}, true},
86 }
87
88 for _, d := range data {
89 i, err := UnmarshalItem(d.in)
90 if d.valid && err == nil {
91 t.Errorf("UnmarshalItem(%s): error expected", d.in)
92 }
93
94 if !d.valid && !reflect.DeepEqual(d.expected, i) {
95 t.Errorf("UnmarshalItem(%s) = %v, %v; %v, <nil> expected", d.in, i, err, d.expected)
96 }
97 }
98}

Callers

nothing calls this directly

Calls 4

NewItemFunction · 0.85
TokenTypeAlias · 0.85
UnmarshalItemFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…