Fixed tests Lists
This commit is contained in:
@@ -4,26 +4,33 @@ use esercizi::es06_list::LinkedList;
|
|||||||
fn test_front() {
|
fn test_front() {
|
||||||
let mut list = LinkedList::new();
|
let mut list = LinkedList::new();
|
||||||
|
|
||||||
|
assert_eq!(0, list.len());
|
||||||
assert_eq!(None, list.get_front());
|
assert_eq!(None, list.get_front());
|
||||||
assert_eq!(None, list.pop_front());
|
assert_eq!(None, list.pop_front());
|
||||||
assert_eq!(None, list.get_front());
|
assert_eq!(None, list.get_front());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_front(50);
|
list.push_front(50);
|
||||||
|
assert_eq!(1, list.len());
|
||||||
assert_eq!(Some(50), list.get_front());
|
assert_eq!(Some(50), list.get_front());
|
||||||
assert_eq!(Some(50), list.pop_front());
|
assert_eq!(Some(50), list.pop_front());
|
||||||
assert_eq!(None, list.get_front());
|
assert_eq!(None, list.get_front());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_front(50);
|
list.push_front(50);
|
||||||
list.push_front(20);
|
list.push_front(20);
|
||||||
|
assert_eq!(2, list.len());
|
||||||
assert_eq!(Some(20), list.get_front());
|
assert_eq!(Some(20), list.get_front());
|
||||||
assert_eq!(Some(20), list.pop_front());
|
assert_eq!(Some(20), list.pop_front());
|
||||||
assert_eq!(Some(50), list.get_front());
|
assert_eq!(Some(50), list.get_front());
|
||||||
assert_eq!(Some(50), list.pop_front());
|
assert_eq!(Some(50), list.pop_front());
|
||||||
assert_eq!(None, list.get_front());
|
assert_eq!(None, list.get_front());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_front(50);
|
list.push_front(50);
|
||||||
list.push_front(20);
|
list.push_front(20);
|
||||||
list.push_front(150);
|
list.push_front(150);
|
||||||
|
assert_eq!(3, list.len());
|
||||||
assert_eq!(Some(150), list.get_front());
|
assert_eq!(Some(150), list.get_front());
|
||||||
assert_eq!(Some(150), list.pop_front());
|
assert_eq!(Some(150), list.pop_front());
|
||||||
assert_eq!(Some(20), list.get_front());
|
assert_eq!(Some(20), list.get_front());
|
||||||
@@ -31,32 +38,40 @@ fn test_front() {
|
|||||||
assert_eq!(Some(50), list.get_front());
|
assert_eq!(Some(50), list.get_front());
|
||||||
assert_eq!(Some(50), list.pop_front());
|
assert_eq!(Some(50), list.pop_front());
|
||||||
assert_eq!(None, list.get_front());
|
assert_eq!(None, list.get_front());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_back() {
|
fn test_back() {
|
||||||
let mut list = LinkedList::new();
|
let mut list = LinkedList::new();
|
||||||
|
|
||||||
|
assert_eq!(0, list.len());
|
||||||
assert_eq!(None, list.get_back());
|
assert_eq!(None, list.get_back());
|
||||||
assert_eq!(None, list.pop_back());
|
assert_eq!(None, list.pop_back());
|
||||||
assert_eq!(None, list.get_back());
|
assert_eq!(None, list.get_back());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_back(50);
|
list.push_back(50);
|
||||||
|
assert_eq!(1, list.len());
|
||||||
assert_eq!(Some(50), list.get_back());
|
assert_eq!(Some(50), list.get_back());
|
||||||
assert_eq!(Some(50), list.pop_back());
|
assert_eq!(Some(50), list.pop_back());
|
||||||
assert_eq!(None, list.get_back());
|
assert_eq!(None, list.get_back());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_back(50);
|
list.push_back(50);
|
||||||
list.push_back(20);
|
list.push_back(20);
|
||||||
|
assert_eq!(2, list.len());
|
||||||
assert_eq!(Some(20), list.get_back());
|
assert_eq!(Some(20), list.get_back());
|
||||||
assert_eq!(Some(20), list.pop_back());
|
assert_eq!(Some(20), list.pop_back());
|
||||||
assert_eq!(Some(50), list.get_back());
|
assert_eq!(Some(50), list.get_back());
|
||||||
assert_eq!(Some(50), list.pop_back());
|
assert_eq!(Some(50), list.pop_back());
|
||||||
assert_eq!(None, list.get_back());
|
assert_eq!(None, list.get_back());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_back(50);
|
list.push_back(50);
|
||||||
list.push_back(20);
|
list.push_back(20);
|
||||||
list.push_back(150);
|
list.push_back(150);
|
||||||
|
assert_eq!(3, list.len());
|
||||||
assert_eq!(Some(150), list.get_back());
|
assert_eq!(Some(150), list.get_back());
|
||||||
assert_eq!(Some(150), list.pop_back());
|
assert_eq!(Some(150), list.pop_back());
|
||||||
assert_eq!(Some(20), list.get_back());
|
assert_eq!(Some(20), list.get_back());
|
||||||
@@ -64,6 +79,7 @@ fn test_back() {
|
|||||||
assert_eq!(Some(50), list.get_back());
|
assert_eq!(Some(50), list.get_back());
|
||||||
assert_eq!(Some(50), list.pop_back());
|
assert_eq!(Some(50), list.pop_back());
|
||||||
assert_eq!(None, list.get_back());
|
assert_eq!(None, list.get_back());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ fn test_front() {
|
|||||||
assert_eq!(false, list.is_empty());
|
assert_eq!(false, list.is_empty());
|
||||||
assert_eq!(Some(50), list.pop_front());
|
assert_eq!(Some(50), list.pop_front());
|
||||||
assert_eq!(true, list.is_empty());
|
assert_eq!(true, list.is_empty());
|
||||||
assert_eq!(0, list.len());
|
|
||||||
assert_eq!(None, list.pop_front());
|
assert_eq!(None, list.pop_front());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_front(50);
|
list.push_front(50);
|
||||||
list.push_front(20);
|
list.push_front(20);
|
||||||
@@ -25,6 +25,7 @@ fn test_front() {
|
|||||||
assert_eq!(Some(20), list.pop_front());
|
assert_eq!(Some(20), list.pop_front());
|
||||||
assert_eq!(Some(50), list.pop_front());
|
assert_eq!(Some(50), list.pop_front());
|
||||||
assert_eq!(None, list.pop_front());
|
assert_eq!(None, list.pop_front());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_front(50);
|
list.push_front(50);
|
||||||
list.push_front(20);
|
list.push_front(20);
|
||||||
@@ -35,6 +36,7 @@ fn test_front() {
|
|||||||
assert_eq!(Some(20), list.pop_front());
|
assert_eq!(Some(20), list.pop_front());
|
||||||
assert_eq!(Some(50), list.pop_front());
|
assert_eq!(Some(50), list.pop_front());
|
||||||
assert_eq!(None, list.pop_front());
|
assert_eq!(None, list.pop_front());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -52,8 +54,8 @@ fn test_back() {
|
|||||||
assert_eq!(false, list.is_empty());
|
assert_eq!(false, list.is_empty());
|
||||||
assert_eq!(Some(50), list.pop_back());
|
assert_eq!(Some(50), list.pop_back());
|
||||||
assert_eq!(true, list.is_empty());
|
assert_eq!(true, list.is_empty());
|
||||||
assert_eq!(0, list.len());
|
|
||||||
assert_eq!(None, list.pop_back());
|
assert_eq!(None, list.pop_back());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_back(50);
|
list.push_back(50);
|
||||||
list.push_back(20);
|
list.push_back(20);
|
||||||
@@ -62,6 +64,7 @@ fn test_back() {
|
|||||||
assert_eq!(Some(20), list.pop_back());
|
assert_eq!(Some(20), list.pop_back());
|
||||||
assert_eq!(Some(50), list.pop_back());
|
assert_eq!(Some(50), list.pop_back());
|
||||||
assert_eq!(None, list.pop_back());
|
assert_eq!(None, list.pop_back());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
|
|
||||||
list.push_back(50);
|
list.push_back(50);
|
||||||
list.push_back(20);
|
list.push_back(20);
|
||||||
@@ -72,6 +75,7 @@ fn test_back() {
|
|||||||
assert_eq!(Some(20), list.pop_back());
|
assert_eq!(Some(20), list.pop_back());
|
||||||
assert_eq!(Some(50), list.pop_back());
|
assert_eq!(Some(50), list.pop_back());
|
||||||
assert_eq!(None, list.pop_back());
|
assert_eq!(None, list.pop_back());
|
||||||
|
assert_eq!(0, list.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user