Added exemplary unit test for iter_mut().
authorTorsten Scheck <torsten.scheck@gmx.de>
Mon, 3 Jul 2017 16:07:04 +0000 (18:07 +0200)
committerTorsten Scheck <torsten.scheck@gmx.de>
Mon, 3 Jul 2017 16:07:04 +0000 (18:07 +0200)
solutions/src/list.rs

index c7ae6ad2565651a2628536cce710d2e3cdb1c2c4..1c794fc3f81aa1da1849ce1ae1b620fe63ac8620 100644 (file)
@@ -204,4 +204,20 @@ mod tests {
         }
         assert_eq!(count.count.get(), 20);
     }
         }
         assert_eq!(count.count.get(), 20);
     }
+
+    #[test]
+    fn test_iter_mut() {
+        let mut l = LinkedList::<i32>::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);
+        }
+    }
 }
 }