Skip to content

Commit

Permalink
tests: Add test for double-width utf-8 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Nukesor committed Aug 7, 2021
1 parent 81be4fb commit 704f683
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/all/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ mod presets_test;
mod property_test;
mod simple_test;
mod styling_test;
mod utf_8_characters;
33 changes: 33 additions & 0 deletions tests/all/utf_8_characters.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use pretty_assertions::assert_eq;

use comfy_table::*;

#[test]
fn simple_emoji_table() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec![
"This is a text",
"This is another text",
"This is the third text",
])
.add_row(&vec![
"This is another text",
"Now\nadd some\nmulti line stuff",
"✅",
]);

println!("{}", table.to_string());
let expected = "
+----------------------+----------------------+------------------------+
| Header1 | Header2 | Header3 |
+======================================================================+
| This is a text | This is another text | This is the third text |
|----------------------+----------------------+------------------------|
| This is another text | Now | ✅ |
| | add some | |
| | multi line stuff | |
+----------------------+----------------------+------------------------+";
assert_eq!("\n".to_string() + &table.to_string(), expected);
}

0 comments on commit 704f683

Please sign in to comment.