ConExpression/
lib.rs

1#[cfg(test)]
2mod tests {
3    use super::*;
4
5    #[test]
6    #[ignore]
7    fn it_work() {}
8
9    #[test]
10    fn test_panic() {
11        panic!("test panic here...");
12    }
13
14    #[test]
15    fn test_assert__ok() {
16        assert!(1 == 1);
17    }
18
19    #[test]
20    fn test_assert__failed() {
21        assert!(1 == 2, "1不等于2");
22    }
23
24    #[test]
25    fn test_assert_eq__ok() {
26        assert_eq!(1, 1);
27    }
28
29    #[test]
30    fn test_assert_eq__failed() {
31        assert_eq!(1, 2);
32    }
33
34    #[test]
35    fn test_assert_ne__ok() {
36        assert_ne!(1, 2);
37    }
38
39    #[test]
40    fn test_assert_ne__failed() {
41        assert_ne!(1, 1);
42    }
43
44    #[test]
45    #[should_panic(expected = "panic something!")]
46    fn test_assert_should_panic__ok() {
47        println!("★★★test_assert_should_panic__ok: it will panic something!\n");
48        panic!("panic something!");
49    }
50
51    #[test]
52    #[should_panic(expected = "panic something!")]
53    fn test_assert_should_panic__failed() {
54        println!("★★★test_assert_should_panic__failed: it will panic otherthing!\n");
55        panic!("panic otherthing!");
56    }
57
58    #[test]
59    #[should_panic(expected = "panic something!")]
60    fn test_assert_should_panic__failed_no_panic() {
61        println!("★★★test_assert_should_panic__failed_no_panic: it won't panic anything!\n");
62    }
63}
64
65pub fn run(){
66    println!("\n--------------- call the function of \"run()\" write in lib.rs.\n");
67}