(t *testing.T)
| 86 | } |
| 87 | |
| 88 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…