Last active
November 26, 2024 12:40
-
-
Save masiarek/1c14ed8fe43408a620f61311a3dad901 to your computer and use it in GitHub Desktop.
compilation is OK - however "cargo test" fails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
fn factorial(n: u64) -> u64 { | |
if n == 0 || n == 1 { | |
1 | |
} else { | |
n * factorial(n - 1) | |
} | |
} | |
} | |
#[cfg(test)] | |
mod tests { | |
use crate::factorial; | |
#[test] | |
fn first() { | |
assert_eq!(factorial(0), 1); | |
} | |
#[test] | |
fn fifth() { | |
assert_eq!(factorial(4), 24); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment