Add more debug assertion macros
This commit is contained in:
parent
91518b82fd
commit
97cdfd33dd
1 changed files with 32 additions and 2 deletions
|
@ -26,8 +26,8 @@ macro_rules! nih_log {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A `debug_assert!()` analogue that prints the error instead with line number information instead
|
/// A `debug_assert!()` analogue that prints the error with line number information instead of
|
||||||
/// of panicking.
|
/// panicking.
|
||||||
///
|
///
|
||||||
/// TODO: Detect if we're running under a debugger, and trigger a break if we are
|
/// TODO: Detect if we're running under a debugger, and trigger a break if we are
|
||||||
macro_rules! nih_debug_assert {
|
macro_rules! nih_debug_assert {
|
||||||
|
@ -42,3 +42,33 @@ macro_rules! nih_debug_assert {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A `debug_assert_eq!()` analogue that prints the error with line number information instead of
|
||||||
|
/// panicking.
|
||||||
|
macro_rules! nih_debug_assert_eq {
|
||||||
|
($left:expr, $right:expr) => (
|
||||||
|
if cfg!(debug_assertions) && $left != $right {
|
||||||
|
nih_log!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right)));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
(left:expr, $right:expr, $format:expr $(, $arg:tt)*) => (
|
||||||
|
if cfg!(debug_assertions) && $left != $right {
|
||||||
|
nih_log!(concat!("Debug assertion failed: ", stringify!($left), " != ", stringify!($right), ", ", $format) $(, $arg)*);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A `debug_assert_neq!()` analogue that prints the error with line number information instead of
|
||||||
|
/// panicking.
|
||||||
|
macro_rules! nih_debug_assert_neq {
|
||||||
|
($left:expr, $right:expr) => (
|
||||||
|
if cfg!(debug_assertions) && $left == $right {
|
||||||
|
nih_log!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right)));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
(left:expr, $right:expr, $format:expr $(, $arg:tt)*) => (
|
||||||
|
if cfg!(debug_assertions) && $left == $right {
|
||||||
|
nih_log!(concat!("Debug assertion failed: ", stringify!($left), " == ", stringify!($right), ", ", $format) $(, $arg)*);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue