package meta import "testing" 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", "deb": "debian-8.5.0-amd64-netinst.iso.torrent", "mul": "multi.torrent", } func TestPieces(t *testing.T) { tor, err := New("../examples/" + tors["mul"]) if err != nil { t.Error(err) } for i, p := range tor.Info.GetPieces() { n, off := tor.Info.findFirstFile(p.Offset) t.Log(i, n, off) } } func TestPieces2(t *testing.T) { tor, err := New("../examples/" + tors["mul"]) if err != nil { t.Error(err) } for i, p := range tor.Info.GetPieces() { t.Logf("%d %x\n", i, p) } } func TestReadAt(t *testing.T) { t.Skip() tor, err := New("../examples/" + tors["bsd"]) if err != nil { t.Error(err) } buf := make([]byte, tor.Info.PieceLength) n, err := tor.Info.ReadAt(buf, 0) if err != nil { t.Log(err) } if n != len(buf) { t.Error("expected", len(buf), "got", n) } //t.Logf("% x\n", buf) }