From b5bbc0be3bb9d2817904920e372be52927a7adb4 Mon Sep 17 00:00:00 2001 From: Gerrit Viljoen Date: Sun, 17 May 2020 12:52:19 +0200 Subject: [PATCH] save game --- src/test.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test.rs b/src/test.rs index 3bddec4..2a90ae8 100644 --- a/src/test.rs +++ b/src/test.rs @@ -673,3 +673,19 @@ fn color_codes_pad_left() { assert_eq!(expected, config.format(input)); } + +#[test] +fn color_codes_trunc() { + let mut config = AsciiTable::default(); + config.columns.insert(0, Column {header: String::new(), max_width: 2, ..Column::default()}); + let input = vec![ + vec!["Hello".color(Color::Blue).bg_color(Color::Yellow).bold()], + vec!["H".color(Color::Blue).bg_color(Color::Yellow).bold()] + ]; + let expected = "┌────┐\n\ + │ \u{1b}[38;5;4m\u{1b}[48;5;3;1mH+\u{1b}[0m │\n\ + │ \u{1b}[38;5;4m\u{1b}[48;5;3;1mH \u{1b}[0m │\n\ + └────┘\n"; + + assert_eq!(expected, config.format(input)); +}