diff --git a/src/stack/arrs.rs b/src/stack/arrs.rs index 19cc7ad..67d2121 100644 --- a/src/stack/arrs.rs +++ b/src/stack/arrs.rs @@ -176,6 +176,20 @@ mod arrs_test { s.push1(val).unwrap(); s.pop1() == Ok(val) } + + fn set1n_get1n_round_trip_quck(val: Vec) -> 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] @@ -194,16 +208,32 @@ mod arrs_test { s.push2(val).unwrap(); s.pop2() == Ok(val) } + + fn set2n_get2n_round_trip_quck(val: Vec) -> 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] #[case(0x00)] #[case(0x8000)] #[case(0x0080)] + #[case(0x0200)] #[case(0xFFFF)] fn set2_get2_round_trip_manual(#[case] val: u16) { let mut s = ArrayStack::new(); s.push2(val).unwrap(); - assert_eq!(s.pop2(), Ok(val)) + assert_eq!(s.idx(), 2); + assert_eq!(s.pop2(), Ok(val)); } }