summaryrefslogtreecommitdiff
path: root/bindgen/extra_assertions.rs
diff options
context:
space:
mode:
authorChristian Poveda <christian.poveda@ferrous-systems.com>2022-09-23 21:36:14 -0500
committerChristian Poveda <christian.poveda@ferrous-systems.com>2022-10-04 20:47:17 -0500
commit0296f9e86c7756e718b6b82836ce1e09b5f8d08a (patch)
treeb5954c6680b243c0b1671a80ea973ef90877e462 /bindgen/extra_assertions.rs
parenta900f8f863d1313ad76603234aaeea22bb9ba7b3 (diff)
split the repo into a workspace
remove `clap` dependency :tada: update the book installation instructions
Diffstat (limited to 'bindgen/extra_assertions.rs')
-rw-r--r--bindgen/extra_assertions.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/bindgen/extra_assertions.rs b/bindgen/extra_assertions.rs
new file mode 100644
index 00000000..0888bf39
--- /dev/null
+++ b/bindgen/extra_assertions.rs
@@ -0,0 +1,34 @@
+//! Macros for defining extra assertions that should only be checked in testing
+//! and/or CI when the `testing_only_extra_assertions` feature is enabled.
+
+/// Simple macro that forwards to assert! when using
+/// testing_only_extra_assertions.
+#[macro_export]
+macro_rules! extra_assert {
+ ( $cond:expr ) => {
+ if cfg!(feature = "testing_only_extra_assertions") {
+ assert!($cond);
+ }
+ };
+ ( $cond:expr , $( $arg:tt )+ ) => {
+ if cfg!(feature = "testing_only_extra_assertions") {
+ assert!($cond, $( $arg )* )
+ }
+ };
+}
+
+/// Simple macro that forwards to assert_eq! when using
+/// testing_only_extra_assertions.
+#[macro_export]
+macro_rules! extra_assert_eq {
+ ( $lhs:expr , $rhs:expr ) => {
+ if cfg!(feature = "testing_only_extra_assertions") {
+ assert_eq!($lhs, $rhs);
+ }
+ };
+ ( $lhs:expr , $rhs:expr , $( $arg:tt )+ ) => {
+ if cfg!(feature = "testing_only_extra_assertions") {
+ assert!($lhs, $rhs, $( $arg )* );
+ }
+ };
+}