From d9f72d6ad261b7b8fe97fb80423780e8361abb86 Mon Sep 17 00:00:00 2001 From: Torsten Scheck Date: Mon, 3 Jul 2017 18:07:04 +0200 Subject: [PATCH 1/1] Added exemplary unit test for iter_mut(). --- solutions/src/list.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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); + } + } } -- 2.30.2