Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rust-lang/rustlings
Browse files Browse the repository at this point in the history
  • Loading branch information
liv committed May 17, 2023
2 parents f452fd7 + 6d1f8c5 commit 4c638e3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Expand Up @@ -2109,6 +2109,15 @@
"contributions": [
"content"
]
},
{
"login": "Ben2917",
"name": "Ben",
"avatar_url": "https://avatars.githubusercontent.com/u/10279994?v=4",
"profile": "https://github.com/Ben2917",
"contributions": [
"content"
]
}
],
"contributorsPerLine": 8,
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.md
Expand Up @@ -298,6 +298,7 @@ authors.
<td align="center" valign="top" width="12.5%"><a href="https://github.com/rb5014"><img src="https://avatars.githubusercontent.com/u/105397317?v=4?s=100" width="100px;" alt="rb5014"/><br /><sub><b>rb5014</b></sub></a><br /><a href="#content-rb5014" title="Content">🖋</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://github.com/deedy5"><img src="https://avatars.githubusercontent.com/u/65482418?v=4?s=100" width="100px;" alt="deedy5"/><br /><sub><b>deedy5</b></sub></a><br /><a href="#content-deedy5" title="Content">🖋</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://github.com/lionel-rowe"><img src="https://avatars.githubusercontent.com/u/26078826?v=4?s=100" width="100px;" alt="lionel-rowe"/><br /><sub><b>lionel-rowe</b></sub></a><br /><a href="#content-lionel-rowe" title="Content">🖋</a></td>
<td align="center" valign="top" width="12.5%"><a href="https://github.com/Ben2917"><img src="https://avatars.githubusercontent.com/u/10279994?v=4?s=100" width="100px;" alt="Ben"/><br /><sub><b>Ben</b></sub></a><br /><a href="#content-Ben2917" title="Content">🖋</a></td>
</tr>
</tbody>
</table>
Expand Down
49 changes: 40 additions & 9 deletions exercises/iterators/iterators5.rs
Expand Up @@ -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]
Expand All @@ -82,13 +97,29 @@ 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> {
Expand Down

0 comments on commit 4c638e3

Please sign in to comment.