From 2dfd53ba160277843fe337cdc28a344e51da6ae8 Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Sun, 25 Dec 2022 22:54:27 -0700 Subject: [PATCH] More tests --- src/stack/arrs.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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)); } }