diff --git a/src/tests.rs b/src/tests.rs index 2fe8077..e4f8782 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,9 +1,33 @@ //! Unit tests use super::*; -#[test] -fn single_threaded() -{ - let pop = Populator::new(10); - //for r in pop.iter +/// Testing iteration +mod iteration { + use super::*; + #[test] + fn single_threaded_trivial() + { + let pop = Populator::new(10); + + for r in pop.iter() + { + r.insert(1usize); + } + + assert_eq!(10usize, pop.complete().into_iter().sum::(), "Did not set all elements to 1"); + } + #[test] + fn single_threaded_nontrivial() + { + let pop = Populator::new(10); + + for r in pop.iter() + { + r.insert(String::from("1")); + } + + assert_eq!(10usize, pop.complete().into_iter() + .map(|x| x.parse::().unwrap()) + .sum::(), "Did not set all elements to 1"); + } }