Skip to content

Commit 3b03d3a

Browse files
de-vri-esjakoschiko
authored andcommitted
Do not show fake operator in pretty-printed assert_matches failure.
1 parent 3ff9a91 commit 3b03d3a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

library/test/src/pretty_print_assertion.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn print_pretty_bool_assertion(macro_name: &'static str, assert: &BoolAssertion)
8383
}
8484

8585
fn print_plain_binary_assertion(macro_name: &'static str, assert: &BinaryAssertion<'_>) {
86-
if macro_name == "assert_eq" || macro_name == "assert_ne" {
86+
if is_specalized_macro(macro_name) {
8787
eprint!(
8888
concat!(
8989
"Assertion:\n",
@@ -116,7 +116,7 @@ fn print_plain_binary_assertion(macro_name: &'static str, assert: &BinaryAsserti
116116
}
117117

118118
fn print_pretty_binary_assertion(macro_name: &'static str, assert: &BinaryAssertion<'_>) {
119-
if macro_name == "assert_eq" || macro_name == "assert_ne" {
119+
if is_specalized_macro(macro_name) {
120120
eprint!(
121121
concat!(
122122
"{bold}Assertion:{reset}\n",
@@ -166,3 +166,9 @@ fn print_plain_message(message: &std::fmt::Arguments<'_>) {
166166
fn print_pretty_message(message: &std::fmt::Arguments<'_>) {
167167
eprintln!("{bold}Message:{reset}\n {msg}", bold = BOLD, reset = RESET, msg = message,);
168168
}
169+
170+
fn is_specalized_macro(macro_name: &str) -> bool {
171+
// Specialized macros already imply the operator in their name,
172+
// so we print them without repeating the operator.
173+
macro_name == "assert_eq" || macro_name == "assert_neq" || macro_name == "assert_matches"
174+
}

0 commit comments

Comments
 (0)