1//! Macros for defining extra assertions that should only be checked in testing
2//! and/or CI when the `testing_only_extra_assertions` feature is enabled.
3
4/// Simple macro that forwards to assert! when using
5/// testing_only_extra_assertions.
6#[macro_export]
7macro_rules! extra_assert {
8 ( $cond:expr ) => {
9 if cfg!(feature = "testing_only_extra_assertions") {
10 assert!($cond);
11 }
12 };
13 ( $cond:expr , $( $arg:tt )+ ) => {
14 if cfg!(feature = "testing_only_extra_assertions") {
15 assert!($cond, $( $arg )* )
16 }
17 };
18}
19
20/// Simple macro that forwards to assert_eq! when using
21/// testing_only_extra_assertions.
22#[macro_export]
23macro_rules! extra_assert_eq {
24 ( $lhs:expr , $rhs:expr ) => {
25 if cfg!(feature = "testing_only_extra_assertions") {
26 assert_eq!($lhs, $rhs);
27 }
28 };
29 ( $lhs:expr , $rhs:expr , $( $arg:tt )+ ) => {
30 if cfg!(feature = "testing_only_extra_assertions") {
31 assert!($lhs, $rhs, $( $arg )* );
32 }
33 };
34}
35