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