diff options
| author | Mo <76752051+mo8it@users.noreply.github.com> | 2024-06-24 13:00:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-24 13:00:53 +0200 |
| commit | 0cd96afe63ff88797976b288122b3506688308fe (patch) | |
| tree | 67ab57aa822ca2aaf833dc12181814d94a00f9fd /exercises | |
| parent | 3d540ed946ee9fd522ba9ec26f68055f5c498317 (diff) | |
| parent | 62afbb034f74dc170347d3eff5131e780930d639 (diff) | |
Merge pull request #1782 from danielsomerfield/main
Fix all_fruits_types_in_basket to fail if all fruit kinds are not included
Diffstat (limited to 'exercises')
| -rw-r--r-- | exercises/11_hashmaps/hashmaps2.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/exercises/11_hashmaps/hashmaps2.rs b/exercises/11_hashmaps/hashmaps2.rs index e6380d9..05b7a87 100644 --- a/exercises/11_hashmaps/hashmaps2.rs +++ b/exercises/11_hashmaps/hashmaps2.rs @@ -11,7 +11,7 @@ use std::collections::HashMap; -#[derive(Hash, PartialEq, Eq)] +#[derive(Hash, PartialEq, Eq, Debug)] enum Fruit { Apple, Banana, @@ -81,9 +81,20 @@ mod tests { #[test] fn all_fruit_types_in_basket() { + let fruit_kinds = vec![ + Fruit::Apple, + Fruit::Banana, + Fruit::Mango, + Fruit::Lychee, + Fruit::Pineapple, + ]; + let mut basket = get_fruit_basket(); fruit_basket(&mut basket); - for amount in basket.values() { + for fruit_kind in fruit_kinds { + let amount = basket + .get(&fruit_kind) + .expect(format!("Fruit kind {:?} was not found in basket", fruit_kind).as_str()); assert_ne!(amount, &0); } } |
