use orx_linked_list::*; use test_case::test_matrix; #[test_matrix( [DoublyList::new(), DoublyListLazy::new()], [0, 1, 2, 3, 4] )] fn remove_doubly>>(mut list: List, M>, idx: usize) { let indices = [ list.push_back('c'), list.push_back('d'), list.push_front('b'), list.push_front('a'), list.push_back('e'), ]; let chars = ['c', 'd', 'b', 'a', 'e']; let c = chars[idx]; let idx = &indices[idx]; let removed = list.try_remove(idx); list.validate(); assert_eq!(removed, Some(c)); } #[test_matrix([DoublyList::new(), DoublyListLazy::new()])] fn remove_doubly_oob>>(mut list: List, M>) { let indices = [ list.push_back('c'), list.push_back('d'), list.push_front('b'), list.push_front('a'), list.push_back('e'), ]; let _ = list.pop_back(); let removed = list.try_remove(&indices[4]); list.validate(); assert_eq!(removed, None); } #[test_matrix([DoublyList::new(), DoublyListLazy::new()])] fn remove_doubly_other_list>>(mut other: List, M>) { let mut list = DoublyList::new(); let indices = [ list.push_back('c'), list.push_back('d'), list.push_front('b'), list.push_front('a'), list.push_back('e'), ]; let other_indices = [ other.push_back('c'), other.push_back('d'), other.push_front('b'), other.push_front('a'), other.push_back('e'), ]; let removed = other.try_remove(&indices[4]); assert_eq!(removed, None); let removed = list.try_remove(&other_indices[4]); assert_eq!(removed, None); list.validate(); other.validate(); }