From 9272f1addb38d02f50e894bcd3abd8ed3f66e374 Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 11 Feb 2022 16:23:50 +0000 Subject: [PATCH] Started adding unit tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit iteration: Single threaded full iterators populate and drop correctly for trivial and non-trivial types. Fortune for parapop's current commit: Half blessing − 半吉 --- src/tests.rs | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) 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"); + } }