Skip to content

Instantly share code, notes, and snippets.

@masiarek
Last active November 26, 2024 12:40
Show Gist options
  • Save masiarek/1c14ed8fe43408a620f61311a3dad901 to your computer and use it in GitHub Desktop.
Save masiarek/1c14ed8fe43408a620f61311a3dad901 to your computer and use it in GitHub Desktop.
compilation is OK - however "cargo test" fails
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