jacderida_exp_add_lib/
lib.rs1pub fn add_one(x: i32) -> i32 {
2 x + 1
3}
4
5pub fn add_two(x: i32) -> i32 {
6 x + 2
7}
8
9pub fn add_three(x: i32) -> i32 {
10 x + 3
11}
12
13pub fn add_four(x: i32) -> i32 {
14 x + 4
15}
16
17#[cfg(test)]
18mod tests {
19 use super::add_four;
20 use super::add_one;
21 use super::add_three;
22 use super::add_two;
23
24 #[test]
25 fn should_add_one() {
26 assert_eq!(2, add_one(1));
27 }
28
29 #[test]
30 fn should_add_two() {
31 assert_eq!(3, add_two(1));
32 }
33
34 #[test]
35 fn should_add_three() {
36 assert_eq!(4, add_three(1));
37 }
38
39 #[test]
40 fn should_add_four() {
41 assert_eq!(5, add_four(1));
42 }
43}