2024-09-14 03:48:26 -04:00
|
|
|
fn picky_eater(food: &str) -> &str {
|
|
|
|
if food == "strawberry" {
|
|
|
|
"Yummy!"
|
|
|
|
} else if food == "potato" {
|
|
|
|
"I guess I can eat that."
|
2024-05-22 09:16:50 -04:00
|
|
|
} else {
|
2024-09-14 03:48:26 -04:00
|
|
|
"No thanks!"
|
2024-05-22 09:16:50 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// You can optionally experiment here.
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
2024-09-14 03:48:26 -04:00
|
|
|
fn yummy_food() {
|
|
|
|
assert_eq!(picky_eater("strawberry"), "Yummy!");
|
2024-05-22 09:16:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2024-09-14 03:48:26 -04:00
|
|
|
fn neutral_food() {
|
|
|
|
assert_eq!(picky_eater("potato"), "I guess I can eat that.");
|
2024-05-22 09:16:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2024-09-14 03:48:26 -04:00
|
|
|
fn default_disliked_food() {
|
|
|
|
assert_eq!(picky_eater("broccoli"), "No thanks!");
|
|
|
|
assert_eq!(picky_eater("gummy bears"), "No thanks!");
|
|
|
|
assert_eq!(picky_eater("literally anything"), "No thanks!");
|
2024-05-22 09:16:50 -04:00
|
|
|
}
|
|
|
|
}
|