1pub mod debug;
2
3#[macro_export]
15macro_rules! asserts_eq {
16 ($expresson:expr, $expected:expr) => {
17 assert_eq!($expresson, $expected);
18 };
19
20 ($expresson:expr, $expected:expr, $($others:expr),+) => {
21 assert_eq!($expresson, $expected);
22 asserts_eq!($expresson, $($others),+);
23 };
24}
25
26#[macro_export]
38macro_rules! asserts_ne {
39 ($expresson:expr, $expected:expr) => {
40 assert_ne!($expresson, $expected);
41 };
42
43 ($expresson:expr, $expected:expr, $($others:expr),+) => {
44 assert_ne!($expresson, $expected);
45 asserts_ne!($expresson, $($others),+);
46 };
47}
48
49#[macro_export]
61macro_rules! asserts_eq_one_of {
62 ($expresson:expr, $expected:expr) => {
63 assert_eq!($expresson, $expected);
64 };
65
66 ($expresson:expr, $expected:expr, $($others:expr),+) => {
67 if ($expresson != $expected) {
68 asserts_eq_one_of!($expresson, $($others),+);
69 } else {
70 assert_eq!($expresson, $expected);
71 }
72 };
73}
74
75#[macro_export]
87macro_rules! asserts_ne_one_of {
88 ($expresson:expr, $expected:expr) => {
89 assert_ne!($expresson, $expected);
90 };
91
92 ($expresson:expr, $expected:expr, $($others:expr),+) => {
93 if ($expresson == $expected) {
94 asserts_ne_one_of!($expresson, $($others),+);
95 } else {
96 assert_ne!($expresson, $expected);
97 }
98 };
99}
100
101#[cfg(test)]
102mod tests {
103 use super::*;
104
105 #[test]
106 fn test_asserts_eq() {
107 asserts_eq!(1, 1);
108 asserts_eq!(1, 1, 1);
109 }
110
111 #[test]
112 #[should_panic]
113 fn test_asserts_eq_should_fail() {
114 asserts_eq!(1, 2);
115 asserts_eq!(1, 2, 3);
116 }
117
118 #[test]
119 fn test_asserts_ne() {
120 asserts_ne!(1, 2);
121 asserts_ne!(1, 2, 3);
122 }
123
124 #[test]
125 #[should_panic]
126 fn test_asserts_ne_should_fail() {
127 asserts_ne!(1, 1);
128 asserts_ne!(1, 1, 1);
129 }
130
131 #[test]
132 fn test_asserts_eq_one_of() {
133 asserts_eq_one_of!(1, 1);
134 asserts_eq_one_of!(1, 1, 2);
135 }
136
137 #[test]
138 #[should_panic]
139 fn test_asserts_eq_one_of_should_fail() {
140 asserts_eq_one_of!(1, 2);
141 asserts_eq_one_of!(1, 2, 3);
142 }
143
144 #[test]
145 fn test_asserts_ne_one_of() {
146 asserts_ne_one_of!(1, 2);
147 asserts_ne_one_of!(1, 1, 2);
148 asserts_ne_one_of!(1, 2, 3);
149 }
150
151 #[test]
152 #[should_panic]
153 fn test_asserts_ne_one_of_should_fail() {
154 asserts_ne_one_of!(1, 1);
155 asserts_ne_one_of!(1, 1, 1);
156 }
157}