1
0
Fork 0
mirror of https://github.com/rust-lang/rustlings.git synced 2024-05-24 17:16:12 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Daniel Somerfield 180942f7af
Merge 62afbb034f into 459c52137a 2024-04-08 11:40:25 +02:00
Daniel Somerfield 62afbb034f Move test array to be in test module as vec 2024-03-27 20:37:19 -07:00
Daniel Somerfield 8bfe2ec71e Fix all_fruits_types_in_basket to fail if all fruit kinds are not included 2023-11-21 14:02:26 -08:00

View File

@ -18,7 +18,7 @@
use std::collections::HashMap;
#[derive(Hash, PartialEq, Eq)]
#[derive(Hash, PartialEq, Eq, Debug)]
enum Fruit {
Apple,
Banana,
@ -81,12 +81,23 @@ mod tests {
let count = basket.values().sum::<u32>();
assert!(count > 11);
}
#[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);
}
}