final test is concluded, bencode implementation is complete and capable
of decoding and encoding torrent files and announces in a way as they come
This commit is contained in:
parent
c978925f70
commit
2d80fc2657
1 changed files with 16 additions and 0 deletions
|
|
@ -164,6 +164,10 @@ public class BTreeTest {
|
|||
|
||||
tree.setRoot(new BString("test"));
|
||||
assertArrayEquals("4:test".getBytes(), tree.encode());
|
||||
|
||||
tree.setRoot(new BDict())
|
||||
.set(new BInteger(1), new BInteger(2));
|
||||
assertArrayEquals("di1ei2ee".getBytes(), tree.encode());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -190,4 +194,16 @@ public class BTreeTest {
|
|||
assertEquals(new BInteger(16777216), pieceLength);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecodeEncodeTorrentFile() throws BError, IOException {
|
||||
final byte[] data = Files.readAllBytes(Path.of("test", "test.torrent"));
|
||||
|
||||
BTree torrent = new BTree();
|
||||
assertDoesNotThrow(() -> {
|
||||
torrent.decode(data);
|
||||
|
||||
assertArrayEquals(data, torrent.encode());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue