simple-linked-list: test_peek_returns_head_element tests head element
Closes
@@ -47,6 +47,12 @@ fn test_peek_returns_head_element() {
list.push(2);
assert_eq!(list.peek(), Some(&2), "Element must be 2");
assert_eq!(list.peek(), Some(&2), "Element must be still 2");
+ list.push(3);
+ assert_eq!(list.peek(), Some(&3), "Head element is now 3");
+ assert_eq!(list.pop(), Some(3), "Element must be 3");
+ assert_eq!(list.peek(), Some(&2), "Head element is now 2");
+ assert_eq!(list.pop(), Some(2), "Element must be 2");
+ assert_eq!(list.peek(), None, "No element should be contained in list");
}
#[test]
