#[derive(Debug)] struct Rectangle { width: u32, height: u32, } impl Rectangle { fn can_hold(&self, other: &Rectangle) -> bool { self.width >= other.width && self.height >= other.height } } pub fn greeting(name: &str) -> String { format!("hello {}!", name) } #[cfg(test)] mod tests { use super::*; #[test] fn exception() { let result = 2+2; assert_eq!(result, 4); } #[test] fn another() { println!("this one will fail"); } #[test] fn hold() { let larger = Rectangle { width: 7, height: 8, }; let smaller = Rectangle { width: 5, height: 4, }; assert!(larger.can_hold(&smaller)); } #[test] fn greeting_contain_names() { let result = greeting("caol"); assert!(result.contains("carol"), "gretting did not contain name, the value is {}", result); } }