Skip to content

Commit 771a27e

Browse files
Finomnisdjc
authored andcommitted
Add test for multicolor style without current char
1 parent 354b732 commit 771a27e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/style.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,35 @@ mod tests {
983983
assert_eq!(&buf[0], "fghijklmno");
984984
}
985985

986+
#[test]
987+
fn multicolor_without_current_style() {
988+
set_colors_enabled(true);
989+
990+
const CHARS: &str = "=-";
991+
const WIDTH: u16 = 8;
992+
let pos = Arc::new(AtomicPosition::new());
993+
// half finished
994+
pos.set(2);
995+
let state = ProgressState::new(Some(4), pos);
996+
let mut buf = Vec::new();
997+
998+
let style = ProgressStyle::with_template("{wide_bar}")
999+
.unwrap()
1000+
.progress_chars(CHARS);
1001+
style.format_state(&state, &mut buf, WIDTH);
1002+
assert_eq!(&buf[0], "====----");
1003+
1004+
buf.clear();
1005+
let style = ProgressStyle::with_template("{wide_bar:.red.on_blue/green.on_cyan}")
1006+
.unwrap()
1007+
.progress_chars(CHARS);
1008+
style.format_state(&state, &mut buf, WIDTH);
1009+
assert_eq!(
1010+
&buf[0],
1011+
"\u{1b}[31m\u{1b}[44m====\u{1b}[32m\u{1b}[46m----\u{1b}[0m\u{1b}[0m"
1012+
);
1013+
}
1014+
9861015
#[test]
9871016
fn wide_element_style() {
9881017
set_colors_enabled(true);

0 commit comments

Comments
 (0)