1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
pub mod exp;
pub mod fmt;
pub mod fnc;
pub mod fs;
pub mod obj;

#[cfg(test)]
mod tests {
    #[test]
    fn inc() {
        let mut num = 3;

        crate::exp::inc!(num);
        assert_eq!(num, 4);

        crate::exp::inc!(num);
        assert_eq!(num, 5);
    }

    #[test]
    fn dec() {
        let mut num = 3;

        crate::exp::dec!(num);
        assert_eq!(num, 2);

        crate::exp::dec!(num);
        assert_eq!(num, 1);
    }

    #[test]
    fn ternary() {
        let test = |val: bool| crate::exp::ternary!(val, "something", "nothing");

        assert_eq!(test(true), "something");
        assert_eq!(test(false), "nothing");
    }

    #[test]
    fn then() {
        let mut var = "";

        crate::exp::then!(true, var = "something");
        assert_eq!(var, "something");
    }

    #[test]
    fn string() {
        assert_eq!(crate::fmt::string!(), "");
        assert_eq!(crate::fmt::string!("something"), "something".to_string());
    }

    #[test]
    fn str() {
        assert_eq!(crate::fmt::str!("something".to_string()), "something");
    }

    #[test]
    fn fmtstr() {
        let data = 123;
        let var = "hello";

        assert_eq!(crate::fmt::fmtstr!("{var} world {data}{}", 45), "hello world 12345");
    }

    #[test]
    fn fn_name() {
        assert_eq!(crate::fnc::function_name!(), "fn_name");
    }

    #[test]
    fn fn_path() {
        assert_eq!(crate::fnc::function_path!(), "fn_path");
    }

    #[test]
    fn clone() {
        let var: String = Default::default();

        assert_eq!(crate::obj::clone!(var), "");
    }

    #[test]
    fn file_exists() { assert_eq!(crate::fs::file_exists!("tests/file.txt"), true) }

    #[test]
    fn folder_exists() { assert_eq!(crate::fs::folder_exists!("tests/dir"), true) }

    #[test]
    fn path_empty() { assert_eq!(crate::fs::path_empty!("tests/empty_file.txt"), true) }

    #[test]
    fn path_content() { assert_eq!(crate::fs::path_empty!("tests/file.txt"), false) }
}