aboutsummaryrefslogtreecommitdiff
path: root/meta/torrent_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'meta/torrent_test.go')
-rw-r--r--meta/torrent_test.go32
1 files changed, 30 insertions, 2 deletions
diff --git a/meta/torrent_test.go b/meta/torrent_test.go
index 5f304d5..df629d3 100644
--- a/meta/torrent_test.go
+++ b/meta/torrent_test.go
@@ -1,5 +1,12 @@
package meta
+import (
+ "io/ioutil"
+ "testing"
+
+ "dim13.org/btget/bencode"
+)
+
var tors = map[string]string{
"bsd": "OpenBSD_5.9_amd64_install59.iso-2016-03-29-0449.torrent",
"ogg": "OpenBSD_songs_ogg-2016-03-25-0127.torrent",
@@ -7,7 +14,19 @@ var tors = map[string]string{
"mul": "multi.torrent",
}
-/*
+func Open(fname string) (Torrent, error) {
+ var tor Torrent
+ body, err := ioutil.ReadFile(fname)
+ if err != nil {
+ return Torrent{}, err
+ }
+ err = bencode.Unmarshal(body, &tor)
+ if err != nil {
+ return Torrent{}, err
+ }
+ return tor, nil
+}
+
func TestPieces(t *testing.T) {
tor, err := Open("../examples/" + tors["mul"])
if err != nil {
@@ -18,4 +37,13 @@ func TestPieces(t *testing.T) {
t.Log(n, off)
}
}
-*/
+
+func TestPieces2(t *testing.T) {
+ tor, err := Open("../examples/" + tors["mul"])
+ if err != nil {
+ t.Error(err)
+ }
+ for i, p := range tor.Info.pieces() {
+ t.Logf("%d %x\n", i, p)
+ }
+}