projects
/
rust-101.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
383f5bd
)
Added exemplary unit test for iter_mut().
author
Torsten Scheck
<torsten.scheck@gmx.de>
Mon, 3 Jul 2017 16:07:04 +0000
(18:07 +0200)
committer
Torsten Scheck
<torsten.scheck@gmx.de>
Mon, 3 Jul 2017 16:07:04 +0000
(18:07 +0200)
solutions/src/list.rs
patch
|
blob
|
history
diff --git
a/solutions/src/list.rs
b/solutions/src/list.rs
index c7ae6ad2565651a2628536cce710d2e3cdb1c2c4..1c794fc3f81aa1da1849ce1ae1b620fe63ac8620 100644
(file)
--- 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::<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);
+ }
+ }
}