This commit is contained in:
Igor Katson 2021-07-18 16:56:47 +01:00
parent 49cb6f9d65
commit 5fd218d456

View file

@ -516,6 +516,7 @@ mod tests {
use std::{ use std::{
io::Cursor, io::Cursor,
net::{Ipv4Addr, SocketAddr, SocketAddrV4}, net::{Ipv4Addr, SocketAddr, SocketAddrV4},
str::FromStr,
}; };
use librqbit_core::id20::Id20; use librqbit_core::id20::Id20;
@ -534,16 +535,10 @@ mod tests {
( (
( (
start, start,
Id20([ Id20::from_str("7fffffffffffffffffffffffffffffffffffffff").unwrap()
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
])
), ),
( (
Id20([ Id20::from_str("8000000000000000000000000000000000000000").unwrap(),
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]),
end end
) )
) )
@ -552,26 +547,17 @@ mod tests {
#[test] #[test]
fn compute_split_start_end_second_split() { fn compute_split_start_end_second_split() {
let start = Id20([ let start = Id20::from_str("8000000000000000000000000000000000000000").unwrap();
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]);
let end = Id20([0xff; 20]); let end = Id20([0xff; 20]);
assert_eq!( assert_eq!(
compute_split_start_end(start, end, 159), compute_split_start_end(start, end, 159),
( (
( (
start, start,
Id20([ Id20::from_str("bfffffffffffffffffffffffffffffffffffffff").unwrap()
0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
])
), ),
( (
Id20([ Id20::from_str("c000000000000000000000000000000000000000").unwrap(),
0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]),
end end
) )
) )
@ -580,26 +566,17 @@ mod tests {
#[test] #[test]
fn compute_split_start_end_3() { fn compute_split_start_end_3() {
let start = Id20([ let start = Id20::from_str("8000000000000000000000000000000000000000").unwrap();
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]);
let end = Id20([0xff; 20]); let end = Id20([0xff; 20]);
assert_eq!( assert_eq!(
compute_split_start_end(start, end, 159), compute_split_start_end(start, end, 159),
( (
( (
start, start,
Id20([ Id20::from_str("bfffffffffffffffffffffffffffffffffffffff").unwrap()
0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
])
), ),
( (
Id20([ Id20::from_str("c000000000000000000000000000000000000000").unwrap(),
0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]),
end end
) )
) )