mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
387 B
22 lines
387 B
fn prints_and_returns_10(a: i32) -> i32 {
|
|
println!("I got the value {a}");
|
|
10
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn this_test_will_pass() {
|
|
let value = prints_and_returns_10(4);
|
|
assert_eq!(10, value);
|
|
}
|
|
|
|
#[test]
|
|
fn this_test_will_fail() {
|
|
let value = prints_and_returns_10(8);
|
|
assert_eq!(5, value);
|
|
}
|
|
}
|