Skip to content

Commit 3522678

Browse files
committed
fix: Added some extra tests to validate iterators5 solution
closes: #1387
1 parent 9fc336c commit 3522678

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

exercises/iterators/iterators5.rs

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,27 @@ mod tests {
6565
}
6666

6767
#[test]
68-
fn count_equals_for() {
68+
fn count_some() {
6969
let map = get_map();
70-
assert_eq!(
71-
count_for(&map, Progress::Complete),
72-
count_iterator(&map, Progress::Complete)
73-
);
70+
assert_eq!(1, count_iterator(&map, Progress::Some));
71+
}
72+
73+
#[test]
74+
fn count_none() {
75+
let map = get_map();
76+
assert_eq!(2, count_iterator(&map, Progress::None));
77+
}
78+
79+
#[test]
80+
fn count_complete_equals_for() {
81+
let map = get_map();
82+
let progressStates = vec![Progress::Complete, Progress::Some, Progress::None];
83+
for progressState in progressStates {
84+
assert_eq!(
85+
count_for(&map, progressState),
86+
count_iterator(&map, progressState)
87+
);
88+
}
7489
}
7590

7691
#[test]
@@ -83,14 +98,36 @@ mod tests {
8398
}
8499

85100
#[test]
86-
fn count_collection_equals_for() {
101+
fn count_collection_some() {
87102
let collection = get_vec_map();
88103
assert_eq!(
89-
count_collection_for(&collection, Progress::Complete),
90-
count_collection_iterator(&collection, Progress::Complete)
104+
1,
105+
count_collection_iterator(&collection, Progress::Some)
91106
);
92107
}
93108

109+
#[test]
110+
fn count_collection_none() {
111+
let collection = get_vec_map();
112+
assert_eq!(
113+
4,
114+
count_collection_iterator(&collection, Progress::None)
115+
);
116+
}
117+
118+
#[test]
119+
fn count_collection_equals_for() {
120+
let progressStates = vec![Progress::Complete, Progress::Some, Progress::None];
121+
let collection = get_vec_map();
122+
123+
for progressState in progressStates {
124+
assert_eq!(
125+
count_collection_for(&collection, progressState),
126+
count_collection_iterator(&collection, progressState)
127+
);
128+
}
129+
}
130+
94131
fn get_map() -> HashMap<String, Progress> {
95132
use Progress::*;
96133

0 commit comments

Comments
 (0)