feat: Adds message to assert_buffer_eq!

This commit is contained in:
Dheepak Krishnamurthy 2024-01-18 23:37:18 -05:00
parent 2819eea82b
commit 9f1b8c9c68
No known key found for this signature in database
GPG key ID: 602B439E509219ED

View file

@ -4,6 +4,9 @@
#[macro_export]
macro_rules! assert_buffer_eq {
($actual_expr:expr, $expected_expr:expr) => {
assert_buffer_eq!($actual_expr, $expected_expr, "buffers not equal")
};
($actual_expr:expr, $expected_expr:expr, $message:expr) => {
match (&$actual_expr, &$expected_expr) {
(actual, expected) => {
if actual.area != expected.area {
@ -46,7 +49,7 @@ macro_rules! assert_buffer_eq {
}
// shouldn't get here, but this guards against future behavior
// that changes equality but not area or content
assert_eq!(actual, expected, "buffers not equal");
assert_eq!(actual, expected, $message);
}
}
};