From: Torsten Scheck Date: Mon, 3 Jul 2017 16:07:04 +0000 (+0200) Subject: Added exemplary unit test for iter_mut(). X-Git-Url: https://git.ralfj.de/rust-101.git/commitdiff_plain/d9f72d6ad261b7b8fe97fb80423780e8361abb86?ds=inline;hp=383f5bdfee5830c66cd273f5b4ee9be47d093b31 Added exemplary unit test for iter_mut(). --- diff --git a/solutions/src/list.rs b/solutions/src/list.rs index c7ae6ad..1c794fc 100644 --- a/solutions/src/list.rs +++ b/solutions/src/list.rs @@ -204,4 +204,20 @@ mod tests { } assert_eq!(count.count.get(), 20); } + + #[test] + fn test_iter_mut() { + let mut l = LinkedList::::new(); + for i in 0..5 { + l.push_back(i); + } + + assert_eq!(l.pop_front(), Some(0)); + assert_eq!(l.pop_back(), Some(4)); + + for (n, i) in l.iter_mut().enumerate() { + *i-=1; + assert_eq!(n as i32, *i); + } + } }