Testing2 [Rust] Testing 예제_2 (27일차) fn prints_and_returns_10(a: i32) -> i32 { println!("I got the vaue {}", 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); } } pub fn add_two(a: i32) -> i32 { a + 2 } #[cfg(test)] mod tests { use super::*; #[.. 2023. 1. 9. [Rust] Testing 예제 (26일차) pub fn add(left: usize, right: usize) -> usize { left + right } #[cfg(test)] mod tests { #[test] fn exploration() { assert_eq!(2 + 2, 4); } } pub fn add(left: usize, right: usize) -> usize { left + right } #[cfg(test)] mod tests { #[test] fn exploration() { assert_eq!(2 + 2, 4); } #[test] fn another() { panic!("Make this test fail"); } } #[derive(Debug)] pub struct Rectangle { length: u32, width.. 2023. 1. 8. 이전 1 다음