実際のところ
adder/ ├── Cargo.toml ├── src/ │ └── lib.rs └── tests/ └── add_tests.rs
src/lib.rs
pub fn add(a: i32, b: i32) -> i32 { a + b }
tests/add_tests.rs
use adder::add; #[test] fn test_add_positive_numbers() { assert_eq!(add(2, 3), 5); } #[test] fn test_add_negative_numbers() { assert_eq!(add(-2, -3), -5); } #[test] fn test_add_zero() { assert_eq!(add(0, 5), 5); } #[test] fn test_add_negative_and_positive() { assert_eq!(add(-2, 3), 1); } #[test] fn test_add_large_numbers() { assert_eq!(add(1000000, 2000000), 3000000); }