Skip to content

Commit

Permalink
docs ~ add customized assertion example
Browse files Browse the repository at this point in the history
  • Loading branch information
rivy committed Feb 24, 2020
1 parent 2f39b86 commit ebdd31e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/pretty_assertion_custom.rs
@@ -0,0 +1,14 @@
#[allow(unused_imports)]
use pretty_assertions;

// note in docs/PR that "I don't think it's possible" to design a helper macro that simplifies the `assert_eq` generation
// ... a generator macro "shadows" the std? `assert_eq!` macro at a lower scope level (terminology?) causing an error

macro_rules! assert_eq { ($($arg:tt)+) => ({
pretty_assertions::with_config_assert_eq!(
pretty_assertions::AssertConfig { style: pretty_assertions::Color::Yellow.normal(), auto_label: true, prefix_left: "<<=", prefix_right: "=>>", prefix: "<=>", ..Default::default() },
$($arg)+
)
})}

include!("standard_assertion.rs");

0 comments on commit ebdd31e

Please sign in to comment.