Skip to content

Commit 934f618

Browse files
committed
Add color to assert_rendered_output
1 parent 791d954 commit 934f618

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/test_helpers/assertions/assert_rendered_output.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod render_view_line;
66
use std::fmt::Debug;
77

88
use bitflags::bitflags;
9+
use crossterm::style::Stylize as _;
910

1011
#[expect(unused_imports, reason = "Allowed for future use.")]
1112
pub(crate) use self::{
@@ -49,8 +50,8 @@ pub(crate) fn _assert_rendered_output(
4950
let mut mismatch = false;
5051
let mut error_output = vec![
5152
String::from("\nUnexpected output!"),
52-
String::from("--- Expected"),
53-
String::from("+++ Actual"),
53+
"--- Expected".red().to_string(),
54+
"+++ Actual".green().to_string(),
5455
String::from("=========="),
5556
];
5657

@@ -63,26 +64,26 @@ pub(crate) fn _assert_rendered_output(
6364
};
6465

6566
if expected_pattern.matches(output) {
66-
error_output.push(format!(" {}", expected_pattern.expected()));
67+
error_output.push(format!(" {}", expected_pattern.expected()).white().to_string());
6768
}
6869
else {
6970
mismatch = true;
70-
error_output.push(format!("-{}", expected_pattern.expected()));
71-
error_output.push(format!("+{}", expected_pattern.actual(output)));
71+
error_output.push(format!("-{}", expected_pattern.expected()).red().to_string());
72+
error_output.push(format!("+{}", expected_pattern.actual(output)).green().to_string());
7273
}
7374
}
7475

7576
match expected_patterns.len() {
7677
a if a > actual.len() => {
7778
mismatch = true;
7879
for expected_pattern in expected_patterns.iter().skip(actual.len()) {
79-
error_output.push(format!("-{}", expected_pattern.expected().as_str()));
80+
error_output.push(format!("-{}", expected_pattern.expected().as_str()).red().to_string());
8081
}
8182
},
8283
a if a < actual.len() => {
8384
mismatch = true;
8485
for line in actual.iter().skip(expected_patterns.len()) {
85-
error_output.push(format!("+{}", replace_invisibles(line)));
86+
error_output.push(format!("+{}", replace_invisibles(line)).green().to_string());
8687
}
8788
},
8889
_ => {},

0 commit comments

Comments
 (0)