add 8, 11, 12

This commit is contained in:
woojin
2023-08-18 22:10:35 +09:00
parent e500317044
commit b0ee36a9ff
31 changed files with 1797 additions and 73 deletions

View File

@@ -0,0 +1,27 @@
//! Test cases for assignment11/linked_list.rs
#[cfg(test)]
mod test_linked_list {
use super::super::linked_list::*;
#[derive(Debug, PartialEq, Eq)]
struct V(usize);
#[test]
fn test_linked_list() {
let mut list = SinglyLinkedList::new();
list.push_back(V(3));
list.push_front(V(2));
list.push_back(V(4));
list.push_front(V(1));
list.push_back(V(5));
assert_eq!(list.pop_front(), Some(V(1)));
assert_eq!(list.pop_back(), Some(V(5)));
assert_eq!(list.pop_front(), Some(V(2)));
assert_eq!(list.pop_back(), Some(V(4)));
assert_eq!(list.pop_front(), Some(V(3)));
assert_eq!(list.pop_back(), None);
assert_eq!(list.pop_front(), None);
}
}