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