use orx_linked_list::*; use test_case::test_matrix; #[test_matrix([ SinglyList::from_iter(['b', 'c', 'd']), SinglyListLazy::from_iter(['b', 'c', 'd']), ])] fn insert_at_singly>>(mut list: List, M>) { list.insert_at(0, 'a'); list.validate(); assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd'])); list.insert_at(4, 'e'); list.validate(); assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd', 'e'])); list.insert_at(3, 'x'); list.validate(); assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'x', 'd', 'e'])); } #[should_panic] #[test] fn insert_at_singly_oob() { let mut list = SinglyList::from_iter(['b', 'c', 'd']); let _ = list.insert_at(4, 'x'); } #[test_matrix([ DoublyList::from_iter(['b', 'c', 'd']), DoublyListLazy::from_iter(['b', 'c', 'd']), ])] fn insert_at_doubly>>(mut list: List, M>) { list.insert_at(0, 'a'); list.validate(); assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd'])); list.insert_at(4, 'e'); list.validate(); assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd', 'e'])); list.insert_at(3, 'x'); list.validate(); assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'x', 'd', 'e'])); } #[should_panic] #[test] fn insert_at_doubly_oob() { let mut list = DoublyList::from_iter(['b', 'c', 'd']); let _ = list.insert_at(4, 'x'); } #[test_matrix([ DoublyList::from_iter(['b', 'c', 'd']), DoublyListLazy::from_iter(['b', 'c', 'd']), ])] fn insert_at_from_back_doubly>>(mut list: List, M>) { list.insert_at_from_back(0, 'e'); list.validate(); assert!(list.eq_to_iter_vals(['b', 'c', 'd', 'e'])); list.insert_at_from_back(4, 'a'); list.validate(); assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd', 'e'])); list.insert_at_from_back(2, 'x'); list.validate(); assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'x', 'd', 'e'])); } #[should_panic] #[test] fn insert_at_from_back_doubly_oob() { let mut list = DoublyList::from_iter(['b', 'c', 'd']); let _ = list.insert_at_from_back(4, 'x'); }