iteration: Single threaded full iterators populate and drop correctly for trivial and non-trivial types. Fortune for parapop's current commit: Half blessing − 半吉master
parent
4b85a45a27
commit
9272f1addb
@ -1,9 +1,33 @@
|
||||
//! Unit tests
|
||||
use super::*;
|
||||
|
||||
/// 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::<usize>(), "Did not set all elements to 1");
|
||||
}
|
||||
#[test]
|
||||
fn single_threaded()
|
||||
fn single_threaded_nontrivial()
|
||||
{
|
||||
let pop = Populator::new(10);
|
||||
//for r in pop.iter
|
||||
|
||||
for r in pop.iter()
|
||||
{
|
||||
r.insert(String::from("1"));
|
||||
}
|
||||
|
||||
assert_eq!(10usize, pop.complete().into_iter()
|
||||
.map(|x| x.parse::<usize>().unwrap())
|
||||
.sum::<usize>(), "Did not set all elements to 1");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue