From 7b98f46ec894981e526813cd7190bcf50486261c Mon Sep 17 00:00:00 2001 From: LukeMathWalker <20745048+LukeMathWalker@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:31:10 +0100 Subject: [PATCH] Change if-else exercise to require an if-else --- .../02_basic_calculator/03_if_else/src/lib.rs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/exercises/02_basic_calculator/03_if_else/src/lib.rs b/exercises/02_basic_calculator/03_if_else/src/lib.rs index 15af33e..fa2e06e 100644 --- a/exercises/02_basic_calculator/03_if_else/src/lib.rs +++ b/exercises/02_basic_calculator/03_if_else/src/lib.rs @@ -1,24 +1,36 @@ -/// Return `true` if `n` is even, `false` otherwise. -fn is_even(n: u32) -> bool { +/// Return `12` if `n` is even, +/// `13` if `n` is divisible by `3`, +/// `17` otherwise. +fn magic_number(n: u32) -> u32 { todo!() } #[cfg(test)] mod tests { - use crate::is_even; + use crate::magic_number; #[test] fn one() { - assert!(!is_even(1)); + assert_eq!(magic_number(1), 17); } #[test] fn two() { - assert!(is_even(2)); + assert_eq!(magic_number(2), 12); + } + + #[test] + fn six() { + assert_eq!(magic_number(6), 12); + } + + #[test] + fn nine() { + assert_eq!(magic_number(9), 13); } #[test] fn high() { - assert!(!is_even(231)); + assert_eq!(magic_number(233), 17); } }