2024-05-22 14:16:50 +01:00
|
|
|
// TODO: Fix the compiler error on this function.
|
2024-05-22 14:04:12 +01:00
|
|
|
fn foo_if_fizz(fizzish: &str) -> &str {
|
2020-05-01 05:17:17 +01:00
|
|
|
if fizzish == "fizz" {
|
|
|
|
"foo"
|
|
|
|
} else {
|
|
|
|
1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-17 21:46:21 +01:00
|
|
|
fn main() {
|
|
|
|
// You can optionally experiment here.
|
|
|
|
}
|
|
|
|
|
2024-05-22 14:16:50 +01:00
|
|
|
// TODO: Read the tests to understand the desired behavior.
|
|
|
|
// Make all tests pass without changing them.
|
2020-05-01 05:17:17 +01:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn foo_for_fizz() {
|
2024-05-22 14:16:50 +01:00
|
|
|
// This means that calling `foo_if_fizz` with the argument "fizz" should return "foo".
|
2024-05-22 14:13:18 +01:00
|
|
|
assert_eq!(foo_if_fizz("fizz"), "foo");
|
2020-05-01 05:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn bar_for_fuzz() {
|
2024-05-22 14:13:18 +01:00
|
|
|
assert_eq!(foo_if_fizz("fuzz"), "bar");
|
2020-05-01 05:17:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn default_to_baz() {
|
2024-05-22 14:13:18 +01:00
|
|
|
assert_eq!(foo_if_fizz("literally anything"), "baz");
|
2020-05-01 05:17:17 +01:00
|
|
|
}
|
|
|
|
}
|