1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
pub fn add(a: i32, b: i32) -> i32 { a + b } #[cfg(test)] mod tests { use super::*; #[test] fn test_add() { assert_eq!(add(2, 2), 4); } #[test] fn test_add_negative() { assert_eq!(add(-1, 1), 0); } }