1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-03-21 21:27:30 +02:00

36 lines
627 B
Rust
Raw Normal View History

2020-04-30 21:17:17 -07:00
// Step 1: Make me compile!
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
2024-05-22 15:04:12 +02:00
fn foo_if_fizz(fizzish: &str) -> &str {
2020-04-30 21:17:17 -07:00
if fizzish == "fizz" {
"foo"
} else {
1
}
}
fn main() {
// You can optionally experiment here.
}
2020-04-30 21:17:17 -07:00
// No test changes needed!
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn foo_for_fizz() {
2024-05-22 15:13:18 +02:00
assert_eq!(foo_if_fizz("fizz"), "foo");
2020-04-30 21:17:17 -07:00
}
#[test]
fn bar_for_fuzz() {
2024-05-22 15:13:18 +02:00
assert_eq!(foo_if_fizz("fuzz"), "bar");
2020-04-30 21:17:17 -07:00
}
#[test]
fn default_to_baz() {
2024-05-22 15:13:18 +02:00
assert_eq!(foo_if_fizz("literally anything"), "baz");
2020-04-30 21:17:17 -07:00
}
}