summaryrefslogtreecommitdiffstats
path: root/crates/searcher/src/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/searcher/src/macros.rs')
-rw-r--r--crates/searcher/src/macros.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/searcher/src/macros.rs b/crates/searcher/src/macros.rs
new file mode 100644
index 00000000..d8224e41
--- /dev/null
+++ b/crates/searcher/src/macros.rs
@@ -0,0 +1,25 @@
+/// Like assert_eq, but nicer output for long strings.
+#[cfg(test)]
+#[macro_export]
+macro_rules! assert_eq_printed {
+ ($expected:expr, $got:expr, $($tt:tt)*) => {
+ let expected = &*$expected;
+ let got = &*$got;
+ let label = format!($($tt)*);
+ if expected != got {
+ panic!("
+printed outputs differ! (label: {})
+
+expected:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+{}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+got:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+{}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+", label, expected, got);
+ }
+ }
+}