summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorliv <shadows_withal@fastmail.com>2023-05-17 16:30:31 +0200
committerliv <shadows_withal@fastmail.com>2023-05-17 16:30:31 +0200
commit4c638e365f4de4f34b6ca3408daa08d5c6688b68 (patch)
tree302326eee6e4a065391cfb698f40de6eecd590ac /exercises
parentf452fd7bb0118d8e56848ec9e3f5e6e733be6316 (diff)
parent6d1f8c5111bbfb58c6443e3776676be70e6a1b3e (diff)
Merge branch 'main' of github.com:rust-lang/rustlings
Diffstat (limited to 'exercises')
-rw-r--r--exercises/iterators/iterators5.rs49
1 files changed, 40 insertions, 9 deletions
diff --git a/exercises/iterators/iterators5.rs b/exercises/iterators/iterators5.rs
index 8709795..dcf0742 100644
--- a/exercises/iterators/iterators5.rs
+++ b/exercises/iterators/iterators5.rs
@@ -65,12 +65,27 @@ mod tests {
}
#[test]
- fn count_equals_for() {
+ fn count_some() {
let map = get_map();
- assert_eq!(
- count_for(&map, Progress::Complete),
- count_iterator(&map, Progress::Complete)
- );
+ assert_eq!(1, count_iterator(&map, Progress::Some));
+ }
+
+ #[test]
+ fn count_none() {
+ let map = get_map();
+ assert_eq!(2, count_iterator(&map, Progress::None));
+ }
+
+ #[test]
+ fn count_complete_equals_for() {
+ let map = get_map();
+ let progressStates = vec![Progress::Complete, Progress::Some, Progress::None];
+ for progressState in progressStates {
+ assert_eq!(
+ count_for(&map, progressState),
+ count_iterator(&map, progressState)
+ );
+ }
}
#[test]
@@ -83,12 +98,28 @@ mod tests {
}
#[test]
+ fn count_collection_some() {
+ let collection = get_vec_map();
+ assert_eq!(1, count_collection_iterator(&collection, Progress::Some));
+ }
+
+ #[test]
+ fn count_collection_none() {
+ let collection = get_vec_map();
+ assert_eq!(4, count_collection_iterator(&collection, Progress::None));
+ }
+
+ #[test]
fn count_collection_equals_for() {
+ let progressStates = vec![Progress::Complete, Progress::Some, Progress::None];
let collection = get_vec_map();
- assert_eq!(
- count_collection_for(&collection, Progress::Complete),
- count_collection_iterator(&collection, Progress::Complete)
- );
+
+ for progressState in progressStates {
+ assert_eq!(
+ count_collection_for(&collection, progressState),
+ count_collection_iterator(&collection, progressState)
+ );
+ }
}
fn get_map() -> HashMap<String, Progress> {