More tests

This commit is contained in:
Reid 'arrdem' McKenzie 2022-12-25 22:54:27 -07:00
parent 3d18b42584
commit 2dfd53ba16

View file

@ -176,6 +176,20 @@ mod arrs_test {
s.push1(val).unwrap(); s.push1(val).unwrap();
s.pop1() == Ok(val) s.pop1() == Ok(val)
} }
fn set1n_get1n_round_trip_quck(val: Vec<u8>) -> bool {
let mut s = ArrayStack::new();
for i in val.clone().into_iter() {
s.push1(i).unwrap();
};
for i in val.clone().into_iter().rev() {
match s.pop1() {
Ok(j) => if i != j { return false }
Err(e) => panic!("{:?}", e)
}
}
true
}
} }
#[rstest] #[rstest]
@ -194,16 +208,32 @@ mod arrs_test {
s.push2(val).unwrap(); s.push2(val).unwrap();
s.pop2() == Ok(val) s.pop2() == Ok(val)
} }
fn set2n_get2n_round_trip_quck(val: Vec<u16>) -> bool {
let mut s = ArrayStack::new();
for i in val.clone().into_iter() {
s.push2(i).unwrap();
};
for i in val.clone().into_iter().rev() {
match s.pop2() {
Ok(j) => if i != j { return false }
Err(e) => panic!("{:?}", e)
}
}
true
}
} }
#[rstest] #[rstest]
#[case(0x00)] #[case(0x00)]
#[case(0x8000)] #[case(0x8000)]
#[case(0x0080)] #[case(0x0080)]
#[case(0x0200)]
#[case(0xFFFF)] #[case(0xFFFF)]
fn set2_get2_round_trip_manual(#[case] val: u16) { fn set2_get2_round_trip_manual(#[case] val: u16) {
let mut s = ArrayStack::new(); let mut s = ArrayStack::new();
s.push2(val).unwrap(); s.push2(val).unwrap();
assert_eq!(s.pop2(), Ok(val)) assert_eq!(s.idx(), 2);
assert_eq!(s.pop2(), Ok(val));
} }
} }