Skip to content

Commit

Permalink
Differentiate between ansi_term style and colored style due to deprec…
Browse files Browse the repository at this point in the history
…ation of reverse
  • Loading branch information
atezet committed Oct 10, 2024
1 parent 4bf79fa commit 215832a
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions tests/ansi_term_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ mod compat_colors {
}

macro_rules! test_simple_style {
($string:expr, $style:ident) => {
($string:expr, $colored_style:ident, $ansi_term_style:ident) => {
#[test]
fn $style() {
let s = format!("{} {}", $string, stringify!($style));
fn $colored_style() {
let s = format!("{} {}", $string, stringify!($colored_style));
assert_eq!(
s.$style().to_string(),
ansi_term::Style::new().$style().paint(s).to_string()
s.$colored_style().to_string(),
ansi_term::Style::new()
.$ansi_term_style()
.paint(s)
.to_string()
)
}
};
Expand All @@ -53,13 +56,13 @@ mod compat_styles {
use super::colored;
use super::colored::*;

test_simple_style!("test string", bold);
test_simple_style!("test string", dimmed);
test_simple_style!("test string", italic);
test_simple_style!("test string", underline);
test_simple_style!("test string", blink);
test_simple_style!("test string", reverse);
test_simple_style!("test string", hidden);
test_simple_style!("test string", bold, bold);
test_simple_style!("test string", dimmed, dimmed);
test_simple_style!("test string", italic, italic);
test_simple_style!("test string", underline, underline);
test_simple_style!("test string", blink, blink);
test_simple_style!("test string", reversed, reverse);
test_simple_style!("test string", hidden, hidden);
}

macro_rules! test_simple_bgcolor {
Expand Down

0 comments on commit 215832a

Please sign in to comment.