From 911423307d2ae0ffa555b323fb7414b7f427e915 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 26 Oct 2017 14:25:59 +1100 Subject: [PATCH] Add a test for bdecoding consecutive dicts --- bencode/decode_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bencode/decode_test.go b/bencode/decode_test.go index d519b8a6..1db0c7e4 100644 --- a/bencode/decode_test.go +++ b/bencode/decode_test.go @@ -70,6 +70,20 @@ func TestDecoderConsecutive(t *testing.T) { require.Equal(t, io.EOF, err) } +func TestDecoderConsecutiveDicts(t *testing.T) { + bb := bytes.NewBufferString("d4:herp4:derped3:wat1:ke17:oh baby a triple!") + d := NewDecoder(bb) + var m map[string]interface{} + require.NoError(t, d.Decode(&m)) + assert.Len(t, m, 1) + assert.Equal(t, "derp", m["herp"]) + require.NoError(t, d.Decode(&m)) + assert.Equal(t, "k", m["wat"]) + var s string + require.NoError(t, d.Decode(&s)) + assert.Equal(t, "oh baby a triple!", s) +} + func check_error(t *testing.T, err error) { if err != nil { t.Error(err)