mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-25 06:57:31 -05:00
Merge pull request #1782 from danielsomerfield/main
Fix all_fruits_types_in_basket to fail if all fruit kinds are not included
This commit is contained in:
commit
0cd96afe63
1 changed files with 13 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue