Skip to content

Commit 656140d

Browse files
authored
Merge pull request #1478 from Ben2917/improved_tests_for_iterators5
fix: Added some extra tests to validate iterators5 solution
2 parents 9508e97 + a6f9964 commit 656140d

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

exercises/iterators/iterators5.rs

Lines changed: 40 additions & 9 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]
@@ -82,13 +97,29 @@ mod tests {
8297
);
8398
}
8499

100+
#[test]
101+
fn count_collection_some() {
102+
let collection = get_vec_map();
103+
assert_eq!(1, count_collection_iterator(&collection, Progress::Some));
104+
}
105+
106+
#[test]
107+
fn count_collection_none() {
108+
let collection = get_vec_map();
109+
assert_eq!(4, count_collection_iterator(&collection, Progress::None));
110+
}
111+
85112
#[test]
86113
fn count_collection_equals_for() {
114+
let progressStates = vec![Progress::Complete, Progress::Some, Progress::None];
87115
let collection = get_vec_map();
88-
assert_eq!(
89-
count_collection_for(&collection, Progress::Complete),
90-
count_collection_iterator(&collection, Progress::Complete)
91-
);
116+
117+
for progressState in progressStates {
118+
assert_eq!(
119+
count_collection_for(&collection, progressState),
120+
count_collection_iterator(&collection, progressState)
121+
);
122+
}
92123
}
93124

94125
fn get_map() -> HashMap<String, Progress> {

0 commit comments

Comments
 (0)