1pub mod calc1;
2pub mod calc2;
3pub mod calc3;
4
5#[cfg(test)]
6mod tests {
7 use super::calc1::{add, sub};
8 use super::calc2::{multiply, rate};
9 use super::calc3::{pow, log};
10
11 #[test]
12 fn test_add() {
13 assert_eq!(add(10, 20), 30);
14 assert_eq!(add(u32::MAX, 1), u32::MAX); }
16
17 #[test]
18 fn test_sub() {
19 assert_eq!(sub(30, 10), 20);
20 assert_eq!(sub(u32::MIN, 1), u32::MIN);
21 }
22
23 #[test]
24 fn test_multiply() {
25 assert_eq!(multiply(30, 2), 60);
26 assert_eq!(multiply(u32::MAX, 2), u32::MAX);
27 }
28
29 #[test]
30 fn test_rate() {
31 assert_eq!(rate(30, 2), 15);
32 assert_eq!(rate(30, 0), 0);
33 }
34
35 #[test]
36 fn test_pow() {
37 assert_eq!(pow(2, 3), 8);
38 assert_eq!(pow(64, 2), 4096);
39 }
40
41 #[test]
42 fn test_log() {
43 assert_eq!(log(100, 10), 2.0);
44 assert_eq!(log(4096, 2), 12.0)
45 }
46}