aboutsummaryrefslogtreecommitdiff
path: root/bencode/bencode_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'bencode/bencode_test.go')
-rw-r--r--bencode/bencode_test.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/bencode/bencode_test.go b/bencode/bencode_test.go
index a5512e7..a7c534c 100644
--- a/bencode/bencode_test.go
+++ b/bencode/bencode_test.go
@@ -15,8 +15,8 @@ func TestMarshal(t *testing.T) {
Info: torrent.Info{
Length: 1000,
Files: []torrent.File{
- {Path: "A"},
- {Path: "B"},
+ {Path: []string{"A"}},
+ {Path: []string{"B"}},
},
},
}
@@ -26,3 +26,19 @@ func TestMarshal(t *testing.T) {
}
t.Logf("%q\n", string(out))
}
+
+func TestUnmarshalString(t *testing.T) {
+ in := "4:testZZZ"
+ s := unmarshalString([]byte(in))
+ if s != "test" {
+ t.Error("expected test, got", s)
+ }
+}
+
+func TestUnmarshalInt(t *testing.T) {
+ in := "i12345e999"
+ i := unmarshalInt([]byte(in))
+ if i != 12345 {
+ t.Error("expected 12345, got", i)
+ }
+}