cdb_rust_sample/calc/itself/mod.rs
1pub fn twice(a: i32) -> i32 {
2 a * a
3}
4
5#[cfg(test)]
6mod tests {
7 use super::twice;
8
9 #[test]
10 fn twice_one_should_be_equals_to_one() {
11 assert_eq!(twice(1), 1);
12 }
13
14 #[test]
15 fn twice_two_should_be_equals_to_four() {
16 assert_eq!(twice(2), 4);
17 }
18
19 #[test]
20 fn twice_three_should_be_equals_to_nine() {
21 assert_eq!(twice(3), 9);
22 }
23}