| //! https://doc.rust-lang.org/rust-by-example/testing/unit_testing.html | |
| pub fn add(a: i32, b: i32) -> i32 { | |
| a + b | |
| } | |
| #[cfg(test)] | |
| mod tests { | |
| // Note this useful idiom: importing names from outer (for mod tests) scope. | |
| use super::*; | |
| #[test] | |
| fn test_add() { | |
| assert_eq!(add(1, 2), 3); | |
| } | |
| } |