Add test for whitespace in bencode name.

This commit is contained in:
Jack Palevich 2014-07-27 15:47:06 +08:00
parent 047893b8ff
commit c104c8e258

View file

@ -230,6 +230,7 @@ func TestDecode(t *testing.T) {
type structA struct { type structA struct {
A int "a" A int "a"
B string `example:"data" bencode:"b"` B string `example:"data" bencode:"b"`
C string `example:"data2" bencode:"sea monster"`
} }
func TestUnmarshal(t *testing.T) { func TestUnmarshal(t *testing.T) {
@ -254,7 +255,7 @@ func TestUnmarshal(t *testing.T) {
SVPair{"li42e3:abce", []any{42, "abc"}}, SVPair{"li42e3:abce", []any{42, "abc"}},
SVPair{"de", map[string]any{}}, SVPair{"de", map[string]any{}},
SVPair{"d3:cati1e3:dogi2ee", map[string]any{"cat": 1, "dog": 2}}, SVPair{"d3:cati1e3:dogi2ee", map[string]any{"cat": 1, "dog": 2}},
SVPair{"d1:ai10e1:b3:fooe", structA{10, "foo"}}, SVPair{"d1:ai10e1:b3:foo11:sea monster3:bare", structA{10, "foo", "bar"}},
SVPair{"d1:ad2:id20:abcdefghij0123456789e1:q4:ping1:t2:aa1:y1:qe", nestedDictionary}, SVPair{"d1:ad2:id20:abcdefghij0123456789e1:q4:ping1:t2:aa1:y1:qe", nestedDictionary},
} }
for _, sv := range tests { for _, sv := range tests {