1extern crate benko;
7
8pub use parser::*;
9pub use types::*;
10
11mod parser;
12mod types;
13
14#[cfg(test)]
15mod tests {
16 use crate::types::{Torrent, TorrentInfo};
17
18 #[test]
19 fn it_works() {
20 let torrent_bytes =
21 std::fs::read("ubuntu.torrent").expect("Could not find ubuntu.torrent file.");
22
23 let torrent: Torrent = Torrent::from_bytes(torrent_bytes.as_slice());
24 let info: TorrentInfo = torrent.info;
25
26 assert_eq!("https://torrent.ubuntu.com/announce", torrent.announce);
27 assert!(info.files.is_none());
28 assert_eq!(2942003200, info.length.expect("this should be populated"));
29 assert_eq!("ubuntu-20.10-desktop-amd64.iso", info.name);
30 assert_eq!(262144, info.piece_length);
31
32 println!("piece length: {:?}", info.piece_length);
33 }
34}