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