refactor test code
This commit is contained in:
parent
3a62d362e5
commit
9e26d8be7f
@ -15,14 +15,14 @@ pub type R = TestResults;
|
||||
|
||||
impl R {
|
||||
pub fn unwrap(self) {
|
||||
match self {
|
||||
Self {
|
||||
success,
|
||||
total,
|
||||
result: Err(e),
|
||||
} => panic!("failed:\n{success}/{total}\n{e}\n"),
|
||||
_ => (),
|
||||
};
|
||||
if let Self {
|
||||
success,
|
||||
total,
|
||||
result: Err(e),
|
||||
} = self
|
||||
{
|
||||
panic!("failed:\n{success}/{total}\n{e}\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,8 @@ mod tests {
|
||||
UnbalancedConstructor::rc(Box::new(|node| Box::new(move || Ok(node.clone()))));
|
||||
let mut rng = rand::thread_rng();
|
||||
let t_set = ctr.from_slice(&mut rng, &[0]);
|
||||
assert!(t_contains(&DefaultComparator, t_set.clone(), 0.into()).is_ok());
|
||||
assert!(t_contains(&DefaultComparator, t_set.clone(), 1.into()).is_err());
|
||||
assert!(t_contains(&DefaultComparator, t_set.clone(), 0).is_ok());
|
||||
assert!(t_contains(&DefaultComparator, t_set.clone(), 1).is_err());
|
||||
assert!(
|
||||
t_subset_of_t(&DefaultComparator, t_set.clone(), t_set.clone(), None, None).is_ok()
|
||||
);
|
||||
@ -216,7 +216,7 @@ mod tests {
|
||||
let small: Vec<i32> = big
|
||||
.iter()
|
||||
.filter(|x| **x != key && rng.gen_ratio(4, 5))
|
||||
.map(|x| *x)
|
||||
.copied()
|
||||
.collect();
|
||||
let t_small = ctr.from_slice(&mut rng, &small);
|
||||
let t_big = ctr.from_slice(&mut rng, &big);
|
||||
@ -267,7 +267,7 @@ mod tests {
|
||||
let small: Vec<i32> = big
|
||||
.iter()
|
||||
.filter(|x| **x != key && rng.gen_ratio(4, 5))
|
||||
.map(|x| *x)
|
||||
.copied()
|
||||
.collect();
|
||||
let t_small = ctr.from_slice(&mut rng, &small);
|
||||
let t_big = ctr.from_slice(&mut rng, &big);
|
||||
|
@ -74,12 +74,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn can_parse_false() {
|
||||
assert_eq!(bool::parse_slice(&[0]).unwrap(), false)
|
||||
assert!(!bool::parse_slice(&[0]).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_parse_true() {
|
||||
assert_eq!(bool::parse_slice(&[1]).unwrap(), true)
|
||||
assert!(bool::parse_slice(&[1]).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user