Skip to content

Commit 40b38d2

Browse files
committed
test: Add tests to ensure merge works as expected
and does indeed overwrite the former colors with the latter.
1 parent 2d114cd commit 40b38d2

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/markdown/text_style.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,4 +521,30 @@ mod tests {
521521
let attrs: Vec<_> = style.iter_attributes().collect();
522522
assert_eq!(attrs, expected);
523523
}
524+
525+
#[rstest]
526+
#[case::fg_color(
527+
TextStyle::default().bold().fg_color(Color::Red),
528+
TextStyle::default().fg_color(Color::Blue),
529+
TextStyle::default().bold().fg_color(Color::Blue)
530+
)]
531+
#[case::fg_color(
532+
TextStyle::default().fg_color(Color::Red),
533+
TextStyle::default().bold().fg_color(Color::Blue),
534+
TextStyle::default().bold().fg_color(Color::Blue)
535+
)]
536+
#[case::bg_color(
537+
TextStyle::default().bold().bg_color(Color::Yellow),
538+
TextStyle::default().bg_color(Color::Green),
539+
TextStyle::default().bold().bg_color(Color::Green)
540+
)]
541+
#[case::bg_color(
542+
TextStyle::default().bg_color(Color::Yellow),
543+
TextStyle::default().bold().bg_color(Color::Green),
544+
TextStyle::default().bold().bg_color(Color::Green)
545+
)]
546+
fn merge_overwrites_colors(#[case] mut some: TextStyle, #[case] other: TextStyle, #[case] output: TextStyle) {
547+
some.merge(&other);
548+
assert_eq!(some, output);
549+
}
524550
}

0 commit comments

Comments
 (0)