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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
///
/// ```rust
/// use asserts_rs::*;
/// asserts_eq!(1, 1); //OK
/// asserts_eq!(1, 1, 1); // OK
/// ```
/// ```should_panic
/// use asserts_rs::*;
/// asserts_eq!(1, 1, 1, 2); // panic 1 not equal to 2
/// ```
/// 
#[macro_export]
macro_rules! asserts_eq {
    ($expresson:expr, $expected:expr) => {
        assert_eq!($expresson, $expected);
    };

    ($expresson:expr, $expected:expr, $($others:expr),+) => {
        assert_eq!($expresson, $expected);
        asserts_eq!($expresson, $($others),+);
    };
}

///
/// ```rust
/// use asserts_rs::*;
/// asserts_ne!(1, 2); //OK
/// asserts_ne!(1, 2, 3); // OK
/// ```
/// ```should_panic
/// use asserts_rs::*;
/// asserts_ne!(1, 2, 1, 3); // panic 1 equal to 1
/// ```
/// 
#[macro_export]
macro_rules! asserts_ne {
    ($expresson:expr, $expected:expr) => {
        assert_ne!($expresson, $expected);
    };

    ($expresson:expr, $expected:expr, $($others:expr),+) => {
        assert_ne!($expresson, $expected);
        asserts_ne!($expresson, $($others),+);
    };
}

///
/// ```rust
/// use asserts_rs::*;
/// asserts_eq_one_of!(1, 1); //OK
/// asserts_eq_one_of!(1, 1, 2); // OK
/// ```
/// ```should_panic
/// use asserts_rs::*;
/// asserts_eq_one_of!(1, 2, 3); // panic 1 is not equals to any of numbers in (2, 3)s
/// ```
/// 
#[macro_export]
macro_rules! asserts_eq_one_of {
    ($expresson:expr, $expected:expr) => {
        assert_eq!($expresson, $expected);
    };

    ($expresson:expr, $expected:expr, $($others:expr),+) => {
        if ($expresson != $expected) {
            asserts_eq_one_of!($expresson, $($others),+);
        } else {
            assert_eq!($expresson, $expected);
        }
    };
}

///
/// ```rust
/// use asserts_rs::*;
/// asserts_ne_one_of!(1, 2); //OK
/// asserts_ne_one_of!(1, 2, 3); // OK
/// ```
/// ```should_panic
/// use asserts_rs::*;
/// asserts_ne_one_of!(1, 1, 1); // panic 1 is equals to all of numbers in (1, 1)
/// ```
/// 
#[macro_export]
macro_rules! asserts_ne_one_of {
    ($expresson:expr, $expected:expr) => {
        assert_ne!($expresson, $expected);
    };

    ($expresson:expr, $expected:expr, $($others:expr),+) => {
        if ($expresson == $expected) {
            asserts_ne_one_of!($expresson, $($others),+);
        } else {
            assert_ne!($expresson, $expected);
        }
    };
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_asserts_eq() {
        asserts_eq!(1, 1);
        asserts_eq!(1, 1, 1);
    }

    #[test]
    #[should_panic]
    fn test_asserts_eq_should_fail() {
        asserts_eq!(1, 2);
        asserts_eq!(1, 2, 3);
    }

    #[test]
    fn test_asserts_ne() {
        asserts_ne!(1, 2);
        asserts_ne!(1, 2, 3);
    }

    #[test]
    #[should_panic]
    fn test_asserts_ne_should_fail() {
        asserts_ne!(1, 1);
        asserts_ne!(1, 1, 1);
    }

    #[test]
    fn test_asserts_eq_one_of() {
        asserts_eq_one_of!(1, 1);
        asserts_eq_one_of!(1, 1, 2);
    }

    #[test]
    #[should_panic]
    fn test_asserts_eq_one_of_should_fail() {
        asserts_eq_one_of!(1, 2);
        asserts_eq_one_of!(1, 2, 3);
    }

    #[test]
    fn test_asserts_ne_one_of() {
        asserts_ne_one_of!(1, 2);
        asserts_ne_one_of!(1, 1, 2);
        asserts_ne_one_of!(1, 2, 3);
    }

    #[test]
    #[should_panic]
    fn test_asserts_ne_one_of_should_fail() {
        asserts_ne_one_of!(1, 1);
        asserts_ne_one_of!(1, 1, 1);
    }
}