trpl-zh-cn/listings/ch11-writing-automated-tests/listing-11-07/src/lib.rs

15 lines
200 B
Rust
Raw Normal View History

2024-10-20 23:44:05 +08:00
pub fn add_two(a: usize) -> usize {
2022-02-06 16:43:51 +08:00
a + 2
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_adds_two() {
2024-10-20 23:44:05 +08:00
let result = add_two(2);
assert_eq!(result, 4);
2022-02-06 16:43:51 +08:00
}
}