summaryrefslogtreecommitdiffstats
path: root/vendor/tabled/tests/settings
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/tabled/tests/settings')
-rw-r--r--vendor/tabled/tests/settings/alignment_test.rs138
-rw-r--r--vendor/tabled/tests/settings/color_test.rs34
-rw-r--r--vendor/tabled/tests/settings/colorization.rs64
-rw-r--r--vendor/tabled/tests/settings/column_names_test.rs270
-rw-r--r--vendor/tabled/tests/settings/concat_test.rs140
-rw-r--r--vendor/tabled/tests/settings/disable_test.rs83
-rw-r--r--vendor/tabled/tests/settings/duplicate_test.rs189
-rw-r--r--vendor/tabled/tests/settings/extract_test.rs242
-rw-r--r--vendor/tabled/tests/settings/format_test.rs269
-rw-r--r--vendor/tabled/tests/settings/formatting_test.rs68
-rw-r--r--vendor/tabled/tests/settings/height_test.rs263
-rw-r--r--vendor/tabled/tests/settings/highlingt_test.rs419
-rw-r--r--vendor/tabled/tests/settings/margin_test.rs195
-rw-r--r--vendor/tabled/tests/settings/merge_test.rs196
-rw-r--r--vendor/tabled/tests/settings/mod.rs23
-rw-r--r--vendor/tabled/tests/settings/padding_test.rs138
-rw-r--r--vendor/tabled/tests/settings/panel_test.rs337
-rw-r--r--vendor/tabled/tests/settings/render_settings.rs292
-rw-r--r--vendor/tabled/tests/settings/rotate_test.rs214
-rw-r--r--vendor/tabled/tests/settings/shadow_test.rs105
-rw-r--r--vendor/tabled/tests/settings/span_test.rs1234
-rw-r--r--vendor/tabled/tests/settings/split_test.rs277
-rw-r--r--vendor/tabled/tests/settings/style_test.rs2606
-rw-r--r--vendor/tabled/tests/settings/width_test.rs2836
24 files changed, 10632 insertions, 0 deletions
diff --git a/vendor/tabled/tests/settings/alignment_test.rs b/vendor/tabled/tests/settings/alignment_test.rs
new file mode 100644
index 000000000..0a8145ae2
--- /dev/null
+++ b/vendor/tabled/tests/settings/alignment_test.rs
@@ -0,0 +1,138 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{
+ locator::ByColumnName,
+ object::{Columns, Rows, Segment},
+ Alignment, Modify, Padding, Style,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ full_alignment,
+ Matrix::new(3, 3).with(Style::psql()).with(Modify::new(Segment::all()).with(Alignment::left())),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ head_and_data_alignment,
+ Matrix::new(3, 3)
+ .with(Modify::new(Rows::first()).with(Alignment::left()))
+ .with(Modify::new(Rows::new(1..)).with(Alignment::right())),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ full_alignment_multiline,
+ Matrix::new(3, 3).insert((3, 2), "https://\nwww\n.\nredhat\n.com\n/en")
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left())),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | https:// | 2-2 "
+ " | | www | "
+ " | | . | "
+ " | | redhat | "
+ " | | .com | "
+ " | | /en | "
+);
+
+test_table!(
+ vertical_alignment_test,
+ Matrix::new(3, 3)
+ .insert((2, 2), "E\nnde\navou\nros")
+ .insert((3, 2), "Red\nHat")
+ .insert((3, 3), "https://\nwww\n.\nredhat\n.com\n/en")
+ .with(Style::psql())
+ .with(Modify::new(Columns::new(1..)).with(Alignment::bottom())),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | | E | "
+ " | | nde | "
+ " | | avou | "
+ " | 1-0 | ros | 1-2 "
+ " 2 | | | https:// "
+ " | | | www "
+ " | | | . "
+ " | | | redhat "
+ " | | Red | .com "
+ " | 2-0 | Hat | /en "
+);
+
+test_table!(
+ alignment_doesnt_change_padding,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 0, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Alignment::left())),
+ " N| column 0| column 1| column 2"
+ "----+-----------+-----------+-----------"
+ " 0| 0-0 | 0-1 | 0-2 "
+ " 1| 1-0 | 1-1 | 1-2 "
+ " 2| 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ alignment_global,
+ Matrix::new(3, 3).with(Style::psql()).with(Alignment::right()),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ padding_by_column_name,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(ByColumnName::new("column 0")).with(Padding::new(3, 3, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Alignment::center())),
+ " N | column 0 | column 1 | column 2 "
+ "---+--------------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ padding_by_column_name_not_first_row,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(ByColumnName::new("0-2")).with(Padding::new(3, 3, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Alignment::center())),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ padding_by_column_name_not_existing,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(ByColumnName::new("column 01123123")).with(Padding::new(3, 3, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Alignment::center())),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
diff --git a/vendor/tabled/tests/settings/color_test.rs b/vendor/tabled/tests/settings/color_test.rs
new file mode 100644
index 000000000..b81c63ae3
--- /dev/null
+++ b/vendor/tabled/tests/settings/color_test.rs
@@ -0,0 +1,34 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{Color, Modify};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ color_global,
+ Matrix::new(3, 3).with(Color::FG_MAGENTA),
+ "+---+----------+----------+----------+"
+ "| \u{1b}[35mN\u{1b}[39m | \u{1b}[35mcolumn 0\u{1b}[39m | \u{1b}[35mcolumn 1\u{1b}[39m | \u{1b}[35mcolumn 2\u{1b}[39m |"
+ "+---+----------+----------+----------+"
+ "| \u{1b}[35m0\u{1b}[39m | \u{1b}[35m0-0\u{1b}[39m | \u{1b}[35m0-1\u{1b}[39m | \u{1b}[35m0-2\u{1b}[39m |"
+ "+---+----------+----------+----------+"
+ "| \u{1b}[35m1\u{1b}[39m | \u{1b}[35m1-0\u{1b}[39m | \u{1b}[35m1-1\u{1b}[39m | \u{1b}[35m1-2\u{1b}[39m |"
+ "+---+----------+----------+----------+"
+ "| \u{1b}[35m2\u{1b}[39m | \u{1b}[35m2-0\u{1b}[39m | \u{1b}[35m2-1\u{1b}[39m | \u{1b}[35m2-2\u{1b}[39m |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ color_cell,
+ Matrix::new(3, 3).with(Modify::new((0, 0)).with(Color::BG_BRIGHT_BLACK)),
+ "+---+----------+----------+----------+"
+ "| \u{1b}[100mN\u{1b}[49m | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
diff --git a/vendor/tabled/tests/settings/colorization.rs b/vendor/tabled/tests/settings/colorization.rs
new file mode 100644
index 000000000..49911c494
--- /dev/null
+++ b/vendor/tabled/tests/settings/colorization.rs
@@ -0,0 +1,64 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{
+ object::{Cell, Object},
+ themes::Colorization,
+ Color,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ chess_2x3,
+ Matrix::new(2, 3).with(Colorization::chess(color1(), color2())),
+ "+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41mN\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 0\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106mcolumn 1\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 2\u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[106m \u{1b}[49m\u{1b}[106m0\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m0-0\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m0-1\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-2\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41m1\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m1-0\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m1-1\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m1-2\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+"
+);
+
+test_table!(
+ chess_3x3,
+ Matrix::new(3, 3).with(Colorization::chess(color1(), color2())),
+ "+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41mN\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106mcolumn 0\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 1\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106mcolumn 2\u{1b}[49m\u{1b}[106m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[106m \u{1b}[49m\u{1b}[106m0\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m0-0\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-1\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m0-2\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41m1\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m1-0\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m1-1\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m1-2\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[106m \u{1b}[49m\u{1b}[106m2\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m2-0\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m2-1\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m2-2\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+"
+);
+
+test_table!(
+ rows,
+ Matrix::new(2, 3).with(Colorization::rows([color1(), color2(), color3()])),
+ "+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41mN\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 0\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 1\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 2\u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[106m \u{1b}[49m\u{1b}[106m0\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-0\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-1\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-2\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[1m \u{1b}[22m\u{1b}[1m1\u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m1-0\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m1-1\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m1-2\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\n+---+----------+----------+----------+"
+);
+
+test_table!(
+ columns,
+ Matrix::new(2, 3).with(Colorization::columns([color1(), color2(), color3()])),
+ "+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41mN\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106mcolumn 0\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[1m \u{1b}[22m\u{1b}[1mcolumn 1\u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 2\u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41m0\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-0\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m0-1\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m0-2\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41m1\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m1-0\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m1-1\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m1-2\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+"
+);
+
+test_table!(
+ by_row,
+ Matrix::new(2, 3).with(Colorization::by_row([color1(), color2(), color3()])),
+ "+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41mN\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106mcolumn 0\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[1m \u{1b}[22m\u{1b}[1mcolumn 1\u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 2\u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[106m \u{1b}[49m\u{1b}[106m0\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m0-0\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m0-1\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-2\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[1m \u{1b}[22m\u{1b}[1m1\u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m1-0\u{1b}[49m\u{1b}[41m \u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m1-1\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m1-2\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\n+---+----------+----------+----------+"
+);
+
+test_table!(
+ by_column,
+ Matrix::new(2, 3).with(Colorization::by_column([color1(), color2(), color3()])),
+ "+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41mN\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 0\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 1\u{1b}[49m\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\u{1b}[41mcolumn 2\u{1b}[49m\u{1b}[41m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[106m \u{1b}[49m\u{1b}[106m0\u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-0\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-1\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-2\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m|\n+---+----------+----------+----------+\n|\u{1b}[1m \u{1b}[22m\u{1b}[1m1\u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m1-0\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m1-1\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m1-2\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m|\n+---+----------+----------+----------+"
+);
+
+test_table!(
+ exact,
+ Matrix::new(2, 3).with(Colorization::exact([color1(), color2(), color3()], Cell::new(0, 0).and(Cell::new(1, 1)).and(Cell::new(2, 2)))),
+ "+---+----------+----------+----------+\n|\u{1b}[41m \u{1b}[49m\u{1b}[41mN\u{1b}[49m\u{1b}[41m \u{1b}[49m| column 0 | column 1 | column 2 |\n+---+----------+----------+----------+\n| 0 |\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m0-0\u{1b}[49m\u{1b}[106m \u{1b}[49m\u{1b}[106m \u{1b}[49m| 0-1 | 0-2 |\n+---+----------+----------+----------+\n| 1 | 1-0 |\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m1-1\u{1b}[22m\u{1b}[1m \u{1b}[22m\u{1b}[1m \u{1b}[22m| 1-2 |\n+---+----------+----------+----------+"
+);
+
+fn color1() -> Color {
+ Color::BG_RED
+}
+
+fn color2() -> Color {
+ Color::BG_BRIGHT_CYAN
+}
+
+fn color3() -> Color {
+ Color::BOLD
+}
diff --git a/vendor/tabled/tests/settings/column_names_test.rs b/vendor/tabled/tests/settings/column_names_test.rs
new file mode 100644
index 000000000..c2b23f1e3
--- /dev/null
+++ b/vendor/tabled/tests/settings/column_names_test.rs
@@ -0,0 +1,270 @@
+#![cfg(feature = "std")]
+
+use tabled::{
+ grid::config::AlignmentHorizontal,
+ settings::{themes::ColumnNames, Color},
+ Table,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ new,
+ Matrix::new(3, 3).with(ColumnNames::new(["1", "2", "3", "4"])),
+ "+1--+2---------+3---------+4---------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ new_more_names_then_columns,
+ Matrix::new(3, 3).with(ColumnNames::new(["1", "2", "3", "4", "5", "6", "7"])),
+ "+1--+2---------+3---------+4---------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ new_less_names_then_columns,
+ Matrix::new(3, 3).with(ColumnNames::new(["1", "2"])),
+ "+1--+2---------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ new_empty,
+ Matrix::new(3, 3).with(ColumnNames::new([""; 0])),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ default,
+ Matrix::new(3, 3).with(ColumnNames::default()),
+ "+N--+column 0+column 1+column 2+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+--------+--------+--------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+--------+--------+--------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+--------+--------+--------+"
+);
+
+test_table!(
+ alignment_left,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_alignment(AlignmentHorizontal::Left)),
+ "+&str---+&str------+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ alignment_right,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_alignment(AlignmentHorizontal::Right)),
+ "+---&str+------&str+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ alignment_center,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_alignment(AlignmentHorizontal::Center)),
+ "+-&str--+---&str---+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ alignment_left_offset,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_alignment(AlignmentHorizontal::Left).set_offset(1)),
+ "+-&str--+-&str-----+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ alignment_left_offset_big,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_alignment(AlignmentHorizontal::Left).set_offset(30)),
+ "+------------------------------&str+------------------------------&str+"
+ "| Hello | World |"
+ "+----------------------------------+----------------------------------+"
+ "| and | looooong |"
+ "| | word |"
+ "+----------------------------------+----------------------------------+"
+);
+
+test_table!(
+ alignment_left_offset_0,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_alignment(AlignmentHorizontal::Left).set_offset(0)),
+ "+&str---+&str------+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ alignment_right_offset,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_alignment(AlignmentHorizontal::Right).set_offset(1)),
+ "+--&str-+-----&str-+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ alignment_right_offset_big,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_alignment(AlignmentHorizontal::Right).set_offset(30)),
+ "+&str------------------------------+&str------------------------------+"
+ "| Hello | World |"
+ "+----------------------------------+----------------------------------+"
+ "| and | looooong |"
+ "| | word |"
+ "+----------------------------------+----------------------------------+"
+);
+
+test_table!(
+ alignment_right_offset_0,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_alignment(AlignmentHorizontal::Right).set_offset(0)),
+ "+---&str+------&str+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ set_line,
+ Matrix::new(3, 3).with(ColumnNames::default().set_line(1)),
+ "+---+--------+--------+--------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+N--+column 0+column 1+column 2+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+--------+--------+--------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+--------+--------+--------+"
+);
+
+test_table!(
+ set_line_max_out,
+ Matrix::new(3, 3).with(ColumnNames::default().set_line(100)),
+ "+---+--------+--------+--------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+--------+--------+--------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+--------+--------+--------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+--------+--------+--------+"
+);
+
+test_table!(
+ set_line_0,
+ Matrix::new(3, 3).with(ColumnNames::default().set_line(0)),
+ "+N--+column 0+column 1+column 2+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+--------+--------+--------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+--------+--------+--------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+--------+--------+--------+"
+);
+
+test_table!(
+ set_colors_some_some,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_colors([Some(Color::BG_BLACK), Some(Color::BG_BLUE)])),
+ "+\u{1b}[40m&\u{1b}[49m\u{1b}[40ms\u{1b}[49m\u{1b}[40mt\u{1b}[49m\u{1b}[40mr\u{1b}[49m---+\u{1b}[44m&\u{1b}[49m\u{1b}[44ms\u{1b}[49m\u{1b}[44mt\u{1b}[49m\u{1b}[44mr\u{1b}[49m------+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ set_colors_none_some,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_colors([None, Some(Color::BG_BLUE)])),
+ "+&str---+\u{1b}[44m&\u{1b}[49m\u{1b}[44ms\u{1b}[49m\u{1b}[44mt\u{1b}[49m\u{1b}[44mr\u{1b}[49m------+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ set_colors_none_none,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_colors([None, None])),
+ "+&str---+&str------+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
+
+test_table!(
+ set_colors_empty,
+ Table::new([("Hello", "World"), ("and", "looooong\nword")])
+ .with(ColumnNames::default().set_colors([None; 0])),
+ "+&str---+&str------+"
+ "| Hello | World |"
+ "+-------+----------+"
+ "| and | looooong |"
+ "| | word |"
+ "+-------+----------+"
+);
diff --git a/vendor/tabled/tests/settings/concat_test.rs b/vendor/tabled/tests/settings/concat_test.rs
new file mode 100644
index 000000000..b988dcad9
--- /dev/null
+++ b/vendor/tabled/tests/settings/concat_test.rs
@@ -0,0 +1,140 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{Concat, Style};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ join_vertical_0,
+ Matrix::new(2, 3).insert((1, 0), "123").with(Style::psql())
+ .with(Concat::vertical(Matrix::new(2, 3).to_table()))
+ .to_string(),
+ " N | column 0 | column 1 | column 2 "
+ "-----+----------+----------+----------"
+ " 123 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " N | column 0 | column 1 | column 2 "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+);
+
+test_table!(
+ join_vertical_1,
+ Matrix::new(2, 3)
+ .with(Concat::vertical(Matrix::new(2, 3).insert((1, 0), "123").with(Style::psql()))),
+ "+-----+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+-----+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+-----+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+-----+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+-----+----------+----------+----------+"
+ "| 123 | 0-0 | 0-1 | 0-2 |"
+ "+-----+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+-----+----------+----------+----------+"
+);
+
+test_table!(
+ join_horizontal_0,
+ {
+ let mut table1 = Matrix::table(2, 3);
+ table1.with(Style::ascii());
+ let mut table2 = Matrix::table(2, 3);
+ table2.with(Style::psql());
+ table2.with(Concat::horizontal(table1)).to_string()
+ },
+ " N | column 0 | column 1 | column 2 | N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------+---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 | 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 | 1 | 1-0 | 1-1 | 1-2 "
+);
+
+test_table!(
+ join_horizontal_1,
+ {
+ let mut table1 = Matrix::table(2, 3);
+ table1.with(Style::ascii());
+ let mut table2 = Matrix::table(2, 3);
+ table2.with(Style::psql());
+ table1.with(Concat::horizontal(table2)).to_string()
+ },
+ "+---+----------+----------+----------+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 | N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 | 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 | 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+---+----------+----------+----------+"
+);
+
+test_table!(
+ join_vertical_different_size,
+ {
+ let mut table1 = Matrix::table(2, 2);
+ table1.with(Style::psql());
+ let mut table2 = Matrix::table(2, 3);
+ table2.with(Style::psql());
+ table1.with(Concat::vertical(table2)).to_string()
+ },
+ " N | column 0 | column 1 | "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | "
+ " 1 | 1-0 | 1-1 | "
+ " N | column 0 | column 1 | column 2 "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+);
+
+test_table!(
+ join_horizontal_different_size,
+ {
+ let mut table1 = Matrix::table(2, 3);
+ table1.with(Style::psql());
+ let mut table2 = Matrix::table(3, 3);
+ table2.with(Style::psql());
+ table1.with(Concat::horizontal(table2)).to_string()
+ },
+ " N | column 0 | column 1 | column 2 | N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------+---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 | 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 | 1 | 1-0 | 1-1 | 1-2 "
+ " | | | | 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ join_horizontal_with_not_default_empty_string,
+ {
+ let mut table1 = Matrix::table(2, 3);
+ table1.with(Style::psql());
+ let mut table2 = Matrix::table(3, 3);
+ table2.with(Style::psql());
+ table1.with(Concat::horizontal(table2).default_cell("NaN")).to_string()
+ },
+ " N | column 0 | column 1 | column 2 | N | column 0 | column 1 | column 2 "
+ "-----+----------+----------+----------+---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 | 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 | 1 | 1-0 | 1-1 | 1-2 "
+ " NaN | NaN | NaN | NaN | 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ join_vertical_with_not_default_empty_string,
+ {
+ let mut table1 = Matrix::table(2, 2);
+ table1.with(Style::psql());
+ let mut table2 = Matrix::table(2, 3);
+ table2.with(Style::psql());
+ table1.with(Concat::vertical(table2).default_cell("NaN")).to_string()
+ },
+ " N | column 0 | column 1 | NaN "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | NaN "
+ " 1 | 1-0 | 1-1 | NaN "
+ " N | column 0 | column 1 | column 2 "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+);
diff --git a/vendor/tabled/tests/settings/disable_test.rs b/vendor/tabled/tests/settings/disable_test.rs
new file mode 100644
index 000000000..cf50acf84
--- /dev/null
+++ b/vendor/tabled/tests/settings/disable_test.rs
@@ -0,0 +1,83 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{
+ locator::ByColumnName,
+ object::{Columns, Rows, Segment},
+ style::{HorizontalLine, Style},
+ Alignment, Disable, Modify,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ disable_rows,
+ Matrix::new(3, 3).with(Disable::row(Rows::new(1..=2))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ disable_header,
+ Matrix::new(3, 3).with(Style::psql()).with(Disable::row(Rows::first())),
+ " 0 | 0-0 | 0-1 | 0-2 "
+ "---+-----+-----+-----"
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ disable_all_table_via_rows,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Disable::row(Columns::new(..))),
+ ""
+);
+
+test_table!(
+ disable_header_with_new_styling,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Disable::row(Rows::new(..1)))
+ .with(Style::modern().remove_horizontal().horizontals([HorizontalLine::new(1, Style::modern().get_horizontal())])),
+ "┌───┬─────┬─────┬─────┐"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "├───┼─────┼─────┼─────┤"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└───┴─────┴─────┴─────┘"
+);
+
+test_table!(
+ disable_columns,
+ Matrix::new(3, 3).with(Style::psql()).with(Disable::column(Columns::first())),
+ " column 0 | column 1 | column 2 "
+ "----------+----------+----------"
+ " 0-0 | 0-1 | 0-2 "
+ " 1-0 | 1-1 | 1-2 "
+ " 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ disable_column_by_name,
+ Matrix::new(3, 3).with(Style::psql())
+ .with(Disable::column(ByColumnName::new("column 1")))
+ .with(Disable::column(ByColumnName::new("column 3"))),
+ " N | column 0 | column 2 "
+ "---+----------+----------"
+ " 0 | 0-0 | 0-2 "
+ " 1 | 1-0 | 1-2 "
+ " 2 | 2-0 | 2-2 "
+);
+
+test_table!(
+ disable_all_table_via_columns,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Disable::column(Columns::new(..))),
+ ""
+);
diff --git a/vendor/tabled/tests/settings/duplicate_test.rs b/vendor/tabled/tests/settings/duplicate_test.rs
new file mode 100644
index 000000000..6d15fbfac
--- /dev/null
+++ b/vendor/tabled/tests/settings/duplicate_test.rs
@@ -0,0 +1,189 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{
+ object::{Cell, Columns, Rows, Segment},
+ Dup,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ dup_cell_to_cell,
+ Matrix::new(3, 3).with(Dup::new(Cell::new(0, 0), Cell::new(0, 1))),
+ "+----------+----------+----------+----------+"
+ "| column 0 | column 0 | column 1 | column 2 |"
+ "+----------+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+----------+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+----------+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+----------+----------+----------+----------+"
+);
+
+test_table!(
+ dup_cell_to_column,
+ Matrix::new(3, 3).with(Dup::new(Columns::single(1), Cell::new(0, 0))),
+ "+---+---+----------+----------+"
+ "| N | N | column 1 | column 2 |"
+ "+---+---+----------+----------+"
+ "| 0 | N | 0-1 | 0-2 |"
+ "+---+---+----------+----------+"
+ "| 1 | N | 1-1 | 1-2 |"
+ "+---+---+----------+----------+"
+ "| 2 | N | 2-1 | 2-2 |"
+ "+---+---+----------+----------+"
+);
+
+test_table!(
+ dup_row_to_row_single,
+ Matrix::new(3, 3).with(Dup::new(Rows::single(1), Rows::single(0))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ dup_row_to_row_single_to_many,
+ Matrix::new(3, 3).with(Dup::new(Rows::new(1..3), Rows::single(0))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ dup_row_to_row_single_to_all,
+ Matrix::new(3, 3).with(Dup::new(Rows::new(1..), Rows::single(0))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ dup_row_to_column_single,
+ Matrix::new(3, 3).with(Dup::new(Columns::single(1), Rows::single(0))),
+ "+---+----------+----------+----------+"
+ "| N | N | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | column 0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | column 1 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | column 2 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ dup_column_to_row_single,
+ Matrix::new(3, 3).with(Dup::new(Columns::single(1), Columns::single(0))),
+ "+---+---+----------+----------+"
+ "| N | N | column 1 | column 2 |"
+ "+---+---+----------+----------+"
+ "| 0 | 0 | 0-1 | 0-2 |"
+ "+---+---+----------+----------+"
+ "| 1 | 1 | 1-1 | 1-2 |"
+ "+---+---+----------+----------+"
+ "| 2 | 2 | 2-1 | 2-2 |"
+ "+---+---+----------+----------+"
+);
+
+test_table!(
+ dup_row_to_column_single_repeat,
+ Matrix::new(4, 3).with(Dup::new(Columns::single(1), Rows::single(0))),
+ "+---+----------+----------+----------+"
+ "| N | N | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | column 0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | column 1 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | column 2 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+ "| 3 | N | 3-1 | 3-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ dup_column_to_row_single_stop,
+ Matrix::new(4, 3).with(Dup::new(Rows::single(1), Columns::single(0))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | 0 | 1 | 2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+ "| 3 | 3-0 | 3-1 | 3-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ dup_row_to_global,
+ Matrix::new(4, 3).with(Dup::new(Segment::all(), Rows::single(0))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ dup_column_to_global,
+ Matrix::new(4, 3).with(Dup::new(Segment::all(), Columns::single(0))),
+ "+---+---+---+---+"
+ "| N | 0 | 1 | 2 |"
+ "+---+---+---+---+"
+ "| 3 | N | 0 | 1 |"
+ "+---+---+---+---+"
+ "| 2 | 3 | N | 0 |"
+ "+---+---+---+---+"
+ "| 1 | 2 | 3 | N |"
+ "+---+---+---+---+"
+ "| 0 | 1 | 2 | 3 |"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ dup_empty_table,
+ Matrix::empty().with(Dup::new(Segment::all(), Columns::single(0))),
+ ""
+);
+
+test_table!(
+ dup_invalid_target,
+ Matrix::new(4, 3).with(Dup::new(Segment::all(), Columns::single(99))),
+ Matrix::new(4, 3),
+);
+
+test_table!(
+ dup_invalid_source,
+ Matrix::new(4, 3).with(Dup::new(Rows::single(99), Columns::first())),
+ Matrix::new(4, 3),
+);
diff --git a/vendor/tabled/tests/settings/extract_test.rs b/vendor/tabled/tests/settings/extract_test.rs
new file mode 100644
index 000000000..ce4697d7a
--- /dev/null
+++ b/vendor/tabled/tests/settings/extract_test.rs
@@ -0,0 +1,242 @@
+#![cfg(feature = "std")]
+
+use tabled::{
+ builder::Builder,
+ settings::{
+ object::{Rows, Segment},
+ Alignment, Disable, Extract, Format, Modify, Padding,
+ },
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ extract_segment_full_test,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]"))))
+ .with(Extract::segment(.., ..)),
+ "+-------+--------------+--------------+--------------+"
+ "| [N] | [column 0] | [column 1] | [column 2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [0] | [0-0] | [0-1] | [0-2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [1] | [1-0] | [1-1] | [1-2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [2] | [2-0] | [2-1] | [2-2] |"
+ "+-------+--------------+--------------+--------------+"
+);
+
+test_table!(
+ extract_segment_skip_top_row_test,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]"))))
+ .with(Extract::segment(1.., ..)),
+ "+-------+---------+---------+---------+"
+ "| [0] | [0-0] | [0-1] | [0-2] |"
+ "+-------+---------+---------+---------+"
+ "| [1] | [1-0] | [1-1] | [1-2] |"
+ "+-------+---------+---------+---------+"
+ "| [2] | [2-0] | [2-1] | [2-2] |"
+ "+-------+---------+---------+---------+"
+);
+
+test_table!(
+ extract_segment_skip_column_test,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]"))))
+ .with(Extract::segment(.., 1..)),
+ "+--------------+--------------+--------------+"
+ "| [column 0] | [column 1] | [column 2] |"
+ "+--------------+--------------+--------------+"
+ "| [0-0] | [0-1] | [0-2] |"
+ "+--------------+--------------+--------------+"
+ "| [1-0] | [1-1] | [1-2] |"
+ "+--------------+--------------+--------------+"
+ "| [2-0] | [2-1] | [2-2] |"
+ "+--------------+--------------+--------------+"
+);
+
+test_table!(
+ extract_segment_bottom_right_square_test,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]"))))
+ .with(Extract::segment(2.., 2..)),
+ "+---------+---------+"
+ "| [1-1] | [1-2] |"
+ "+---------+---------+"
+ "| [2-1] | [2-2] |"
+ "+---------+---------+"
+);
+
+test_table!(
+ extract_segment_middle_section_test,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]"))))
+ .with(Extract::segment(1..3, 1..)),
+ "+---------+---------+---------+"
+ "| [0-0] | [0-1] | [0-2] |"
+ "+---------+---------+---------+"
+ "| [1-0] | [1-1] | [1-2] |"
+ "+---------+---------+---------+"
+);
+
+test_table!(
+ extract_segment_empty_test,
+ Matrix::new(3, 3).with(Extract::segment(1..1, 1..1)),
+ ""
+);
+
+test_table!(
+ extract_rows_full_test,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]"))))
+ .with(Extract::rows(..)),
+ "+-------+--------------+--------------+--------------+"
+ "| [N] | [column 0] | [column 1] | [column 2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [0] | [0-0] | [0-1] | [0-2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [1] | [1-0] | [1-1] | [1-2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [2] | [2-0] | [2-1] | [2-2] |"
+ "+-------+--------------+--------------+--------------+"
+);
+
+test_table!(
+ extract_rows_empty_test,
+ Matrix::new(3, 3).with(Extract::rows(0..0)),
+ ""
+);
+
+test_table!(
+ extract_rows_partial_view_test,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]"))))
+ .with(Extract::rows(0..=2)),
+ "+-------+--------------+--------------+--------------+"
+ "| [N] | [column 0] | [column 1] | [column 2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [0] | [0-0] | [0-1] | [0-2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [1] | [1-0] | [1-1] | [1-2] |"
+ "+-------+--------------+--------------+--------------+"
+);
+
+test_table!(
+ extract_columns_full_test,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]"))))
+ .with(Extract::columns(..)),
+ "+-------+--------------+--------------+--------------+"
+ "| [N] | [column 0] | [column 1] | [column 2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [0] | [0-0] | [0-1] | [0-2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [1] | [1-0] | [1-1] | [1-2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [2] | [2-0] | [2-1] | [2-2] |"
+ "+-------+--------------+--------------+--------------+"
+);
+
+test_table!(
+ extract_columns_empty_test,
+ Matrix::new(3, 3).with(Extract::columns(0..0)),
+ ""
+);
+
+test_table!(
+ extract_columns_partial_view_test,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]"))))
+ .with(Extract::columns(0..2)),
+ "+-------+--------------+"
+ "| [N] | [column 0] |"
+ "+-------+--------------+"
+ "| [0] | [0-0] |"
+ "+-------+--------------+"
+ "| [1] | [1-0] |"
+ "+-------+--------------+"
+ "| [2] | [2-0] |"
+ "+-------+--------------+"
+);
+
+test_table!(
+ extract_inside_test,
+ Matrix::new(3, 3).with(Disable::row(Rows::first())).with(Extract::segment(1..2, 1..2)),
+ "+-----+"
+ "| 1-0 |"
+ "+-----+"
+);
+
+test_table!(
+ extract_left_test,
+ Matrix::new(3, 3).with(Disable::row(Rows::first())).with(Extract::segment(.., ..1)),
+ "+---+"
+ "| 0 |"
+ "+---+"
+ "| 1 |"
+ "+---+"
+ "| 2 |"
+ "+---+"
+);
+
+test_table!(
+ extract_right_test,
+ Matrix::new(3, 3).with(Disable::row(Rows::first())).with(Extract::segment(.., 2..)),
+ "+-----+-----+"
+ "| 0-1 | 0-2 |"
+ "+-----+-----+"
+ "| 1-1 | 1-2 |"
+ "+-----+-----+"
+ "| 2-1 | 2-2 |"
+ "+-----+-----+"
+);
+
+test_table!(
+ extract_top_test,
+ Matrix::new(3, 3).with(Disable::row(Rows::first())).with(Extract::segment(..1, ..)),
+ "+---+-----+-----+-----+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+-----+-----+-----+"
+);
+
+test_table!(
+ extract_bottom_test,
+ Matrix::new(3, 3).with(Disable::row(Rows::first())).with(Extract::segment(2.., ..)),
+ "+---+-----+-----+-----+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+-----+-----+-----+"
+);
+
+test_table!(
+ extract_all_test,
+ Matrix::new(3, 3)
+ .with(Disable::row(Rows::first()))
+ .with(Extract::segment(3.., 3..)),
+ ""
+);
+
+test_table!(
+ extract_empty_test,
+ Builder::default().build().with(Extract::segment(.., ..)),
+ ""
+);
diff --git a/vendor/tabled/tests/settings/format_test.rs b/vendor/tabled/tests/settings/format_test.rs
new file mode 100644
index 000000000..82585ca62
--- /dev/null
+++ b/vendor/tabled/tests/settings/format_test.rs
@@ -0,0 +1,269 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{
+ object::{Cell, Columns, Object, Rows, Segment},
+ Alignment, Format, Modify, Padding, Style,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+#[cfg(feature = "color")]
+use owo_colors::OwoColorize;
+
+test_table!(
+ formatting_full_test,
+ Matrix::new(3, 3).with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]")))),
+ "+-----+------------+------------+------------+"
+ "| [N] | [column 0] | [column 1] | [column 2] |"
+ "+-----+------------+------------+------------+"
+ "| [0] | [0-0] | [0-1] | [0-2] |"
+ "+-----+------------+------------+------------+"
+ "| [1] | [1-0] | [1-1] | [1-2] |"
+ "+-----+------------+------------+------------+"
+ "| [2] | [2-0] | [2-1] | [2-2] |"
+ "+-----+------------+------------+------------+"
+);
+
+test_table!(
+ formatting_head_test,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Rows::first()).with(Format::content(|s| format!(":{s}")))),
+ "| :N | :column 0 | :column 1 | :column 2 |"
+ "|----|-----------|-----------|-----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ formatting_row_test,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Rows::new(1..)).with(Format::content(|s| format!("<{s}>")))),
+ " N | column 0 | column 1 | column 2 "
+ "-----+----------+----------+----------"
+ " <0> | <0-0> | <0-1> | <0-2> "
+ " <1> | <1-0> | <1-1> | <1-2> "
+ " <2> | <2-0> | <2-1> | <2-2> "
+);
+
+test_table!(
+ formatting_column_test,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Columns::single(0)).with(Format::content(|s| format!("(x) {s}")))),
+ " (x) N | column 0 | column 1 | column 2 "
+ "-------+----------+----------+----------"
+ " (x) 0 | 0-0 | 0-1 | 0-2 "
+ " (x) 1 | 1-0 | 1-1 | 1-2 "
+ " (x) 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ formatting_multiline_test,
+ Matrix::new(3, 3)
+ .insert((2, 2), "E\nnde\navou\nros")
+ .insert((3, 2), "Red\nHat")
+ .insert((3, 3), "https://\nwww\n.\nredhat\n.com\n/en")
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("(x) {s}")).multiline())),
+ " (x) N | (x) column 0 | (x) column 1 | (x) column 2 "
+ "-------+--------------+--------------+--------------"
+ " (x) 0 | (x) 0-0 | (x) 0-1 | (x) 0-2 "
+ " (x) 1 | (x) 1-0 | (x) E | (x) 1-2 "
+ " | | (x) nde | "
+ " | | (x) avou | "
+ " | | (x) ros | "
+ " (x) 2 | (x) 2-0 | (x) Red | (x) https:// "
+ " | | (x) Hat | (x) www "
+ " | | | (x) . "
+ " | | | (x) redhat "
+ " | | | (x) .com "
+ " | | | (x) /en "
+);
+
+test_table!(
+ formatting_cell_test,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Cell::new(0, 0)).with(Format::content(|s| format!("(x) {s}"))))
+ .with(Modify::new(Cell::new(0, 1)).with(Format::content(|s| format!("(x) {s}"))))
+ .with(Modify::new(Cell::new(0, 2)).with(Format::content(|s| format!("(x) {s}")))),
+ " (x) N | (x) column 0 | (x) column 1 | column 2 "
+ "-------+--------------+--------------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ formatting_combination_and_test,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(
+ Modify::new(Columns::single(0).and(Rows::single(0)))
+ .with(Format::content(|s| format!("(x) {s}"))),
+ ),
+ " (x) N | (x) column 0 | (x) column 1 | (x) column 2 "
+ "-------+--------------+--------------+--------------"
+ " (x) 0 | 0-0 | 0-1 | 0-2 "
+ " (x) 1 | 1-0 | 1-1 | 1-2 "
+ " (x) 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ formatting_combination_not_test,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(
+ Modify::new(Columns::single(0).and(Rows::single(0)).not(Cell::new(0, 0)))
+ .with(Format::content(|s| format!("(x) {s}"))),
+ ),
+ " N | (x) column 0 | (x) column 1 | (x) column 2 "
+ "-------+--------------+--------------+--------------"
+ " (x) 0 | 0-0 | 0-1 | 0-2 "
+ " (x) 1 | 1-0 | 1-1 | 1-2 "
+ " (x) 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ formatting_combination_inverse_test,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Columns::single(0).inverse()).with(Format::content(|s| format!("(x) {s}")))),
+ " N | (x) column 0 | (x) column 1 | (x) column 2 "
+ "---+--------------+--------------+--------------"
+ " 0 | (x) 0-0 | (x) 0-1 | (x) 0-2 "
+ " 1 | (x) 1-0 | (x) 1-1 | (x) 1-2 "
+ " 2 | (x) 2-0 | (x) 2-1 | (x) 2-2 "
+);
+
+test_table!(
+ formatting_combination_intersect_test,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(
+ Modify::new(Columns::new(1..3).intersect(Rows::new(1..3)))
+ .with(Format::content(|s| format!("(x) {s}"))),
+ ),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | (x) 0-0 | (x) 0-1 | 0-2 "
+ " 1 | (x) 1-0 | (x) 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ formatting_using_lambda_test,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Rows::first()).with(Format::content(|s| format!(":{s}")))),
+ "| :N | :column 0 | :column 1 | :column 2 |"
+ "|----|-----------|-----------|-----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ formatting_using_function_test,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Rows::first()).with(Format::content(str::to_uppercase))),
+ "| N | COLUMN 0 | COLUMN 1 | COLUMN 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ format_with_index,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Rows::first()).with(Format::positioned(|a, (b, c)| match (b, c) {
+ (0, 0) => "(0, 0)".to_string(),
+ (0, 1) => "(0, 1)".to_string(),
+ (0, 2) => "(0, 2)".to_string(),
+ _ => a.to_string(),
+ }))),
+ "| (0, 0) | (0, 1) | (0, 2) | column 2 |"
+ "|--------|--------|--------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ format_doesnt_change_padding,
+ Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 1, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Format::content(|s| format!("[{s}]")))),
+ "+-------+--------------+--------------+--------------+"
+ "| [N] | [column 0] | [column 1] | [column 2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [0] | [0-0] | [0-1] | [0-2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [1] | [1-0] | [1-1] | [1-2] |"
+ "+-------+--------------+--------------+--------------+"
+ "| [2] | [2-0] | [2-1] | [2-2] |"
+ "+-------+--------------+--------------+--------------+"
+);
+
+test_table!(
+ formatting_content_str_test,
+ Matrix::new(3, 3).with(Modify::new(Segment::all()).with(Format::content(|_| String::from("Hello World")))),
+ "+-------------+-------------+-------------+-------------+"
+ "| Hello World | Hello World | Hello World | Hello World |"
+ "+-------------+-------------+-------------+-------------+"
+ "| Hello World | Hello World | Hello World | Hello World |"
+ "+-------------+-------------+-------------+-------------+"
+ "| Hello World | Hello World | Hello World | Hello World |"
+ "+-------------+-------------+-------------+-------------+"
+ "| Hello World | Hello World | Hello World | Hello World |"
+ "+-------------+-------------+-------------+-------------+"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ color_test,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(
+ Modify::new(Columns::new(..1).and(Columns::new(2..)))
+ .with(Format::content(|s| s.red().to_string())),
+ )
+ .with(Modify::new(Columns::new(1..2)).with(Format::content(|s| s.blue().to_string()))),
+ " \u{1b}[31mN\u{1b}[39m | \u{1b}[34mcolumn 0\u{1b}[39m | \u{1b}[31mcolumn 1\u{1b}[39m | \u{1b}[31mcolumn 2\u{1b}[39m "
+ "---+----------+----------+----------"
+ " \u{1b}[31m0\u{1b}[39m | \u{1b}[34m0-0\u{1b}[39m | \u{1b}[31m0-1\u{1b}[39m | \u{1b}[31m0-2\u{1b}[39m "
+ " \u{1b}[31m1\u{1b}[39m | \u{1b}[34m1-0\u{1b}[39m | \u{1b}[31m1-1\u{1b}[39m | \u{1b}[31m1-2\u{1b}[39m "
+ " \u{1b}[31m2\u{1b}[39m | \u{1b}[34m2-0\u{1b}[39m | \u{1b}[31m2-1\u{1b}[39m | \u{1b}[31m2-2\u{1b}[39m "
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ color_multiline_test,
+ Matrix::new(3, 3)
+ .insert((2, 2), "E\nnde\navou\nros")
+ .insert((3, 2), "Red\nHat")
+ .insert((3, 3), "https://\nwww\n.\nredhat\n.com\n/en")
+ .with(Style::psql())
+ .with(Modify::new(Columns::new(..1)).with(Format::content(|s| s.red().to_string()).multiline()))
+ .with(Modify::new(Columns::new(1..2)).with(Format::content(|s| s.blue().to_string()).multiline()))
+ .with(Modify::new(Columns::new(2..)).with(Format::content(|s| s.green().to_string()).multiline())),
+ " \u{1b}[31mN\u{1b}[39m | \u{1b}[34mcolumn 0\u{1b}[39m | \u{1b}[32mcolumn 1\u{1b}[39m | \u{1b}[32mcolumn 2\u{1b}[39m "
+ "---+----------+----------+----------\n \u{1b}[31m0\u{1b}[39m | \u{1b}[34m0-0\u{1b}[39m | \u{1b}[32m0-1\u{1b}[39m | \u{1b}[32m0-2\u{1b}[39m "
+ " \u{1b}[31m1\u{1b}[39m | \u{1b}[34m1-0\u{1b}[39m | \u{1b}[32mE\u{1b}[39m | \u{1b}[32m1-2\u{1b}[39m "
+ " | | \u{1b}[32mnde\u{1b}[39m | "
+ " | | \u{1b}[32mavou\u{1b}[39m | "
+ " | | \u{1b}[32mros\u{1b}[39m | "
+ " \u{1b}[31m2\u{1b}[39m | \u{1b}[34m2-0\u{1b}[39m | \u{1b}[32mRed\u{1b}[39m | \u{1b}[32mhttps://\u{1b}[39m "
+ " | | \u{1b}[32mHat\u{1b}[39m | \u{1b}[32mwww\u{1b}[39m \n | | | \u{1b}[32m.\u{1b}[39m "
+ " | | | \u{1b}[32mredhat\u{1b}[39m "
+ " | | | \u{1b}[32m.com\u{1b}[39m "
+ " | | | \u{1b}[32m/en\u{1b}[39m "
+);
diff --git a/vendor/tabled/tests/settings/formatting_test.rs b/vendor/tabled/tests/settings/formatting_test.rs
new file mode 100644
index 000000000..70f925a8b
--- /dev/null
+++ b/vendor/tabled/tests/settings/formatting_test.rs
@@ -0,0 +1,68 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{formatting::Justification, object::Columns, Color, Modify};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ justification,
+ Matrix::new(3, 3).with(Justification::new('#')),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | ##0-0### | ##0-1### | ##0-2### |"
+ "+---+----------+----------+----------+"
+ "| 1 | ##1-0### | ##1-1### | ##1-2### |"
+ "+---+----------+----------+----------+"
+ "| 2 | ##2-0### | ##2-1### | ##2-2### |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ justification_color,
+ Matrix::new(3, 3).with(Justification::new('#').color(Color::BG_RED)),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | \u{1b}[41m##\u{1b}[49m0-0\u{1b}[41m###\u{1b}[49m | \u{1b}[41m##\u{1b}[49m0-1\u{1b}[41m###\u{1b}[49m | \u{1b}[41m##\u{1b}[49m0-2\u{1b}[41m###\u{1b}[49m |"
+ "+---+----------+----------+----------+"
+ "| 1 | \u{1b}[41m##\u{1b}[49m1-0\u{1b}[41m###\u{1b}[49m | \u{1b}[41m##\u{1b}[49m1-1\u{1b}[41m###\u{1b}[49m | \u{1b}[41m##\u{1b}[49m1-2\u{1b}[41m###\u{1b}[49m |"
+ "+---+----------+----------+----------+"
+ "| 2 | \u{1b}[41m##\u{1b}[49m2-0\u{1b}[41m###\u{1b}[49m | \u{1b}[41m##\u{1b}[49m2-1\u{1b}[41m###\u{1b}[49m | \u{1b}[41m##\u{1b}[49m2-2\u{1b}[41m###\u{1b}[49m |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ justification_columns,
+ Matrix::new(3, 3)
+ .with(Modify::new(Columns::single(1)).with(Justification::new('#')))
+ .with(Modify::new(Columns::single(2)).with(Justification::new('@')))
+ .with(Modify::new(Columns::single(3)).with(Justification::new('$'))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | ##0-0### | @@0-1@@@ | $$0-2$$$ |"
+ "+---+----------+----------+----------+"
+ "| 1 | ##1-0### | @@1-1@@@ | $$1-2$$$ |"
+ "+---+----------+----------+----------+"
+ "| 2 | ##2-0### | @@2-1@@@ | $$2-2$$$ |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ justification_color_columns,
+ Matrix::new(3, 3)
+ .with(Modify::new(Columns::single(1)).with(Justification::new('#').color(Color::BG_BLUE)))
+ .with(Modify::new(Columns::single(2)).with(Justification::new('@').color(Color::BG_RED)))
+ .with(Modify::new(Columns::single(3)).with(Justification::new('$').color(Color::BG_WHITE))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | \u{1b}[44m##\u{1b}[49m0-0\u{1b}[44m###\u{1b}[49m | \u{1b}[41m@@\u{1b}[49m0-1\u{1b}[41m@@@\u{1b}[49m | \u{1b}[47m$$\u{1b}[49m0-2\u{1b}[47m$$$\u{1b}[49m |"
+ "+---+----------+----------+----------+"
+ "| 1 | \u{1b}[44m##\u{1b}[49m1-0\u{1b}[44m###\u{1b}[49m | \u{1b}[41m@@\u{1b}[49m1-1\u{1b}[41m@@@\u{1b}[49m | \u{1b}[47m$$\u{1b}[49m1-2\u{1b}[47m$$$\u{1b}[49m |"
+ "+---+----------+----------+----------+"
+ "| 2 | \u{1b}[44m##\u{1b}[49m2-0\u{1b}[44m###\u{1b}[49m | \u{1b}[41m@@\u{1b}[49m2-1\u{1b}[41m@@@\u{1b}[49m | \u{1b}[47m$$\u{1b}[49m2-2\u{1b}[47m$$$\u{1b}[49m |"
+ "+---+----------+----------+----------+"
+);
diff --git a/vendor/tabled/tests/settings/height_test.rs b/vendor/tabled/tests/settings/height_test.rs
new file mode 100644
index 000000000..48d6a6364
--- /dev/null
+++ b/vendor/tabled/tests/settings/height_test.rs
@@ -0,0 +1,263 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{
+ object::{Columns, Segment},
+ Alignment, Format, Height, Modify, Style,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+#[cfg(feature = "color")]
+use owo_colors::OwoColorize;
+
+test_table!(
+ cell_height_increase,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(
+ Modify::new(Columns::first())
+ .with(Height::increase(3))
+ )
+ .with(Modify::new(Segment::all()).with(
+ Alignment::center_vertical()
+ )),
+ "| N | | | |"
+ "| | column 0 | column 1 | column 2 |"
+ "| | | | |"
+ "|---|----------|----------|----------|"
+ "| 0 | | | |"
+ "| | 0-0 | 0-1 | 0-2 |"
+ "| | | | |"
+ "| 1 | | | |"
+ "| | 1-0 | 1-1 | 1-2 |"
+ "| | | | |"
+ "| 2 | | | |"
+ "| | 2-0 | 2-1 | 2-2 |"
+ "| | | | |"
+);
+
+test_table!(
+ table_height_increase,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::first()).with(Alignment::center_vertical()))
+ .with(Height::increase(10)),
+ "| | column 0 | column 1 | column 2 |"
+ "| N | | | |"
+ "| | | | |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| | | | |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| | | | |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "| | | | |"
+);
+
+test_table!(
+ cell_height_increase_zero,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(
+ Modify::new(Columns::first())
+ .with(Height::increase(0))
+ )
+ .with(Modify::new(Segment::all()).with(
+ Alignment::center_vertical()
+ )),
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ table_height_increase_zero,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::first()).with(Alignment::center_vertical()))
+ .with(Height::increase(0)),
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ cell_height_limit,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::first()).with(Format::content(|s| format!("xxxx\n{s}xxxx\nxxxx\n"))))
+ .with(
+ Modify::new(Columns::first())
+ .with(Height::limit(1))
+ )
+ .with(Modify::new(Segment::all()).with(
+ Alignment::center_vertical()
+ )),
+ "| xxxx | column 0 | column 1 | column 2 |"
+ "|------|----------|----------|----------|"
+ "| xxxx | 0-0 | 0-1 | 0-2 |"
+ "| xxxx | 1-0 | 1-1 | 1-2 |"
+ "| xxxx | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ table_height_limit,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::first()).with(Format::content(|s| format!("xxxx\n{s}xxxx\nxxxx\n"))))
+ .with(Modify::new(Columns::first()).with(Alignment::center_vertical()))
+ .with(Height::limit(10)),
+ "| xxxx | column 0 | column 1 | column 2 |"
+ "| Nxxxx | | | |"
+ "|-------|----------|----------|----------|"
+ "| xxxx | 0-0 | 0-1 | 0-2 |"
+ "| 0xxxx | | | |"
+ "| xxxx | 1-0 | 1-1 | 1-2 |"
+ "| 1xxxx | | | |"
+ "| xxxx | 2-0 | 2-1 | 2-2 |"
+ "| 2xxxx | | | |"
+ "| xxxx | | | |"
+);
+
+test_table!(
+ table_height_limit_style_change_after,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::first()).with(Format::content(|s| format!("xxxx\n{s}xxxx\nxxxx\n"))))
+ .with(Modify::new(Columns::first()).with(Alignment::center_vertical()))
+ .with(Height::limit(7)),
+ "| xxxx | column 0 | column 1 | column 2 |"
+ "|-------|----------|----------|----------|"
+ "| xxxx | 0-0 | 0-1 | 0-2 |"
+ "| xxxx | 1-0 | 1-1 | 1-2 |"
+ "| 1xxxx | | | |"
+ "| xxxx | 2-0 | 2-1 | 2-2 |"
+ "| 2xxxx | | | |"
+);
+
+test_table!(
+ cell_height_limit_zero,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::first()).with(Format::content(|s| format!("xxxx\n{s}xxxx\nxxxx\n"))))
+ .with(
+ Modify::new(Columns::first())
+ .with(Height::limit(0))
+ )
+ .with(Modify::new(Segment::all()).with(
+ Alignment::center_vertical()
+ )),
+ "| | column 0 | column 1 | column 2 |"
+ "|--|----------|----------|----------|"
+ "| | 0-0 | 0-1 | 0-2 |"
+ "| | 1-0 | 1-1 | 1-2 |"
+ "| | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ table_height_limit_zero,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(
+ Modify::new(Columns::new(..))
+ .with(Format::content(|s| format!("xxxx\n{s}xxxx\nxxxx\n")))
+ )
+ .with(Height::limit(0)),
+ "|--|--|--|--|"
+);
+
+test_table!(
+ table_height_limit_zero_1,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Height::limit(0))
+ .with(
+ Modify::new(Columns::new(..)).with(Format::content(|s| format!("xxxx\n{s}xxxx\nxxxx\n")))
+ ),
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| | | | |"
+ "|------|------|------|------|"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| | | | |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| | | | |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| xxxx | xxxx | xxxx | xxxx |"
+ "| | | | |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ cell_height_limit_colored,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::first()).with(Format::content(|s| format!("xxxx\n{s}xxxx\nxxxx\n").red().to_string())))
+ .with(
+ Modify::new(Columns::first())
+ .with(Height::limit(1))
+ )
+ .with(Modify::new(Segment::all()).with(
+ Alignment::center_vertical()
+ )),
+ "| \u{1b}[31mxxxx\u{1b}[39m | column 0 | column 1 | column 2 |"
+ "|------|----------|----------|----------|"
+ "| \u{1b}[31mxxxx\u{1b}[39m | 0-0 | 0-1 | 0-2 |"
+ "| \u{1b}[31mxxxx\u{1b}[39m | 1-0 | 1-1 | 1-2 |"
+ "| \u{1b}[31mxxxx\u{1b}[39m | 2-0 | 2-1 | 2-2 |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ table_height_limit_colored,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::first()).with(Format::content(|s| format!("xxxx\n{s}xxxx\nxxxx\n").blue().on_green().to_string())))
+ .with(Modify::new(Columns::first()).with(Alignment::center_vertical()))
+ .with(Height::limit(10)),
+ "| \u{1b}[34;42mxxxx\u{1b}[39m\u{1b}[49m | column 0 | column 1 | column 2 |"
+ "| \u{1b}[34m\u{1b}[42mNxxxx\u{1b}[39m\u{1b}[49m | | | |"
+ "|-------|----------|----------|----------|"
+ "| \u{1b}[34;42mxxxx\u{1b}[39m\u{1b}[49m | 0-0 | 0-1 | 0-2 |"
+ "| \u{1b}[34m\u{1b}[42m0xxxx\u{1b}[39m\u{1b}[49m | | | |"
+ "| \u{1b}[34;42mxxxx\u{1b}[39m\u{1b}[49m | 1-0 | 1-1 | 1-2 |"
+ "| \u{1b}[34m\u{1b}[42m1xxxx\u{1b}[39m\u{1b}[49m | | | |"
+ "| \u{1b}[34;42mxxxx\u{1b}[39m\u{1b}[49m | 2-0 | 2-1 | 2-2 |"
+ "| \u{1b}[34m\u{1b}[42m2xxxx\u{1b}[39m\u{1b}[49m | | | |"
+ "| \u{1b}[34m\u{1b}[42mxxxx\u{1b}[39m\u{1b}[49m | | | |"
+);
+
+#[cfg(feature = "macros")]
+test_table!(
+ cell_height_1x1,
+ tabled::row![tabled::col!["SGML"].with(Height::increase(4))],
+ "+----------+"
+ "| +------+ |"
+ "| | SGML | |"
+ "| | | |"
+ "| +------+ |"
+ "+----------+"
+);
+
+#[cfg(feature = "macros")]
+test_table!(
+ cell_height_1x1_no_top_border,
+ tabled::row![tabled::col!["SGML"].with(Style::ascii().remove_top()).with(Height::increase(4))],
+ "+----------+"
+ "| | SGML | |"
+ "| | | |"
+ "| | | |"
+ "| +------+ |"
+ "+----------+"
+);
diff --git a/vendor/tabled/tests/settings/highlingt_test.rs b/vendor/tabled/tests/settings/highlingt_test.rs
new file mode 100644
index 000000000..cb5ce75f3
--- /dev/null
+++ b/vendor/tabled/tests/settings/highlingt_test.rs
@@ -0,0 +1,419 @@
+#![cfg(feature = "std")]
+
+use tabled::{
+ builder::Builder,
+ settings::{
+ highlight::Highlight,
+ object::{Cell, Columns, Frame, Object, Rows, Segment},
+ style::{Border, Style},
+ },
+};
+
+use crate::matrix::Matrix;
+use testing_table::{static_table, test_table};
+
+test_table!(
+ highlingt_object_exceeds_boundaries,
+ Matrix::new(3, 3).with(Style::modern()).with(Highlight::new(Cell::new(1000, 0), Border::filled('+'))),
+ "┌───┬──────────┬──────────┬──────────┐"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└───┴──────────┴──────────┴──────────┘"
+);
+
+test_table!(
+ highlingt_empty_table,
+ Builder::default()
+ .build()
+ .with(Highlight::new(Segment::all(), Border::filled('+'))),
+ ""
+);
+
+test_table!(
+ highlingt_cell,
+ Matrix::new(3, 3)
+ .with(Style::modern())
+ .with(Highlight::new(Cell::new(0, 0), Border::filled('+')))
+ .with(Highlight::new(Cell::new(1, 1), Border::filled('*'))),
+ "+++++──────────┬──────────┬──────────┐"
+ "+ N + column 0 │ column 1 │ column 2 │"
+ "++++************──────────┼──────────┤"
+ "│ 0 * 0-0 * 0-1 │ 0-2 │"
+ "├───************──────────┼──────────┤"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└───┴──────────┴──────────┴──────────┘"
+);
+
+test_table!(
+ highlingt_row,
+ Matrix::new(3, 3)
+ .with(Style::modern())
+ .with(Highlight::new(Rows::single(0), Border::filled('+')))
+ .with(Highlight::new(Rows::single(3), Border::filled('*'))),
+ "++++++++++++++++++++++++++++++++++++++"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "++++++++++++++++++++++++++++++++++++++"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "**************************************"
+ "* 2 │ 2-0 │ 2-1 │ 2-2 *"
+ "**************************************"
+);
+
+test_table!(
+ highlingt_column,
+ Matrix::new(3, 3)
+ .with(Style::modern())
+ .with(Highlight::new(Columns::single(0), Border::filled('+')))
+ .with(Highlight::new(Columns::single(2), Border::filled('*'))),
+ "+++++──────────************──────────┐"
+ "+ N + column 0 * column 1 * column 2 │"
+ "+───+──────────*──────────*──────────┤"
+ "+ 0 + 0-0 * 0-1 * 0-2 │"
+ "+───+──────────*──────────*──────────┤"
+ "+ 1 + 1-0 * 1-1 * 1-2 │"
+ "+───+──────────*──────────*──────────┤"
+ "+ 2 + 2-0 * 2-1 * 2-2 │"
+ "+++++──────────************──────────┘"
+);
+
+test_table!(
+ highlingt_row_range,
+ Matrix::new(3, 3)
+ .with(Style::modern())
+ .with(Highlight::new(Rows::new(1..3), Border::filled('+'))),
+ "┌───┬──────────┬──────────┬──────────┐"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "++++++++++++++++++++++++++++++++++++++"
+ "+ 0 │ 0-0 │ 0-1 │ 0-2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 1 │ 1-0 │ 1-1 │ 1-2 +"
+ "++++++++++++++++++++++++++++++++++++++"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└───┴──────────┴──────────┴──────────┘"
+);
+
+test_table!(
+ highlingt_column_range,
+ Matrix::new(3, 3)
+ .with(Style::modern())
+ .with(Highlight::new(Columns::new(..2), Border::filled('+'))),
+ "++++++++++++++++──────────┬──────────┐"
+ "+ N │ column 0 + column 1 │ column 2 │"
+ "+───┼──────────+──────────┼──────────┤"
+ "+ 0 │ 0-0 + 0-1 │ 0-2 │"
+ "+───┼──────────+──────────┼──────────┤"
+ "+ 1 │ 1-0 + 1-1 │ 1-2 │"
+ "+───┼──────────+──────────┼──────────┤"
+ "+ 2 │ 2-0 + 2-1 │ 2-2 │"
+ "++++++++++++++++──────────┴──────────┘"
+);
+
+test_table!(
+ highlingt_frame,
+ Matrix::new(3, 3)
+ .with(Style::modern())
+ .with(Highlight::new(
+ Frame,
+ Border::filled('+')
+ .corner_top_left('*')
+ .corner_top_right('#')
+ .corner_bottom_left('@')
+ .corner_bottom_right('.'),
+ )),
+ "*++++++++++++++++++++++++++++++++++++#"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 0 │ 0-0 │ 0-1 │ 0-2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 1 │ 1-0 │ 1-1 │ 1-2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 2 │ 2-0 │ 2-1 │ 2-2 +"
+ "@++++++++++++++++++++++++++++++++++++."
+);
+
+test_table!(
+ highlingt_full,
+ Matrix::new(3, 3)
+ .with(Style::modern())
+ .with(Highlight::new(
+ Segment::all(),
+ Border::filled('+')
+ .corner_top_left('*')
+ .corner_top_right('#')
+ .corner_bottom_left('@')
+ .corner_bottom_right('.'),
+ )),
+ "*++++++++++++++++++++++++++++++++++++#"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 0 │ 0-0 │ 0-1 │ 0-2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 1 │ 1-0 │ 1-1 │ 1-2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 2 │ 2-0 │ 2-1 │ 2-2 +"
+ "@++++++++++++++++++++++++++++++++++++."
+);
+
+test_table!(
+ highlingt_single_column,
+ Matrix::table(3, 0)
+ .with(Style::modern())
+ .with(Highlight::new(Cell::new(0, 0), Border::default().left('*').top('x')))
+ .with(Highlight::new(Rows::new(1..3), Border::default().left('n'))),
+ "┌xxx┐"
+ "* N │"
+ "├───┤"
+ "n 0 │"
+ "n───┤"
+ "n 1 │"
+ "├───┤"
+ "│ 2 │"
+ "└───┘"
+);
+
+test_table!(
+ highlingt_several_times,
+ Matrix::new(3, 3)
+ .with(Style::modern())
+ .with(Highlight::new(Frame, Border::filled('*')))
+ .with(Highlight::new(Cell::new(1, 1), Border::filled('#')))
+ .with(Highlight::new(Columns::single(3), Border::filled('x'))),
+ "**************************xxxxxxxxxxxx"
+ "* N │ column 0 │ column 1 x column 2 x"
+ "*───############──────────x──────────x"
+ "* 0 # 0-0 # 0-1 x 0-2 x"
+ "*───############──────────x──────────x"
+ "* 1 │ 1-0 │ 1-1 x 1-2 x"
+ "*───┼──────────┼──────────x──────────x"
+ "* 2 │ 2-0 │ 2-1 x 2-2 x"
+ "**************************xxxxxxxxxxxx"
+);
+
+// @todo
+//
+// #[test]
+// fn highlingt_empty_border() {
+// let data = create_vector::<3, 3>();
+// let table = Table::new(&data)
+// .with(Style::modern())
+// .with(Highlight::new(Frame, Border::empty()))
+// .to_string();
+
+// let expected = static_table!(
+// " N │ column 0 │ column 1 │ column 2 "
+// "─── ──────────"
+// " 0 0-0 │ 0-1 0-2 "
+// "─── ──────────┼────────── ──────────"
+// " 1 1-0 │ 1-1 1-2 "
+// "─── ──────────"
+// " 2 │ 2-0 │ 2-1 │ 2-2 "
+// );
+
+// assert_eq!(table, expected);
+// }
+
+#[test]
+fn highlingt_complex_figures() {
+ macro_rules! test_highlight {
+ ($object:expr, $expected:expr,) => {
+ let border = Border::filled('+')
+ .corner_top_left('*')
+ .corner_top_right('#')
+ .corner_bottom_left('@')
+ .corner_bottom_right('.');
+
+ let table = Matrix::new(3, 3)
+ .with(Style::modern())
+ .with(Highlight::new($object, border))
+ .to_string();
+
+ assert_eq!(table, $expected);
+ };
+ }
+
+ test_highlight!(
+ Segment::all().not(Segment::new(2.., 1..3)),
+ static_table!(
+ "*++++++++++++++++++++++++++++++++++++#"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 0 │ 0-0 │ 0-1 │ 0-2 +"
+ "+───*+++++++++++++++++++++#──────────+"
+ "+ 1 + 1-0 │ 1-1 + 1-2 +"
+ "+───+──────────┼──────────+──────────+"
+ "+ 2 + 2-0 │ 2-1 + 2-2 +"
+ "@+++.──────────┴──────────@++++++++++."
+ ),
+ );
+
+ test_highlight!(
+ Segment::all()
+ .not(Segment::new(0..1, 1..3))
+ .not(Columns::single(0)),
+ static_table!(
+ "┌───┬──────────┬──────────*++++++++++#"
+ "│ N │ column 0 │ column 1 + column 2 +"
+ "├───*+++++++++++++++++++++.──────────+"
+ "│ 0 + 0-0 │ 0-1 │ 0-2 +"
+ "├───+──────────┼──────────┼──────────+"
+ "│ 1 + 1-0 │ 1-1 │ 1-2 +"
+ "├───+──────────┼──────────┼──────────+"
+ "│ 2 + 2-0 │ 2-1 │ 2-2 +"
+ "└───@++++++++++++++++++++++++++++++++."
+ ),
+ );
+
+ test_highlight!(
+ Segment::all().not(Segment::new(0..1, 1..3)),
+ static_table!(
+ "*+++#──────────┬──────────*++++++++++#"
+ "+ N + column 0 │ column 1 + column 2 +"
+ "+───@+++++++++++++++++++++.──────────+"
+ "+ 0 │ 0-0 │ 0-1 │ 0-2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 1 │ 1-0 │ 1-1 │ 1-2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 2 │ 2-0 │ 2-1 │ 2-2 +"
+ "@++++++++++++++++++++++++++++++++++++."
+ ),
+ );
+
+ test_highlight!(
+ Segment::all().not(Segment::new(1..2, 1..3)),
+ static_table!(
+ "*++++++++++++++++++++++++++++++++++++#"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "+───*+++++++++++++++++++++#──────────+"
+ "+ 0 + 0-0 │ 0-1 + 0-2 +"
+ "+───@+++++++++++++++++++++.──────────+"
+ "+ 1 │ 1-0 │ 1-1 │ 1-2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 2 │ 2-0 │ 2-1 │ 2-2 +"
+ "@++++++++++++++++++++++++++++++++++++."
+ ),
+ );
+
+ test_highlight!(
+ Cell::new(0, 0)
+ .and(Cell::new(3, 3))
+ .and(Cell::new(0, 3))
+ .and(Cell::new(3, 0)),
+ static_table!(
+ "*+++#──────────┬──────────*++++++++++#"
+ "+ N + column 0 │ column 1 + column 2 +"
+ "@+++.──────────┼──────────@++++++++++."
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "*+++#──────────┼──────────*++++++++++#"
+ "+ 2 + 2-0 │ 2-1 + 2-2 +"
+ "@+++.──────────┴──────────@++++++++++."
+ ),
+ );
+
+ test_highlight!(
+ Rows::single(0).and(Rows::single(3)),
+ static_table!(
+ "*++++++++++++++++++++++++++++++++++++#"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "@++++++++++++++++++++++++++++++++++++."
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "*++++++++++++++++++++++++++++++++++++#"
+ "+ 2 │ 2-0 │ 2-1 │ 2-2 +"
+ "@++++++++++++++++++++++++++++++++++++."
+ ),
+ );
+
+ test_highlight!(
+ Columns::single(0).and(Columns::single(3)),
+ static_table!(
+ "*+++#──────────┬──────────*++++++++++#"
+ "+ N + column 0 │ column 1 + column 2 +"
+ "+───+──────────┼──────────+──────────+"
+ "+ 0 + 0-0 │ 0-1 + 0-2 +"
+ "+───+──────────┼──────────+──────────+"
+ "+ 1 + 1-0 │ 1-1 + 1-2 +"
+ "+───+──────────┼──────────+──────────+"
+ "+ 2 + 2-0 │ 2-1 + 2-2 +"
+ "@+++.──────────┴──────────@++++++++++."
+ ),
+ );
+
+ test_highlight!(
+ Segment::all().not(Cell::new(3, 1).and(Cell::new(3, 2))),
+ static_table!(
+ "*++++++++++++++++++++++++++++++++++++#"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 0 │ 0-0 │ 0-1 │ 0-2 +"
+ "+───┼──────────┼──────────┼──────────+"
+ "+ 1 │ 1-0 │ 1-1 │ 1-2 +"
+ "+───*+++++++++++++++++++++#──────────+"
+ "+ 2 + 2-0 │ 2-1 + 2-2 +"
+ "@+++.──────────┴──────────@++++++++++."
+ ),
+ );
+
+ test_highlight!(
+ Rows::single(0)
+ .and(Cell::new(1, 1).and(Cell::new(1, 2)))
+ .and(Cell::new(2, 3)),
+ static_table!(
+ "*++++++++++++++++++++++++++++++++++++#"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "@+++#──────────┼──────────*++++++++++."
+ "│ 0 + 0-0 │ 0-1 + 0-2 │"
+ "├───@+++++++++++++++++++++*++++++++++#"
+ "│ 1 │ 1-0 │ 1-1 + 1-2 +"
+ "├───┼──────────┼──────────@++++++++++."
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└───┴──────────┴──────────┴──────────┘"
+ ),
+ );
+
+ test_highlight!(
+ Segment::all()
+ .not(Segment::new(2.., 0..3))
+ .not(Cell::new(1, 0)),
+ static_table!(
+ "*++++++++++++++++++++++++++++++++++++#"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "@+++#──────────┼──────────┼──────────+"
+ "│ 0 + 0-0 │ 0-1 │ 0-2 +"
+ "├───@+++++++++++++++++++++#──────────+"
+ "│ 1 │ 1-0 │ 1-1 + 1-2 +"
+ "├───┼──────────┼──────────+──────────+"
+ "│ 2 │ 2-0 │ 2-1 + 2-2 +"
+ "└───┴──────────┴──────────@++++++++++."
+ ),
+ );
+
+ test_highlight!(
+ Segment::all()
+ .not(Segment::new(..1, 1..))
+ .not(Segment::new(1..2, 2..))
+ .not(Cell::new(2, 3)),
+ static_table!(
+ "*+++#──────────┬──────────┬──────────┐"
+ "+ N + column 0 │ column 1 │ column 2 │"
+ "+───@++++++++++#──────────┼──────────┤"
+ "+ 0 │ 0-0 + 0-1 │ 0-2 │"
+ "+───┼──────────@++++++++++#──────────┤"
+ "+ 1 │ 1-0 │ 1-1 + 1-2 │"
+ "+───┼──────────┼──────────@++++++++++#"
+ "+ 2 │ 2-0 │ 2-1 │ 2-2 +"
+ "@++++++++++++++++++++++++++++++++++++."
+ ),
+ );
+}
diff --git a/vendor/tabled/tests/settings/margin_test.rs b/vendor/tabled/tests/settings/margin_test.rs
new file mode 100644
index 000000000..513287350
--- /dev/null
+++ b/vendor/tabled/tests/settings/margin_test.rs
@@ -0,0 +1,195 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{object::Cell, Border, Highlight, Margin, Modify, Span, Style, Width};
+
+use crate::matrix::Matrix;
+use testing_table::{is_lines_equal, static_table, test_table};
+
+#[cfg(feature = "color")]
+use ::{owo_colors::OwoColorize, std::convert::TryFrom, tabled::settings::Color};
+
+test_table!(
+ margin_with_table_based_on_grid_borders,
+ Matrix::new(3, 3)
+ .with(Style::extended())
+ .with(Highlight::new(Cell::new(0, 0), Border::filled('+')))
+ .with(Highlight::new(Cell::new(1, 1), Border::filled('*')))
+ .with(Margin::new(1, 2, 1, 2).fill('>', '<', 'V', '^')),
+ "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"
+ ">+++++══════════╦══════════╦══════════╗<<"
+ ">+ N + column 0 ║ column 1 ║ column 2 ║<<"
+ ">++++************══════════╬══════════╣<<"
+ ">║ 0 * 0-0 * 0-1 ║ 0-2 ║<<"
+ ">╠═══************══════════╬══════════╣<<"
+ ">║ 1 ║ 1-0 ║ 1-1 ║ 1-2 ║<<"
+ ">╠═══╬══════════╬══════════╬══════════╣<<"
+ ">║ 2 ║ 2-0 ║ 2-1 ║ 2-2 ║<<"
+ ">╚═══╩══════════╩══════════╩══════════╝<<"
+ "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
+ "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
+);
+
+test_table!(
+ margin_without_table_based_on_grid_borders,
+ Matrix::new(3, 3)
+ .insert((3, 2), "https://\nwww\n.\nredhat\n.com\n/en")
+ .with(Style::psql())
+ .with(Modify::new(Cell::new(3, 2)).with(Span::column(2)))
+ .with(Margin::new(1, 1, 1, 1).fill('>', '<', 'V', '^')),
+ "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"
+ "> N | column 0 | column 1 | column 2 <"
+ ">---+----------+----------+----------<"
+ "> 0 | 0-0 | 0-1 | 0-2 <"
+ "> 1 | 1-0 | 1-1 | 1-2 <"
+ "> 2 | 2-0 | https:// <"
+ "> | | www <"
+ "> | | . <"
+ "> | | redhat <"
+ "> | | .com <"
+ "> | | /en <"
+ "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
+);
+
+test_table!(
+ table_with_empty_margin,
+ Matrix::new(3, 3)
+ .insert((3, 2), "https://\nwww\n.\nredhat\n.com\n/en")
+ .with(Style::psql())
+ .with(Modify::new(Cell::new(3, 2)).with(Span::column(2)))
+ .with(Margin::new(0, 0, 0, 0).fill('>', '<', 'V', '^')),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | https:// "
+ " | | www "
+ " | | . "
+ " | | redhat "
+ " | | .com "
+ " | | /en "
+);
+
+#[test]
+fn table_with_margin_and_min_width() {
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Cell::new(1, 1)).with(Span::column(2)))
+ .with(Margin::new(1, 1, 1, 1).fill('>', '<', 'V', '^'))
+ .with(Width::truncate(20))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "VVVVVVVVVVVVVVVVVVVV"
+ "> | co | co | col <"
+ ">--+----+----+-----<"
+ "> | 0-0 | 0-2 <"
+ "> | 1- | 1- | 1-2 <"
+ "> | 2- | 2- | 2-2 <"
+ "^^^^^^^^^^^^^^^^^^^^"
+ )
+ );
+ assert!(is_lines_equal(&table, 20));
+}
+
+#[test]
+fn table_with_margin_and_max_width() {
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Cell::new(1, 1)).with(Span::column(2)))
+ .with(Margin::new(1, 1, 1, 1).fill('>', '<', 'V', '^'))
+ .with(Width::increase(50))
+ .to_string();
+
+ assert_eq!(papergrid::util::string::string_width_multiline(&table), 50);
+ assert_eq!(
+ table,
+ static_table!(
+ "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"
+ "> N | column 0 | column 1 | column 2 <"
+ ">------+-------------+-------------+-------------<"
+ "> 0 | 0-0 | 0-2 <"
+ "> 1 | 1-0 | 1-1 | 1-2 <"
+ "> 2 | 2-0 | 2-1 | 2-2 <"
+ "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
+ )
+ );
+}
+
+#[test]
+#[ignore = "It's not yet clear what to do with such spans"]
+fn table_0_spanned_with_width() {
+ let table = Matrix::table(0, 0)
+ .with(Modify::new(Cell::new(0, 0)).with(Span::column(0)))
+ .with(Width::increase(50))
+ .to_string();
+
+ assert_eq!(table, "++\n|\n++\n");
+
+ let table = Matrix::table(0, 0)
+ .with(Modify::new(Cell::new(0, 0)).with(Span::column(0)))
+ .with(Width::truncate(50))
+ .to_string();
+
+ assert_eq!(table, "++\n|\n++\n");
+}
+
+#[test]
+fn margin_color_test_not_colored_feature() {
+ use tabled::settings::Color;
+
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Margin::new(2, 2, 2, 2).fill('>', '<', 'V', '^').colorize(
+ Color::BG_GREEN,
+ Color::BG_YELLOW,
+ Color::BG_RED,
+ Color::BG_BLUE,
+ ))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "\u{1b}[41mVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\u{1b}[49m"
+ "\u{1b}[41mVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\u{1b}[49m"
+ "\u{1b}[42m>>\u{1b}[49m N | column 0 | column 1 | column 2 \u{1b}[43m<<\u{1b}[49m"
+ "\u{1b}[42m>>\u{1b}[49m---+----------+----------+----------\u{1b}[43m<<\u{1b}[49m"
+ "\u{1b}[42m>>\u{1b}[49m 0 | 0-0 | 0-1 | 0-2 \u{1b}[43m<<\u{1b}[49m"
+ "\u{1b}[42m>>\u{1b}[49m 1 | 1-0 | 1-1 | 1-2 \u{1b}[43m<<\u{1b}[49m"
+ "\u{1b}[42m>>\u{1b}[49m 2 | 2-0 | 2-1 | 2-2 \u{1b}[43m<<\u{1b}[49m"
+ "\u{1b}[44m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u{1b}[49m"
+ "\u{1b}[44m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u{1b}[49m"
+ )
+ );
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn margin_color_test() {
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Margin::new(2, 2, 2, 2).fill('>', '<', 'V', '^').colorize(
+ Color::try_from(" ".red().bold().to_string()).unwrap(),
+ Color::try_from(" ".green().to_string()).unwrap(),
+ Color::try_from(" ".on_blue().red().bold().to_string()).unwrap(),
+ Color::try_from(" ".on_yellow().blue().to_string()).unwrap(),
+ ))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "\u{1b}[1m\u{1b}[31m\u{1b}[44mVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\u{1b}[22m\u{1b}[39m\u{1b}[49m"
+ "\u{1b}[1m\u{1b}[31m\u{1b}[44mVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\u{1b}[22m\u{1b}[39m\u{1b}[49m"
+ "\u{1b}[1m\u{1b}[31m>>\u{1b}[22m\u{1b}[39m N | column 0 | column 1 | column 2 \u{1b}[32m<<\u{1b}[39m"
+ "\u{1b}[1m\u{1b}[31m>>\u{1b}[22m\u{1b}[39m---+----------+----------+----------\u{1b}[32m<<\u{1b}[39m"
+ "\u{1b}[1m\u{1b}[31m>>\u{1b}[22m\u{1b}[39m 0 | 0-0 | 0-1 | 0-2 \u{1b}[32m<<\u{1b}[39m"
+ "\u{1b}[1m\u{1b}[31m>>\u{1b}[22m\u{1b}[39m 1 | 1-0 | 1-1 | 1-2 \u{1b}[32m<<\u{1b}[39m"
+ "\u{1b}[1m\u{1b}[31m>>\u{1b}[22m\u{1b}[39m 2 | 2-0 | 2-1 | 2-2 \u{1b}[32m<<\u{1b}[39m"
+ "\u{1b}[34m\u{1b}[43m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u{1b}[39m\u{1b}[49m"
+ "\u{1b}[34m\u{1b}[43m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u{1b}[39m\u{1b}[49m"
+ )
+ );
+}
diff --git a/vendor/tabled/tests/settings/merge_test.rs b/vendor/tabled/tests/settings/merge_test.rs
new file mode 100644
index 000000000..cbc119aa9
--- /dev/null
+++ b/vendor/tabled/tests/settings/merge_test.rs
@@ -0,0 +1,196 @@
+#![cfg(feature = "std")]
+
+use tabled::{settings::merge::Merge, Table};
+
+use testing_table::test_table;
+
+test_table!(
+ merge_horizontal,
+ Table::new([[0, 1, 1], [1, 1, 2], [1, 1, 1]]).with(Merge::horizontal()),
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+---+---+---+"
+ "| 0 | 1 |"
+ "+---+---+---+"
+ "| 1 | 2 |"
+ "+---+---+---+"
+ "| 1 |"
+ "+---+---+---+"
+);
+
+test_table!(
+ merge_horizontal_with_no_duplicates,
+ Table::new([[0, 1, 2], [0, 1, 2], [0, 1, 2]]).with(Merge::horizontal()),
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+---+---+---+"
+);
+
+test_table!(
+ merge_horizontal_empty,
+ Table::new([[0usize; 0]]).with(Merge::horizontal()),
+ ""
+);
+
+test_table!(
+ merge_vertical_0,
+ Table::new([[0, 3, 5], [0, 3, 3], [0, 2, 3]]).with(Merge::vertical()),
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+ +---+---+"
+ "| | 3 | 5 |"
+ "+ + +---+"
+ "+ +---+ 3 +"
+ "| | 2 | |"
+ "+---+---+---+"
+);
+
+test_table!(
+ merge_vertical_1,
+ Table::new([[0, 3, 2], [0, 3, 3], [0, 2, 3]]).with(Merge::vertical()),
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+ +---+ +"
+ "+ + 3 +---+"
+ "+ +---+ 3 +"
+ "| | 2 | |"
+ "+---+---+---+"
+);
+
+test_table!(
+ merge_vertical_with_no_duplicates,
+ Table::new([[5; 3], [15; 3], [115; 3]]).with(Merge::vertical()),
+ "+-----+-----+-----+"
+ "| 0 | 1 | 2 |"
+ "+-----+-----+-----+"
+ "| 5 | 5 | 5 |"
+ "+-----+-----+-----+"
+ "| 15 | 15 | 15 |"
+ "+-----+-----+-----+"
+ "| 115 | 115 | 115 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ merge_vertical_empty,
+ Table::new([[0usize; 0]]).with(Merge::vertical()),
+ ""
+);
+
+test_table!(
+ merge_horizontal_and_vertical_0,
+ Table::new([[3, 3, 5], [3, 7, 8], [9, 10, 11]]).with(Merge::horizontal()).with(Merge::vertical()),
+ "+---+----+----+"
+ "| 0 | 1 | 2 |"
+ "+---+----+----+"
+ "| 3 | 5 |"
+ "+---+----+----+"
+ "| 3 | 7 | 8 |"
+ "+---+----+----+"
+ "| 9 | 10 | 11 |"
+ "+---+----+----+"
+);
+
+test_table!(
+ merge_horizontal_and_vertical_1,
+ Table::new([[0, 1, 1], [1, 1, 2], [1, 1, 1]]).with(Merge::horizontal()).with(Merge::vertical()),
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+ +---+---+"
+ "| | 1 |"
+ "+---+---+---+"
+ "| 1 | 2 |"
+ "+---+---+---+"
+ "| 1 |"
+ "+---+---+---+"
+);
+
+test_table!(
+ merge_horizontal_and_vertical_2,
+ Table::new([[3, 4, 5], [3, 3, 8], [3, 10, 11]]).with(Merge::horizontal()).with(Merge::vertical()),
+ "+---+----+----+"
+ "| 0 | 1 | 2 |"
+ "+---+----+----+"
+ "| 3 | 4 | 5 |"
+ "+---+----+----+"
+ "| 3 | 8 |"
+ "+---+----+----+"
+ "| 3 | 10 | 11 |"
+ "+---+----+----+"
+);
+
+test_table!(
+ merge_horizontal_and_vertical_3,
+ Table::new([[3, 4, 5], [3, 3, 8], [3, 10, 11]]).with(Merge::vertical()).with(Merge::horizontal()),
+ "+---+----+----+"
+ "| 0 | 1 | 2 |"
+ "+---+----+----+"
+ "| 3 | 4 | 5 |"
+ "+ +----+----+"
+ "| | 3 | 8 |"
+ "+ +----+----+"
+ "| | 10 | 11 |"
+ "+---+----+----+"
+);
+
+test_table!(
+ merge_horizontal_and_vertical_4,
+ Table::new([[3, 4, 5], [4, 4, 8], [3, 4, 11]]).with(Merge::vertical()).with(Merge::horizontal()),
+ "+---+---+----+"
+ "| 0 | 1 | 2 |"
+ "+---+---+----+"
+ "| 3 | 4 | 5 |"
+ "+---+ +----+"
+ "| 4 | | 8 |"
+ "+---+ +----+"
+ "| 3 | | 11 |"
+ "+---+---+----+"
+);
+
+test_table!(
+ merge_horizontal_and_vertical_5,
+ Table::new([[3, 4, 4], [4, 4, 8], [3, 4, 11]]).with(Merge::vertical()).with(Merge::horizontal()),
+ "+---+---+----+"
+ "| 0 | 1 | 2 |"
+ "+---+---+----+"
+ "| 3 | 4 | 4 |"
+ "+---+ +----+"
+ "| 4 | | 8 |"
+ "+---+ +----+"
+ "| 3 | | 11 |"
+ "+---+---+----+"
+);
+
+test_table!(
+ merge_horizontal_and_vertical_6,
+ Table::new([[4, 4, 4], [5, 4, 8], [3, 4, 11]]).with(Merge::vertical()).with(Merge::horizontal()),
+ "+---+---+----+"
+ "| 0 | 1 | 2 |"
+ "+---+---+----+"
+ "| 4 | 4 | 4 |"
+ "+---+ +----+"
+ "| 5 | | 8 |"
+ "+---+ +----+"
+ "| 3 | | 11 |"
+ "+---+---+----+"
+);
+
+test_table!(
+ merge_horizontal_and_vertical_7,
+ Table::new([[0, 0, 0], [0, 0, 1], [2, 0, 0]]).with(Merge::horizontal()).with(Merge::vertical()),
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+---+---+---+"
+ "| 0 |"
+ "+---+---+---+"
+ "| 0 | 1 |"
+ "+---+---+---+"
+ "| 2 | 0 |"
+ "+---+---+---+"
+);
diff --git a/vendor/tabled/tests/settings/mod.rs b/vendor/tabled/tests/settings/mod.rs
new file mode 100644
index 000000000..da76a5e14
--- /dev/null
+++ b/vendor/tabled/tests/settings/mod.rs
@@ -0,0 +1,23 @@
+mod alignment_test;
+mod color_test;
+mod colorization;
+mod column_names_test;
+mod concat_test;
+mod disable_test;
+mod duplicate_test;
+mod extract_test;
+mod format_test;
+mod formatting_test;
+mod height_test;
+mod highlingt_test;
+mod margin_test;
+mod merge_test;
+mod padding_test;
+mod panel_test;
+mod render_settings;
+mod rotate_test;
+mod shadow_test;
+mod span_test;
+mod split_test;
+mod style_test;
+mod width_test;
diff --git a/vendor/tabled/tests/settings/padding_test.rs b/vendor/tabled/tests/settings/padding_test.rs
new file mode 100644
index 000000000..9a3edb4aa
--- /dev/null
+++ b/vendor/tabled/tests/settings/padding_test.rs
@@ -0,0 +1,138 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{
+ object::{Rows, Segment},
+ Alignment, Modify, Padding, Style,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+#[cfg(feature = "color")]
+use ::{owo_colors::OwoColorize, std::convert::TryFrom, tabled::settings::Color};
+
+test_table!(
+ padding,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Rows::new(1..)).with(Padding::new(1, 1, 0, 2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " | | | "
+ " | | | "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " | | | "
+ " | | | "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ " | | | "
+ " | | | "
+);
+
+test_table!(
+ padding_with_set_characters,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Padding::new(1, 2, 1, 1).fill('>', '<', 'V', '^'))),
+ "VVVV|VVVVVVVVVVV|VVVVVVVVVVV|VVVVVVVVVVV"
+ ">N<<|>column 0<<|>column 1<<|>column 2<<"
+ "^^^^|^^^^^^^^^^^|^^^^^^^^^^^|^^^^^^^^^^^"
+ "----+-----------+-----------+-----------"
+ "VVVV|VVVVVVVVVVV|VVVVVVVVVVV|VVVVVVVVVVV"
+ ">0<<|> 0-0 <<|> 0-1 <<|> 0-2 <<"
+ "^^^^|^^^^^^^^^^^|^^^^^^^^^^^|^^^^^^^^^^^"
+ "VVVV|VVVVVVVVVVV|VVVVVVVVVVV|VVVVVVVVVVV"
+ ">1<<|> 1-0 <<|> 1-1 <<|> 1-2 <<"
+ "^^^^|^^^^^^^^^^^|^^^^^^^^^^^|^^^^^^^^^^^"
+ "VVVV|VVVVVVVVVVV|VVVVVVVVVVV|VVVVVVVVVVV"
+ ">2<<|> 2-0 <<|> 2-1 <<|> 2-2 <<"
+ "^^^^|^^^^^^^^^^^|^^^^^^^^^^^|^^^^^^^^^^^"
+);
+
+test_table!(
+ padding_with_set_characters_and_zero_ident,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Padding::zero().fill('>', '<', '^', 'V'))),
+ "N|column 0|column 1|column 2"
+ "-+--------+--------+--------"
+ "0| 0-0 | 0-1 | 0-2 "
+ "1| 1-0 | 1-1 | 1-2 "
+ "2| 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ padding_multiline,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Rows::new(1..)).with(Padding::new(1, 1, 1, 1))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " | | | "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " | | | "
+ " | | | "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " | | | "
+ " | | | "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ " | | | "
+);
+
+test_table!(
+ padding_multiline_with_vertical_alignment,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::center()).with(Alignment::center_vertical()))
+ .with(Modify::new(Rows::new(1..)).with(Padding::new(1, 1, 1, 1))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " | | | "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " | | | "
+ " | | | "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " | | | "
+ " | | | "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ " | | | "
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ padding_color,
+ {
+ let padding = Padding::new(2, 2, 2, 2).colorize(
+ Color::try_from(' '.on_yellow().to_string()).unwrap(),
+ Color::try_from(' '.on_blue().to_string()).unwrap(),
+ Color::try_from(' '.on_red().to_string()).unwrap(),
+ Color::try_from(' '.on_green().to_string()).unwrap(),
+ );
+
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Rows::new(1..)).with(padding))
+ },
+ " N | column 0 | column 1 | column 2 \n-----+----------+----------+----------\n\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\n\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\n\u{1b}[43m \u{1b}[49m0\u{1b}[44m \u{1b}[49m|\u{1b}[43m \u{1b}[49m 0-0 \u{1b}[44m \u{1b}[49m|\u{1b}[43m \u{1b}[49m 0-1 \u{1b}[44m \u{1b}[49m|\u{1b}[43m \u{1b}[49m 0-2 \u{1b}[44m \u{1b}[49m\n\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m\n\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m\n\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\n\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\n\u{1b}[43m \u{1b}[49m1\u{1b}[44m \u{1b}[49m|\u{1b}[43m \u{1b}[49m 1-0 \u{1b}[44m \u{1b}[49m|\u{1b}[43m \u{1b}[49m 1-1 \u{1b}[44m \u{1b}[49m|\u{1b}[43m \u{1b}[49m 1-2 \u{1b}[44m \u{1b}[49m\n\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m\n\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m\n\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\n\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m|\u{1b}[41m \u{1b}[49m\n\u{1b}[43m \u{1b}[49m2\u{1b}[44m \u{1b}[49m|\u{1b}[43m \u{1b}[49m 2-0 \u{1b}[44m \u{1b}[49m|\u{1b}[43m \u{1b}[49m 2-1 \u{1b}[44m \u{1b}[49m|\u{1b}[43m \u{1b}[49m 2-2 \u{1b}[44m \u{1b}[49m\n\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m\n\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m|\u{1b}[42m \u{1b}[49m"
+);
+
+test_table!(
+ padding_table,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Padding::new(1, 1, 0, 2)),
+ " N | column 0 | column 1 | column 2 "
+ " | | | "
+ " | | | "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " | | | "
+ " | | | "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " | | | "
+ " | | | "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ " | | | "
+ " | | | "
+);
diff --git a/vendor/tabled/tests/settings/panel_test.rs b/vendor/tabled/tests/settings/panel_test.rs
new file mode 100644
index 000000000..613fe1d0e
--- /dev/null
+++ b/vendor/tabled/tests/settings/panel_test.rs
@@ -0,0 +1,337 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{
+ object::{Cell, Object, Rows, Segment},
+ style::{BorderSpanCorrection, HorizontalLine},
+ Alignment, Border, Highlight, Modify, Panel, Span, Style, Width,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+test_table!(
+ panel_has_no_style_by_default,
+ Matrix::new(3, 3).with(Style::psql()).with(Panel::horizontal(0,"Linux Distributions")),
+ " Linux Distributions "
+ "---+----------+----------+----------"
+ " N | column 0 | column 1 | column 2 "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ highlight_panel_0,
+ Matrix::new(3, 3)
+ .with(Panel::horizontal(0,"Linux Distributions"))
+ .with(Style::psql())
+ .with(Highlight::new(Cell::new(0, 0), Border::filled('#'))),
+ "##### "
+ "# Linux Distributions "
+ "#####----------+----------+----------"
+ " N | column 0 | column 1 | column 2 "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ highlight_panel_1,
+ Matrix::new(3, 3)
+ .with(Panel::horizontal(0,"Linux Distributions"))
+ .with(Style::psql())
+ .with(Highlight::new(Cell::new(0, 0), Border::filled('#')))
+ .with(Highlight::new(Cell::new(0, 1), Border::filled('#')))
+ .with(Highlight::new(Cell::new(0, 2), Border::filled('#')))
+ .with(Highlight::new(Cell::new(0, 3), Border::filled('#'))),
+ "######################################"
+ "# Linux Distributions #"
+ "######################################"
+ " N | column 0 | column 1 | column 2 "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ top_panel,
+ Matrix::new(3, 3)
+ .with(Panel::horizontal(0,"Linux Distributions"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::psql()),
+ " Linux Distributions "
+ "---+----------+----------+----------"
+ " N | column 0 | column 1 | column 2 "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ bottom_panel,
+ Matrix::new(3, 3)
+ .with(Panel::horizontal(4,"Linux Distributions"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::psql()),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ " Linux Distributions "
+);
+
+test_table!(
+ inner_panel,
+ Matrix::new(3, 3)
+ .with(Panel::horizontal(2,"Linux Distributions"))
+ .with(Modify::new(Rows::new(2..)).with(Alignment::center()))
+ .with(Style::psql()),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " Linux Distributions "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ header,
+ Matrix::new(3, 3)
+ .with(Panel::header("Linux Distributions"))
+ .with(Style::psql())
+ .with(Modify::new(Rows::new(0..1)).with(Alignment::center())),
+ " Linux Distributions "
+ "---+----------+----------+----------"
+ " N | column 0 | column 1 | column 2 "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ footer,
+ Matrix::new(3, 3)
+ .with(Panel::header("Linux Distributions"))
+ .with(Panel::footer("The end"))
+ .with(Style::psql())
+ .with(Modify::new(Rows::first().and(Rows::last())).with(Alignment::center())),
+ " Linux Distributions "
+ "---+----------+----------+----------"
+ " N | column 0 | column 1 | column 2 "
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ " The end "
+);
+
+test_table!(
+ panel_style_uses_most_left_and_right_cell_styles,
+ Matrix::iter([(0, 1)]).with(Panel::horizontal(0,"Numbers")).with(Style::modern()),
+ "┌─────┬─────┐"
+ "│ Numbers │"
+ "├─────┼─────┤"
+ "│ i32 │ i32 │"
+ "├─────┼─────┤"
+ "│ 0 │ 1 │"
+ "└─────┴─────┘"
+);
+
+test_table!(
+ panel_style_change,
+ Matrix::iter([(0, 1)])
+ .with(Panel::horizontal(0,"Numbers"))
+ .with(Style::modern().intersection_top('─').horizontals([HorizontalLine::new(1, Style::modern().get_horizontal()).intersection(Some('┬'))]))
+ .with(Modify::new(Cell::new(0, 0)).with(Alignment::center())),
+ "┌───────────┐"
+ "│ Numbers │"
+ "├─────┬─────┤"
+ "│ i32 │ i32 │"
+ "├─────┼─────┤"
+ "│ 0 │ 1 │"
+ "└─────┴─────┘"
+);
+
+test_table!(
+ panel_style_uses_most_left_and_right_cell_styles_correct,
+ Matrix::iter([(0, 1)])
+ .with(Panel::horizontal(0,"Numbers"))
+ .with(Style::modern())
+ .with(BorderSpanCorrection),
+ "┌───────────┐"
+ "│ Numbers │"
+ "├─────┬─────┤"
+ "│ i32 │ i32 │"
+ "├─────┼─────┤"
+ "│ 0 │ 1 │"
+ "└─────┴─────┘"
+);
+
+test_table!(
+ panel_style_change_correct,
+ Matrix::iter([(0, 1)])
+ .with(Panel::horizontal(0,"Numbers"))
+ .with(Style::modern().intersection_top('─').horizontals([HorizontalLine::new(1, Style::modern().get_horizontal()).intersection(Some('┬'))]))
+ .with(BorderSpanCorrection)
+ .with(Modify::new(Cell::new(0, 0)).with(Alignment::center())),
+ "┌───────────┐"
+ "│ Numbers │"
+ "├───────────┤" // it's different because we use a top_intersection char by default when making style for `Panel`s.
+ "│ i32 │ i32 │"
+ "├─────┼─────┤"
+ "│ 0 │ 1 │"
+ "└─────┴─────┘"
+);
+
+test_table!(
+ panel_in_single_column,
+ #[allow(clippy::needless_borrow)]
+ Matrix::iter(&[(0)]).with(Panel::horizontal(0,"Numbers")).with(Style::modern()),
+ "┌─────────┐"
+ "│ Numbers │"
+ "├─────────┤"
+ "│ i32 │"
+ "├─────────┤"
+ "│ 0 │"
+ "└─────────┘"
+);
+
+test_table!(
+ panel_vertical_0,
+ Matrix::new(3, 3).with(Style::psql()).with(Panel::vertical(0,"Linux Distributions")),
+ " Linux Distributions | N | column 0 | column 1 | column 2 "
+ " +---+----------+----------+----------"
+ " | 0 | 0-0 | 0-1 | 0-2 "
+ " | 1 | 1-0 | 1-1 | 1-2 "
+ " | 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ panel_vertical_1,
+ Matrix::new(3, 3).with(Style::psql()).with(Panel::vertical(1,"Linux Distributions")),
+ " N | Linux Distributions | column 0 | column 1 | column 2 "
+ "---+ +----------+----------+----------"
+ " 0 | | 0-0 | 0-1 | 0-2 "
+ " 1 | | 1-0 | 1-1 | 1-2 "
+ " 2 | | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ panel_vertical_2,
+ Matrix::new(3, 3).with(Style::psql()).with(Panel::vertical(4,"Linux Distributions")),
+ " N | column 0 | column 1 | column 2 | Linux Distributions "
+ "---+----------+----------+----------+ "
+ " 0 | 0-0 | 0-1 | 0-2 | "
+ " 1 | 1-0 | 1-1 | 1-2 | "
+ " 2 | 2-0 | 2-1 | 2-2 | "
+);
+
+test_table!(
+ panel_vertical_0_wrap,
+ Matrix::new(3, 3).with(Style::psql()).with(Panel::vertical(0,"Linux Distributions")).with(Modify::new(Cell::new(0, 0)).with(Width::wrap(3))),
+ " Lin | N | column 0 | column 1 | column 2 "
+ " ux | | | | "
+ " Dis | | | | "
+ " tri +---+----------+----------+----------"
+ " but | 0 | 0-0 | 0-1 | 0-2 "
+ " ion | 1 | 1-0 | 1-1 | 1-2 "
+ " s | 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ panel_vertical_0_wrap_0,
+ Matrix::new(3, 3).with(Style::psql()).with(Panel::vertical(0,"Linux Distributions")).with(Modify::new(Cell::new(0, 0)).with(Width::wrap(0))),
+ " | N | column 0 | column 1 | column 2 "
+ " +---+----------+----------+----------"
+ " | 0 | 0-0 | 0-1 | 0-2 "
+ " | 1 | 1-0 | 1-1 | 1-2 "
+ " | 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ panel_vertical_0_wrap_100,
+ Matrix::new(3, 3).with(Style::psql()).with(Panel::vertical(0,"Linux Distributions")).with(Modify::new(Cell::new(0, 0)).with(Width::wrap(100))),
+ " Linux Distributions | N | column 0 | column 1 | column 2 "
+ " +---+----------+----------+----------"
+ " | 0 | 0-0 | 0-1 | 0-2 "
+ " | 1 | 1-0 | 1-1 | 1-2 "
+ " | 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ panel_horizontal_set_0,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Panel::horizontal(0,"Linux Distributions"))
+ .with(Panel::vertical(0,"asd")),
+ " asd | Linux Distributions "
+ " +---+----------+----------+----------"
+ " | N | column 0 | column 1 | column 2 "
+ " | 0 | 0-0 | 0-1 | 0-2 "
+ " | 1 | 1-0 | 1-1 | 1-2 "
+ " | 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ panel_horizontal_set_1,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Panel::horizontal(0,"Linux Distributions"))
+ .with(Panel::vertical(0,"asd"))
+ .with(Panel::vertical(5,"asd"))
+ ,
+ " asd | Linux Distributions | asd "
+ " +---+----------+----------+----------+ "
+ " | N | column 0 | column 1 | column 2 | "
+ " | 0 | 0-0 | 0-1 | 0-2 | "
+ " | 1 | 1-0 | 1-1 | 1-2 | "
+ " | 2 | 2-0 | 2-1 | 2-2 | "
+);
+
+test_table!(
+ ignore_col_span_intersect_with_other_span,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Panel::horizontal(0,"Linux Distributions"))
+ .with(Panel::vertical(0,"asd"))
+ .with(Panel::vertical(5,"zxc"))
+ .with(Modify::new((1, 3)).with(Span::column(3)).with("wwwww")),
+ " asd | Linux Distributions | zxc "
+ " +---+----------+-------+----------+ "
+ " | N | column 0 | wwwww | column 2 | "
+ " | 0 | 0-0 | 0-1 | 0-2 | "
+ " | 1 | 1-0 | 1-1 | 1-2 | "
+ " | 2 | 2-0 | 2-1 | 2-2 | "
+);
+
+test_table!(
+ panel_horizontal_x_2,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Panel::horizontal(0,"Linux Distributions"))
+ .with(Panel::vertical(0,"asd"))
+ .with(Panel::vertical(5,"zxc"))
+ .with(Modify::new((1, 3)).with(Span::column(2)).with("wwwww")),
+ " asd | Linux Distributions | zxc "
+ " +---+----------+-----+-----+ "
+ " | N | column 0 | wwwww | "
+ " | 0 | 0-0 | 0-1 | 0-2 | "
+ " | 1 | 1-0 | 1-1 | 1-2 | "
+ " | 2 | 2-0 | 2-1 | 2-2 | "
+);
+
+test_table!(
+ ignore_row_span_intersect_with_other_span,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Panel::horizontal(2,"Linux Distributions"))
+ .with(Panel::vertical(0,"asd"))
+ .with(Panel::vertical(5,"zxc"))
+ .with(Modify::new((0, 3)).with(Span::row(4)).with("xxxxx")),
+ " asd | N | column 0 | xxxxx | column 2 | zxc "
+ " +---+----------+-------+----------+ "
+ " | 0 | 0-0 | 0-1 | 0-2 | "
+ " | Linux Distributions | "
+ " | 1 | 1-0 | 1-1 | 1-2 | "
+ " | 2 | 2-0 | 2-1 | 2-2 | "
+);
diff --git a/vendor/tabled/tests/settings/render_settings.rs b/vendor/tabled/tests/settings/render_settings.rs
new file mode 100644
index 000000000..f25a59a67
--- /dev/null
+++ b/vendor/tabled/tests/settings/render_settings.rs
@@ -0,0 +1,292 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{
+ formatting::{AlignmentStrategy, TabSize, TrimStrategy},
+ object::Segment,
+ Alignment, Modify, Span, Style,
+};
+
+use crate::matrix::{Matrix, MatrixList};
+use testing_table::test_table;
+
+#[cfg(feature = "color")]
+use owo_colors::OwoColorize;
+
+test_table!(
+ alignment_per_line,
+ Matrix::iter(multiline_data1())
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::right()).with(AlignmentStrategy::PerLine)),
+ " N | column 0 | column 1 | column 2 "
+ "-----------+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " asd | 1-0 | 1-1 | 1-2 "
+ " 21213123 | | | "
+ " | | | "
+ " asdasd | | | "
+ " | | | "
+ " | | | "
+ " 2 | 2-0 | https:// | 2-2 "
+ " | | www | "
+ " | | . | "
+ " | | redhat | "
+ " | | .com | "
+ " | | /en | "
+);
+
+test_table!(
+ alignment_per_line_with_trim_0,
+ Matrix::iter(multiline_data1())
+ .with(Style::psql())
+ .with(Alignment::right())
+ .with(AlignmentStrategy::PerLine)
+ .with(TrimStrategy::Horizontal),
+ " N | column 0 | column 1 | column 2 "
+ "-----------+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " asd | 1-0 | 1-1 | 1-2 "
+ " 21213123 | | | "
+ " | | | "
+ " asdasd | | | "
+ " | | | "
+ " | | | "
+ " 2 | 2-0 | https:// | 2-2 "
+ " | | www | "
+ " | | . | "
+ " | | redhat | "
+ " | | .com | "
+ " | | /en | "
+);
+
+test_table!(
+ alignment_per_line_with_trim_1,
+ Matrix::iter(multiline_data2())
+ .with(Style::psql())
+ .with(Modify::new(Segment::all())
+ .with(Alignment::center_vertical())
+ .with(Alignment::left())
+ .with(AlignmentStrategy::PerLine)
+ .with(TrimStrategy::Both)),
+ " N | column 0 | column 1 | column 2 "
+ "-------------------+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " | | | "
+ " | | | "
+ " | | | "
+ " asd | 1-0 | 1-1 | 1-2 "
+ " 21213123 asdasd | | | "
+ " | | | "
+ " | | | "
+ " | | | "
+ " | | https:// | "
+ " | | www | "
+ " 2 | 2-0 | . | 2-2 "
+ " | | redhat | "
+ " | | .com | "
+ " | | /en | "
+);
+
+test_table!(
+ tab_isnot_handled_by_default_test,
+ Matrix::iter(tab_data1()).with(Style::psql()),
+ " N | column 0 | column 1 | column 2 "
+ "--------------+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 123\t123\tasdasd | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | htt\tps:// | 2-2 "
+ " | | www | "
+ " | | . | "
+ " | | red\that | "
+ " | | .c\tom | "
+ " | | /en | "
+);
+
+test_table!(
+ tab_size_test_0,
+ Matrix::iter(tab_data1()).with(Style::psql()).with(TabSize::new(4)),
+ " N | column 0 | column 1 | column 2 "
+ "----------------------+----------+--------------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 123 123 asdasd | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | htt ps:// | 2-2 "
+ " | | www | "
+ " | | . | "
+ " | | red hat | "
+ " | | .c om | "
+ " | | /en | "
+);
+
+test_table!(
+ tab_size_test_1,
+ Matrix::iter(tab_data1()).with(Style::psql()).with(Modify::new(Segment::all()).with(Alignment::right())).with(TabSize::new(2)),
+ " N | column 0 | column 1 | column 2 "
+ "------------------+----------+------------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 123 123 asdasd | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | htt ps:// | 2-2 "
+ " | | www | "
+ " | | . | "
+ " | | red hat | "
+ " | | .c om | "
+ " | | /en | "
+);
+
+test_table!(
+ tab_size_test_2,
+ Matrix::iter(tab_data1()).with(Style::psql()).with(Modify::new(Segment::all()).with(Alignment::right())).with(TabSize::new(0)),
+ " N | column 0 | column 1 | column 2 "
+ "--------------+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 123123asdasd | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | https:// | 2-2 "
+ " | | www | "
+ " | | . | "
+ " | | redhat | "
+ " | | .com | "
+ " | | /en | "
+);
+
+test_table!(
+ tab_size_span_test,
+ Matrix::iter(tab_data2())
+ .with(TabSize::new(4))
+ .with(Style::psql())
+ .with(Modify::new((0, 0)).with(Span::column(3)))
+ .with(Modify::new((1, 0)).with(Span::column(2)))
+ .with(Modify::new((2, 1)).with(Span::column(2))),
+ " N | column 2 "
+ "----------------------+-----+--------------+----------"
+ " H ello World | 0-1 | 0-2 "
+ " 123 123 asdasd | 1-0 | 1-2 "
+ " 2 | 2-0 | htt ps:// | 2-2 "
+ " | | www | "
+ " | | . | "
+ " | | red hat | "
+ " | | .c om | "
+ " | | /en | "
+);
+
+test_table!(
+ test_top_alignment_and_vertical_trim_1,
+ Matrix::iter(vec![" \n\n\n Hello World"])
+ .with(Style::modern())
+ .with(Modify::new(Segment::all()).with(Alignment::top()).with(TrimStrategy::Vertical)),
+ "┌─────────────────┐"
+ "│ &str │"
+ "├─────────────────┤"
+ "│ Hello World │"
+ "│ │"
+ "│ │"
+ "│ │"
+ "└─────────────────┘"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ trim_colored_string_test_2,
+ Matrix::iter(colored_data())
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::right()).with(TrimStrategy::None)),
+ " N | column 0 | column 1 | column 2 "
+ "-----------+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " \u{1b}[31masd\u{1b}[39m | 1-0 | 1-1 | 1-2 "
+ " \u{1b}[31m21213123\u{1b}[39m | | | "
+ " | | | "
+ " \u{1b}[31m asdasd\u{1b}[39m | | | "
+ " | | | "
+ " \u{1b}[31m\u{1b}[39m | | | "
+ " 2 | 2-0 | \u{1b}[44mhttps://\u{1b}[49m | 2-2 "
+ " | | \u{1b}[44mwww\u{1b}[49m | "
+ " | | \u{1b}[44m.\u{1b}[49m | "
+ " | | \u{1b}[44mredhat\u{1b}[49m | "
+ " | | \u{1b}[44m.com\u{1b}[49m | "
+ " | | \u{1b}[44m/en\u{1b}[49m | "
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ trim_colored_string_test_1,
+ Matrix::iter(colored_data())
+ .with(Style::psql())
+ .with(
+ Modify::new(Segment::all())
+ .with(Alignment::right())
+ .with(TrimStrategy::Horizontal)
+ .with(AlignmentStrategy::PerLine),
+ ),
+ " N | column 0 | column 1 | column 2 "
+ "-----------+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " \u{1b}[31masd\u{1b}[39m | 1-0 | 1-1 | 1-2 "
+ " \u{1b}[31m21213123\u{1b}[39m | | | "
+ " | | | "
+ " \u{1b}[31masdasd\u{1b}[39m | | | "
+ " | | | "
+ " \u{1b}[31m\u{1b}[39m | | | "
+ " 2 | 2-0 | \u{1b}[44mhttps://\u{1b}[49m | 2-2 "
+ " | | \u{1b}[44mwww\u{1b}[49m | "
+ " | | \u{1b}[44m.\u{1b}[49m | "
+ " | | \u{1b}[44mredhat\u{1b}[49m | "
+ " | | \u{1b}[44m.com\u{1b}[49m | "
+ " | | \u{1b}[44m/en\u{1b}[49m | "
+);
+#[cfg(feature = "color")]
+test_table!(
+ trim_colored_string_test_0,
+ Matrix::iter(colored_data())
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::right()).with(TrimStrategy::Horizontal)),
+ " N | column 0 | column 1 | column 2 "
+ "-----------+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " \u{1b}[31masd\u{1b}[39m | 1-0 | 1-1 | 1-2 "
+ " \u{1b}[31m21213123\u{1b}[39m | | | "
+ " | | | "
+ " \u{1b}[31masdasd\u{1b}[39m | | | "
+ " | | | "
+ " \u{1b}[31m\u{1b}[39m | | | "
+ " 2 | 2-0 | \u{1b}[44mhttps://\u{1b}[49m | 2-2 "
+ " | | \u{1b}[44mwww\u{1b}[49m | "
+ " | | \u{1b}[44m.\u{1b}[49m | "
+ " | | \u{1b}[44mredhat\u{1b}[49m | "
+ " | | \u{1b}[44m.com\u{1b}[49m | "
+ " | | \u{1b}[44m/en\u{1b}[49m | "
+);
+
+fn multiline_data1() -> Vec<MatrixList<3, true>> {
+ let mut data = Matrix::list::<3, 3>();
+ data[1][0] = String::from("asd\n21213123\n\n asdasd\n\n");
+ data[2][2] = String::from("https://\nwww\n.\nredhat\n.com\n/en");
+ data
+}
+
+fn multiline_data2() -> Vec<MatrixList<3, true>> {
+ let mut data = Matrix::list::<3, 3>();
+ data[1][0] = String::from("\n\n\nasd\n21213123 asdasd\n\n\n");
+ data[2][2] = String::from("https://\nwww\n.\nredhat\n.com\n/en");
+ data
+}
+
+fn tab_data1() -> Vec<MatrixList<3, true>> {
+ let mut data = Matrix::list::<3, 3>();
+ data[1][0] = String::from("123\t123\tasdasd");
+ data[2][2] = String::from("htt\tps://\nwww\n.\nred\that\n.c\tom\n/en");
+ data
+}
+
+fn tab_data2() -> Vec<MatrixList<3, true>> {
+ let mut data = Matrix::list::<3, 3>();
+ data[0][0] = String::from("\tH\t\tello\tWorld");
+ data[1][0] = String::from("123\t123\tasdasd");
+ data[2][2] = String::from("htt\tps://\nwww\n.\nred\that\n.c\tom\n/en");
+ data
+}
+
+#[cfg(feature = "color")]
+fn colored_data() -> Vec<MatrixList<3, true>> {
+ let mut data = Matrix::list::<3, 3>();
+ data[1][0] = "asd\n21213123\n\n asdasd\n\n".red().to_string();
+ data[2][2] = "https://\nwww\n.\nredhat\n.com\n/en".on_blue().to_string();
+ data
+}
diff --git a/vendor/tabled/tests/settings/rotate_test.rs b/vendor/tabled/tests/settings/rotate_test.rs
new file mode 100644
index 000000000..42a781818
--- /dev/null
+++ b/vendor/tabled/tests/settings/rotate_test.rs
@@ -0,0 +1,214 @@
+#![cfg(feature = "std")]
+
+// todo: add method for SPACING between cells.
+
+use tabled::settings::{
+ object::{Cell, Rows},
+ Border, Highlight, Rotate,
+};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+#[test]
+fn test_rotate() {
+ let table = || Matrix::iter([(123, 456, 789), (234, 567, 891)]);
+
+ assert_eq!(
+ table()
+ .with(Rotate::Left)
+ .with(Rotate::Left)
+ .with(Rotate::Left)
+ .with(Rotate::Left)
+ .to_string(),
+ table().to_string()
+ );
+ assert_eq!(
+ table()
+ .with(Rotate::Right)
+ .with(Rotate::Right)
+ .with(Rotate::Right)
+ .with(Rotate::Right)
+ .to_string(),
+ table().to_string()
+ );
+ assert_eq!(
+ table().with(Rotate::Right).with(Rotate::Left).to_string(),
+ table().to_string()
+ );
+ assert_eq!(
+ table().with(Rotate::Left).with(Rotate::Right).to_string(),
+ table().to_string()
+ );
+ assert_eq!(
+ table().with(Rotate::Bottom).with(Rotate::Top).to_string(),
+ table().to_string()
+ );
+ assert_eq!(
+ table()
+ .with(Rotate::Bottom)
+ .with(Rotate::Bottom)
+ .to_string(),
+ table().to_string()
+ );
+ assert_eq!(
+ table().with(Rotate::Top).with(Rotate::Top).to_string(),
+ table().to_string()
+ );
+}
+
+test_table!(
+ test_3x3_box_0,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Rotate::Left),
+ "+-----+-----+-----+"
+ "| i32 | 789 | 891 |"
+ "+-----+-----+-----+"
+ "| i32 | 456 | 567 |"
+ "+-----+-----+-----+"
+ "| i32 | 123 | 234 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ test_3x3_box_1,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Rotate::Left).with(Rotate::Right).with(Rotate::Right),
+ "+-----+-----+-----+"
+ "| 234 | 123 | i32 |"
+ "+-----+-----+-----+"
+ "| 567 | 456 | i32 |"
+ "+-----+-----+-----+"
+ "| 891 | 789 | i32 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ test_left_rotate,
+ Matrix::iter([(123, 456, 789), (234, 567, 891), (111, 222, 333)]).with(Rotate::Left),
+ "+-----+-----+-----+-----+"
+ "| i32 | 789 | 891 | 333 |"
+ "+-----+-----+-----+-----+"
+ "| i32 | 456 | 567 | 222 |"
+ "+-----+-----+-----+-----+"
+ "| i32 | 123 | 234 | 111 |"
+ "+-----+-----+-----+-----+"
+);
+
+test_table!(
+ test_right_rotate,
+ Matrix::iter([(123, 456, 789), (234, 567, 891), (111, 222, 333)]).with(Rotate::Right),
+ "+-----+-----+-----+-----+"
+ "| 111 | 234 | 123 | i32 |"
+ "+-----+-----+-----+-----+"
+ "| 222 | 567 | 456 | i32 |"
+ "+-----+-----+-----+-----+"
+ "| 333 | 891 | 789 | i32 |"
+ "+-----+-----+-----+-----+"
+);
+
+test_table!(
+ test_bottom_rotate,
+ Matrix::iter([(123, 456, 789), (234, 567, 891), (111, 222, 333)]).with(Rotate::Bottom),
+ "+-----+-----+-----+"
+ "| 111 | 222 | 333 |"
+ "+-----+-----+-----+"
+ "| 234 | 567 | 891 |"
+ "+-----+-----+-----+"
+ "| 123 | 456 | 789 |"
+ "+-----+-----+-----+"
+ "| i32 | i32 | i32 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ test_top_rotate,
+ Matrix::iter([(123, 456, 789), (234, 567, 891), (111, 222, 333)]).with(Rotate::Top),
+ "+-----+-----+-----+"
+ "| 111 | 222 | 333 |"
+ "+-----+-----+-----+"
+ "| 234 | 567 | 891 |"
+ "+-----+-----+-----+"
+ "| 123 | 456 | 789 |"
+ "+-----+-----+-----+"
+ "| i32 | i32 | i32 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ rotate_preserve_border_styles_test_0,
+ Matrix::iter([(123, 456, 789), (234, 567, 891), (111, 222, 333)])
+ .with(Highlight::new(Rows::single(0), Border::default().top('*')))
+ .with(Rotate::Left),
+ "+*****************+-----+"
+ "| i32 | 789 | 891 | 333 |"
+ "+-----+-----+-----+-----+"
+ "| i32 | 456 | 567 | 222 |"
+ "+-----+-----+-----+-----+"
+ "| i32 | 123 | 234 | 111 |"
+ "+-----+-----+-----+-----+"
+);
+
+// it's a correct behaviour because
+// when we sen bottom border of cell(0, 2) we also set top border of cell(1, 2)
+//
+// todo: determine if it's correct
+test_table!(
+ rotate_preserve_border_styles_test_1,
+ Matrix::iter([(123, 456, 789), (234, 567, 891), (111, 222, 333)])
+ .with(Highlight::new(Cell::new(0, 2), Border::default().bottom('*')))
+ .with(Rotate::Left),
+ "+-----+-----+-----+-----+"
+ "| i32 | 789 | 891 | 333 |"
+ "+-----+-----+*****+-----+"
+ "| i32 | 456 | 567 | 222 |"
+ "+-----+-----+-----+-----+"
+ "| i32 | 123 | 234 | 111 |"
+ "+-----+-----+-----+-----+"
+);
+
+test_table!(
+ test_left_rotate_1,
+ Matrix::iter([(0, 1, 2, 3, 4, 5), (0, 1, 2, 3, 4, 5)]).with(Rotate::Left),
+ "+-----+---+---+"
+ "| i32 | 5 | 5 |"
+ "+-----+---+---+"
+ "| i32 | 4 | 4 |"
+ "+-----+---+---+"
+ "| i32 | 3 | 3 |"
+ "+-----+---+---+"
+ "| i32 | 2 | 2 |"
+ "+-----+---+---+"
+ "| i32 | 1 | 1 |"
+ "+-----+---+---+"
+ "| i32 | 0 | 0 |"
+ "+-----+---+---+"
+);
+
+test_table!(
+ test_right_rotate_1,
+ Matrix::iter([(0, 1, 2, 3, 4, 5), (0, 1, 2, 3, 4, 5)]).with(Rotate::Right),
+ "+---+---+-----+"
+ "| 0 | 0 | i32 |"
+ "+---+---+-----+"
+ "| 1 | 1 | i32 |"
+ "+---+---+-----+"
+ "| 2 | 2 | i32 |"
+ "+---+---+-----+"
+ "| 3 | 3 | i32 |"
+ "+---+---+-----+"
+ "| 4 | 4 | i32 |"
+ "+---+---+-----+"
+ "| 5 | 5 | i32 |"
+ "+---+---+-----+"
+);
+
+test_table!(
+ test_bottom_rotate_1,
+ Matrix::iter([(0, 1, 2, 3, 4, 5), (0, 1, 2, 3, 4, 5)]).with(Rotate::Bottom),
+ "+-----+-----+-----+-----+-----+-----+"
+ "| 0 | 1 | 2 | 3 | 4 | 5 |"
+ "+-----+-----+-----+-----+-----+-----+"
+ "| 0 | 1 | 2 | 3 | 4 | 5 |"
+ "+-----+-----+-----+-----+-----+-----+"
+ "| i32 | i32 | i32 | i32 | i32 | i32 |"
+ "+-----+-----+-----+-----+-----+-----+"
+);
diff --git a/vendor/tabled/tests/settings/shadow_test.rs b/vendor/tabled/tests/settings/shadow_test.rs
new file mode 100644
index 000000000..2d169698c
--- /dev/null
+++ b/vendor/tabled/tests/settings/shadow_test.rs
@@ -0,0 +1,105 @@
+#![cfg(feature = "std")]
+
+use tabled::settings::{Shadow, Style};
+
+use crate::matrix::Matrix;
+use testing_table::test_table;
+
+#[cfg(feature = "color")]
+use ::{owo_colors::OwoColorize, std::convert::TryFrom, tabled::settings::Color};
+
+test_table!(
+ test_shadow_bottom_right_0,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Style::psql()).with(Shadow::new(1)),
+ " i32 | i32 | i32 "
+ "-----+-----+-----▒"
+ " 123 | 456 | 789 ▒"
+ " 234 | 567 | 891 ▒"
+ " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
+);
+
+test_table!(
+ test_shadow_bottom_left_0,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Style::psql()).with(Shadow::new(1).set_left()),
+ " i32 | i32 | i32 "
+ "▒-----+-----+-----"
+ "▒ 123 | 456 | 789 "
+ "▒ 234 | 567 | 891 "
+ "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ "
+);
+
+test_table!(
+ test_shadow_top_right_0,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Style::psql()).with(Shadow::new(1).set_top()),
+ " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
+ " i32 | i32 | i32 ▒"
+ "-----+-----+-----▒"
+ " 123 | 456 | 789 ▒"
+ " 234 | 567 | 891 "
+);
+
+test_table!(
+ test_shadow_top_left_0,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Style::psql()).with(Shadow::new(1).set_top().set_left()),
+ "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ "
+ "▒ i32 | i32 | i32 "
+ "▒-----+-----+-----"
+ "▒ 123 | 456 | 789 "
+ " 234 | 567 | 891 "
+);
+
+test_table!(
+ test_shadow_set_fill,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Shadow::new(1).set_fill('▓')),
+ "+-----+-----+-----+ "
+ "| i32 | i32 | i32 |▓"
+ "+-----+-----+-----+▓"
+ "| 123 | 456 | 789 |▓"
+ "+-----+-----+-----+▓"
+ "| 234 | 567 | 891 |▓"
+ "+-----+-----+-----+▓"
+ " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"
+);
+
+test_table!(
+ test_shadow_size_1,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Shadow::new(2).set_fill('▓')),
+ "+-----+-----+-----+ "
+ "| i32 | i32 | i32 |▓▓"
+ "+-----+-----+-----+▓▓"
+ "| 123 | 456 | 789 |▓▓"
+ "+-----+-----+-----+▓▓"
+ "| 234 | 567 | 891 |▓▓"
+ "+-----+-----+-----+▓▓"
+ " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"
+ " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"
+);
+
+test_table!(
+ test_shadow_set_offset_0,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Shadow::new(2).set_offset(3)),
+ "+-----+-----+-----+ "
+ "| i32 | i32 | i32 | "
+ "+-----+-----+-----+ "
+ "| 123 | 456 | 789 |▒▒"
+ "+-----+-----+-----+▒▒"
+ "| 234 | 567 | 891 |▒▒"
+ "+-----+-----+-----+▒▒"
+ " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
+ " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ test_shadow_set_color_0,
+ Matrix::iter([(123, 456, 789), (234, 567, 891)]).with(Shadow::new(2).set_offset(3).set_color(Color::try_from(' '.red().to_string()).unwrap())),
+ "+-----+-----+-----+ "
+ "| i32 | i32 | i32 | "
+ "+-----+-----+-----+ "
+ "| 123 | 456 | 789 |\u{1b}[31m▒▒\u{1b}[39m"
+ "+-----+-----+-----+\u{1b}[31m▒▒\u{1b}[39m"
+ "| 234 | 567 | 891 |\u{1b}[31m▒▒\u{1b}[39m"
+ "+-----+-----+-----+\u{1b}[31m▒▒\u{1b}[39m"
+ " \u{1b}[31m▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\u{1b}[39m"
+ " \u{1b}[31m▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\u{1b}[39m"
+);
diff --git a/vendor/tabled/tests/settings/span_test.rs b/vendor/tabled/tests/settings/span_test.rs
new file mode 100644
index 000000000..ed61d8619
--- /dev/null
+++ b/vendor/tabled/tests/settings/span_test.rs
@@ -0,0 +1,1234 @@
+#![cfg(feature = "std")]
+#![allow(clippy::redundant_clone)]
+
+use std::iter::FromIterator;
+
+use tabled::{
+ builder::Builder,
+ grid::config::Position,
+ settings::{
+ object::{Columns, Segment},
+ style::{Border, BorderSpanCorrection, Style},
+ Alignment, Highlight, Modify, Padding, Panel, Span,
+ },
+ Table,
+};
+
+use crate::matrix::Matrix;
+use testing_table::{static_table, test_table};
+
+test_table!(
+ span_column_test_0,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Columns::single(0)).with(Span::column(2))),
+ " N | column 1 | column 2 "
+ "-+-+----------+----------"
+ " 0 | 0-1 | 0-2 "
+ " 1 | 1-1 | 1-2 "
+ " 2 | 2-1 | 2-2 "
+);
+
+test_table!(
+ span_column_test_1,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Columns::new(1..2)).with(Span::column(2))),
+ " N | column 0 | column 2 "
+ "---+-----+----+----------"
+ " 0 | 0-0 | 0-2 "
+ " 1 | 1-0 | 1-2 "
+ " 2 | 2-0 | 2-2 "
+);
+
+test_table!(
+ span_column_test_2,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Columns::single(0)).with(Span::column(4))),
+ " N "
+ "+++"
+ " 0 "
+ " 1 "
+ " 2 "
+);
+
+test_table!(
+ cell_span_test_0,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((0, 0)).with(Span::column(2))),
+ " N | column 1 | column 2 "
+ "---+-----+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_1,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((1, 0)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_2,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((2, 0)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_3,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((3, 0)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_4,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((0, 1)).with(Span::column(2))),
+ " N | column 0 | column 2 "
+ "---+-----+-----+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_5,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((1, 1)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_6,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((2, 1)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_7,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((3, 1)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_8,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((0, 2)).with(Span::column(2))),
+ " N | column 0 | column 1 "
+ "---+----------+-----+-----"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_9,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((1, 2)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_10,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((2, 2)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ cell_span_test_11,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((3, 2)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 "
+);
+
+test_table!(
+ span_multiline,
+ Matrix::new(3, 3)
+ .insert((3, 2), "https://\nwww\n.\nredhat\n.com\n/en")
+ .with(Style::psql())
+ .with(Modify::new((3, 2)).with(Span::column(2))),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | https:// "
+ " | | www "
+ " | | . "
+ " | | redhat "
+ " | | .com "
+ " | | /en "
+);
+
+test_table!(
+ indent_works_in_spaned_columns,
+ Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Padding::new(3, 0, 0, 0)))
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((1, 1)).with(Span::column(3)))
+ .with(Modify::new((3, 1)).with(Span::column(3))),
+ " N| column 0| column 1| column 2"
+ "----+-----------+-----------+-----------"
+ " 0| 0-0 "
+ " 1| 1-0 | 1-1 | 1-2 "
+ " 2| 2-0 "
+);
+
+test_table!(
+ spaned_columns_with_collision,
+ Matrix::iter([["just 1 column"; 5]; 5])
+ .with(Style::modern())
+ .with(
+ Modify::new((0, 0))
+ .with(Span::column(5))
+ .with("span all 5 columns"),
+ )
+ .with(
+ Modify::new((1, 0))
+ .with(Span::column(4))
+ .with("span 4 columns"),
+ )
+ .with(
+ Modify::new((2, 0))
+ .with(Span::column(3))
+ .with("span 3 columns"),
+ )
+ .with(
+ Modify::new((2, 3))
+ .with(Span::column(2))
+ .with("span 2 columns"),
+ )
+ .with(
+ Modify::new((3, 0))
+ .with(Span::column(2))
+ .with("span 3 columns"),
+ )
+ .with(
+ Modify::new((3, 2))
+ .with(Span::column(3))
+ .with("span 3 columns"),
+ )
+ .with(
+ Modify::new((4, 1))
+ .with(Span::column(4))
+ .with("span 4 columns"),
+ ),
+ "┌───────────────┬───────────────┬───────────────┬───────────────┬───────────────┐"
+ "│ span all 5 columns │"
+ "├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤"
+ "│ span 4 columns │ just 1 column │"
+ "├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤"
+ "│ span 3 columns │ span 2 columns │"
+ "├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤"
+ "│ span 3 columns │ span 3 columns │"
+ "├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤"
+ "│ just 1 column │ span 4 columns │"
+ "├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤"
+ "│ just 1 column │ just 1 column │ just 1 column │ just 1 column │ just 1 column │"
+ "└───────────────┴───────────────┴───────────────┴───────────────┴───────────────┘"
+);
+
+test_table!(
+ span_with_panel_test_0,
+ Matrix::iter([[1, 2, 3]])
+ .with(Panel::horizontal(0,"Tabled Releases"))
+ .with(Modify::new((1, 0)).with(Span::column(2)))
+ .with(Style::ascii()),
+ "+-----+-----+-----+"
+ "| Tabled Releases |"
+ "+-----+-----+-----+"
+ "| 0 | 2 |"
+ "+-----+-----+-----+"
+ "| 1 | 2 | 3 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ span_with_panel_test_1,
+ Matrix::iter([[1, 2, 3], [4, 5, 6]])
+ .with(Panel::horizontal(0,"Tabled Releases"))
+ .with(Modify::new((2, 0)).with(Span::column(2)))
+ .with(Style::ascii()),
+ "+-----+-----+-----+"
+ "| Tabled Releases |"
+ "+-----+-----+-----+"
+ "| 0 | 1 | 2 |"
+ "+-----+-----+-----+"
+ "| 1 | 3 |"
+ "+-----+-----+-----+"
+ "| 4 | 5 | 6 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ span_with_panel_test_2,
+ Matrix::iter([[1, 2, 3], [4, 5, 6]])
+ .with(Panel::horizontal(0,"Tabled Releases"))
+ .with(Modify::new((1, 0)).with(Span::column(2)))
+ .with(Modify::new((2, 0)).with(Span::column(2)))
+ .with(Style::ascii()),
+ "+-----+-----+-----+"
+ "| Tabled Releases |"
+ "+-----+-----+-----+"
+ "| 0 | 2 |"
+ "+-----+-----+-----+"
+ "| 1 | 3 |"
+ "+-----+-----+-----+"
+ "| 4 | 5 | 6 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ span_with_panel_with_correction_test_0,
+ Matrix::iter([[1, 2, 3]])
+ .with(Panel::horizontal(0,"Tabled Releases"))
+ .with(Modify::new((1, 0)).with(Span::column(2)))
+ .with(Style::ascii())
+ .with(BorderSpanCorrection),
+ "+-----------------+"
+ "| Tabled Releases |"
+ "+-----------+-----+"
+ "| 0 | 2 |"
+ "+-----+-----+-----+"
+ "| 1 | 2 | 3 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ span_with_panel_with_correction_test_1,
+ Matrix::iter([[1, 2, 3], [4, 5, 6]])
+ .with(Panel::horizontal(0,"Tabled Releases"))
+ .with(Modify::new((2, 0)).with(Span::column(2)))
+ .with(Style::ascii())
+ .with(BorderSpanCorrection),
+ "+-----------------+"
+ "| Tabled Releases |"
+ "+-----+-----+-----+"
+ "| 0 | 1 | 2 |"
+ "+-----+-----+-----+"
+ "| 1 | 3 |"
+ "+-----+-----+-----+"
+ "| 4 | 5 | 6 |"
+ "+-----+-----+-----+"
+);
+
+test_table!(
+ span_with_panel_with_correction_test_2,
+ Matrix::iter([[1, 2, 3], [4, 5, 6]])
+ .with(Panel::horizontal(0,"Tabled Releases"))
+ .with(Modify::new((1, 0)).with(Span::column(2)))
+ .with(Modify::new((2, 0)).with(Span::column(2)))
+ .with(Style::ascii())
+ .with(BorderSpanCorrection),
+ "+-----------------+"
+ "| Tabled Releases |"
+ "+-----------+-----+"
+ "| 0 | 2 |"
+ "+-----------+-----+"
+ "| 1 | 3 |"
+ "+-----+-----+-----+"
+ "| 4 | 5 | 6 |"
+ "+-----+-----+-----+"
+);
+
+#[test]
+#[should_panic]
+#[ignore = "span zero not yet decided"]
+fn span_column_exceeds_boundaries_test() {
+ // todo: determine if it's the right behaiviour
+
+ Matrix::new(3, 3)
+ .with(Modify::new(Columns::single(0)).with(Span::column(100)))
+ .to_string();
+}
+
+#[test]
+#[ignore = "span zero not yet decided"]
+fn span_cell_exceeds_boundaries_test() {
+ // these tests shows that exiding boundaries causes invalid behaiviour
+ //
+ // todo: determine if it's the right behaiviour
+
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((0, 0)).with(Span::column(20)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N "
+ "---+-----+-----+-----"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((1, 1)).with(Span::column(20)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((1, 0)).with(Span::column(20)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+}
+
+#[test]
+#[ignore = "span zero not yet decided"]
+fn span_zero_test() {
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((0, 0)).with(Span::column(0)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " column 0 | column 1 | column 2 "
+ "----+-----+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((0, 1)).with(Span::column(0)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 1 | column 2 "
+ "---+-----+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((0, 2)).with(Span::column(0)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 2 "
+ "---+-----+-----+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((0, 3)).with(Span::column(0)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 "
+ "---+----------+-----+-----"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((0, 4)).with(Span::column(0)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .with(Style::psql())
+ .with(Modify::new((0, 0)).with(Span::column(0)))
+ .with(Modify::new((1, 1)).with(Span::column(0)))
+ .with(Modify::new((2, 2)).with(Span::column(0)))
+ .with(Modify::new((3, 2)).with(Span::column(0)))
+ .with(Modify::new((3, 1)).with(Span::column(0)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " column 0 | column 1 | column 2 "
+ "------+-------+------+----------"
+ " 0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-2 "
+ " 2 | 2-2 "
+ )
+ );
+}
+
+#[test]
+#[ignore = "span zero not yet decided"]
+fn span_all_table_to_zero_test() {
+ let table = Matrix::table(2, 2)
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Span::column(0)))
+ .to_string();
+
+ // todo: determine whether it's correct
+ assert_eq!(table, static_table!("\n++\n\n\n"));
+}
+
+mod row {
+ use tabled::settings::object::Rows;
+
+ use super::*;
+
+ #[test]
+ fn span_row_test() {
+ let table = Matrix::new(3, 3);
+ {
+ let table_str = table
+ .clone()
+ .with(Style::ascii())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Rows::single(0)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table_str,
+ static_table!(
+ "+---+----------+----------+----------+"
+ "+ N + column 0 + column 1 + column 2 +"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+ )
+ );
+
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Rows::single(0)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N + column 0 + column 1 + column 2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Rows::new(1..2)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Rows::single(0)).with(Span::row(4)))
+ .to_string();
+
+ assert_eq!(table, " N + column 0 + column 1 + column 2 ");
+ }
+ }
+
+ #[test]
+ fn cell_span_test() {
+ let table = Matrix::new(3, 3);
+ {
+ // first column cells row span = 2
+
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((0, 0)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ " +----------+----------+----------"
+ " | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((1, 0)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new((2, 0)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ }
+
+ {
+ // first row cells row span = 2
+
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((0, 1)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+ +----------+----------"
+ " 0 | | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((0, 2)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+ +----------"
+ " 0 | 0-0 | | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new((0, 3)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+ "
+ " 0 | 0-0 | 0-1 | "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ }
+
+ {
+ // second column span=2
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((1, 1)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((2, 1)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | | 2-1 | 2-2 "
+ )
+ );
+ }
+ }
+ {
+ // 3rd column span=2
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((1, 2)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((2, 2)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | | 2-2 "
+ )
+ );
+ }
+ }
+ {
+ // 4th column span=2
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((1, 3)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ }
+ {
+ let table = table
+ .clone()
+ .with(Style::psql())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new((2, 3)).with(Span::row(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | "
+ )
+ );
+ }
+ }
+ }
+
+ #[test]
+ fn span_with_panel_with_correction_test() {
+ let data = [[1, 2, 3]];
+ let table = Table::new(data)
+ .with(Modify::new((0, 0)).with(Span::row(2)))
+ .with(Style::ascii())
+ .with(BorderSpanCorrection)
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "| +---+---+"
+ "| | 2 | 3 |"
+ "+---+---+---+"
+ )
+ );
+
+ let data = [[1, 2, 3], [4, 5, 6]];
+ let table = Table::new(data)
+ .with(Modify::new((1, 0)).with(Span::row(2)))
+ .with(Modify::new((0, 2)).with(Span::row(3)))
+ .with(Style::ascii())
+ .with(BorderSpanCorrection)
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+---+---+ |"
+ "| 1 | 2 | |"
+ "| +---+ |"
+ "| | 5 | |"
+ "+---+---+---+"
+ )
+ );
+
+ let data = [[1, 2, 3], [4, 5, 6]];
+ let table = Table::new(data)
+ .with(Modify::new((1, 0)).with(Span::row(2)))
+ .with(Modify::new((0, 2)).with(Span::row(3)))
+ .with(Modify::new((0, 1)).with(Span::row(2)))
+ .with(Style::ascii())
+ .with(BorderSpanCorrection)
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "+---+---+---+"
+ "| 0 | 1 | 2 |"
+ "+---+ | |"
+ "| 1 +---+ |"
+ "| | 5 | |"
+ "+---+---+---+"
+ )
+ );
+
+ let data = [[1, 2, 3], [4, 5, 6]];
+ let table = Table::new(data)
+ .with(Modify::new((1, 0)).with(Span::row(2)))
+ .with(Modify::new((0, 1)).with(Span::row(2)).with(Span::column(2)))
+ .with(Style::ascii())
+ .with(BorderSpanCorrection)
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "+---+-------+"
+ "| 0 | 1 |"
+ "+---+ +"
+ "| 1 +---+---+"
+ "| | 5 | 6 |"
+ "+---+---+---+"
+ )
+ );
+ }
+
+ #[test]
+ fn span_example_test() {
+ let data = [["just 1 column"; 5]; 5];
+
+ let h_span = |r, c, span| Modify::new((r, c)).with(Span::column(span));
+ let v_span = |r, c, span| Modify::new((r, c)).with(Span::row(span));
+
+ let table = Table::new(data)
+ .with(h_span(0, 0, 5).with(String::from("span all 5 columns")))
+ .with(h_span(1, 0, 4).with(String::from("span 4 columns")))
+ .with(h_span(2, 0, 2).with(String::from("span 2 columns")))
+ .with(v_span(2, 4, 4).with(String::from("just 1 column\nspan\n4\ncolumns")))
+ .with(v_span(3, 1, 2).with(String::from("span 2 columns\nspan\n2\ncolumns")))
+ .with(v_span(2, 3, 3).with(String::from("just 1 column\nspan\n3\ncolumns")))
+ .with(h_span(3, 1, 2))
+ .with(Style::modern())
+ .with(BorderSpanCorrection)
+ .with(Modify::new(Segment::all()).with(Alignment::center_vertical()))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "┌───────────────────────────────────────────────────────────────────────────────┐"
+ "│ span all 5 columns │"
+ "├───────────────────────────────────────────────────────────────┬───────────────┤"
+ "│ span 4 columns │ just 1 column │"
+ "├───────────────────────────────┬───────────────┬───────────────┼───────────────┤"
+ "│ span 2 columns │ just 1 column │ │ │"
+ "├───────────────┬───────────────┴───────────────┤ just 1 column │ │"
+ "│ just 1 column │ span 2 columns │ span │ just 1 column │"
+ "│ │ span │ 3 │ span │"
+ "├───────────────┤ 2 │ columns │ 4 │"
+ "│ just 1 column │ columns │ │ columns │"
+ "├───────────────┼───────────────┬───────────────┼───────────────┤ │"
+ "│ just 1 column │ just 1 column │ just 1 column │ just 1 column │ │"
+ "└───────────────┴───────────────┴───────────────┴───────────────┴───────────────┘"
+ )
+ )
+ }
+
+ #[test]
+ fn highlight_row_span_test() {
+ let data = [
+ ["1", "2\n2\n2\n2\n2\n2\n2\n2", "3"],
+ ["4", "5", "6"],
+ ["7", "8", "9"],
+ ];
+ let table = Table::new(data)
+ .with(Modify::new((1, 1)).with(Span::row(3)))
+ .with(Style::modern())
+ .with(Highlight::new(Columns::single(1), Border::filled('*')))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "┌───*****───┐"
+ "│ 0 * 1 * 2 │"
+ "├───*───*───┤"
+ "│ 1 * 2 * 3 │"
+ "│ * 2 * │"
+ "├───* 2 *───┤"
+ "│ 4 * 2 * 6 │"
+ "│ * 2 * │"
+ "├───* 2 *───┤"
+ "│ 7 * 2 * 9 │"
+ "│ * 2 * │"
+ "└───*****───┘"
+ )
+ );
+ }
+}
+
+#[test]
+fn highlight_row_col_span_test() {
+ let data = [
+ ["1", "2\n2\n2\n2\n2\n2\n2\n2", "3", "0"],
+ ["4", "5", "6", "0"],
+ ["7", "8", "9", "0"],
+ ];
+ let table = Table::new(data)
+ .with(Modify::new((1, 1)).with(Span::row(3)).with(Span::column(2)))
+ .with(Style::modern())
+ .with(Highlight::new(Columns::new(1..3), Border::filled('*')))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "┌───*********───┐"
+ "│ 0 * 1 │ 2 * 3 │"
+ "├───*───┼───*───┤"
+ "│ 1 * 2 * 0 │"
+ "│ * 2 * │"
+ "├───* 2 *───┤"
+ "│ 4 * 2 * 0 │"
+ "│ * 2 * │"
+ "├───* 2 *───┤"
+ "│ 7 * 2 * 0 │"
+ "│ * 2 * │"
+ "└───*********───┘"
+ )
+ );
+}
+
+test_table!(
+ column_span_bigger_then_max,
+ Matrix::new(3, 3).with(Modify::new((0, 0)).with(Span::column(100))),
+ "+---+-----+-----+-----+"
+ "| N |"
+ "+---+-----+-----+-----+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+-----+-----+-----+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+-----+-----+-----+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+-----+-----+-----+"
+);
+
+test_table!(
+ row_span_bigger_then_max,
+ Matrix::new(3, 3).with(Modify::new((0, 0)).with(Span::row(100))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+ +----------+----------+----------+"
+ "| | 0-0 | 0-1 | 0-2 |"
+ "+ +----------+----------+----------+"
+ "| | 1-0 | 1-1 | 1-2 |"
+ "+ +----------+----------+----------+"
+ "| | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ column_span_invalid_position_row,
+ Matrix::new(3, 3).with(Modify::new((1000, 0)).with(Span::column(2))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ column_span_invalid_position_column,
+ Matrix::new(3, 3).with(Modify::new((0, 1000)).with(Span::column(2))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ column_span_invalid_position_row_and_column,
+ Matrix::new(3, 3).with(Modify::new((1000, 1000)).with(Span::column(2))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ row_span_invalid_position_row,
+ Matrix::new(3, 3).with(Modify::new((1000, 0)).with(Span::row(2))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ row_span_invalid_position_column,
+ Matrix::new(3, 3).with(Modify::new((0, 1000)).with(Span::row(2))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ row_span_invalid_position_row_and_column,
+ Matrix::new(3, 3).with(Modify::new((1000, 1000)).with(Span::row(2))),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ fix_qc_0,
+ {
+ let data: [[i64; 39]; 2] = [[2542785870, 2382388818, 2879895075, 2885436543, 2331131758, 219892320, 2503640226, 3754929678, 2206481860, 686909682, 3456499235, 931699300, 1556722454, 958179233, 3896072307, 2042612749, 3354379549, 3272539286, 3926297167, 4294967295, 1650407458, 3322068437, 4294967295, 446762625, 829020202, 4150192304, 3430619243, 3460609391, 2992017103, 513091574, 1514148367, 2166549688, 1401371431, 2854075038, 1286733939, 2959901405, 4152658371, 0, 4224074215], [360331598, 3736108702, 2948800064, 2121584548, 1609988995, 469935087, 3974876615, 2193609088, 3568111892, 732365859, 0, 4294967295, 2994498036, 198522721, 1784359340, 1, 2732726754, 592359359, 3016729802, 878533877, 2997437699, 3573361662, 1111570515, 4294967295, 2245782848, 1383106893, 0, 0, 2869976103, 1611436878, 1682224972, 3249055253, 1562255501, 1370527728, 240481955, 334260406, 2247343342, 3000635978, 395723768]];
+ let row_spans = [2, 1, 27, 111, 226, 221, 121, 22, 252, 30, 115, 85, 255, 126, 26, 245, 36, 50, 255, 211, 47, 114, 174, 173, 145, 138, 78, 198, 253, 229, 151, 243, 242, 30, 52, 116, 177, 25, 1, 32, 28, 48, 225, 103, 17, 243, 0, 128, 69, 206, 221, 105, 239, 74, 184, 48, 178, 237, 120, 228, 184, 1, 132, 118, 14, 187];
+ let col_spans = [7, 91, 56, 246, 73];
+
+ let data = data.iter().map(|row| row.iter().map(ToString::to_string));
+ let rspans = create_span_list(2, 39).zip(row_spans.iter()).map(|(pos, span)| Modify::new(pos).with(Span::column(*span))).collect::<Vec<_>>();
+ let cspans = create_span_list(2, 39).zip(col_spans.iter()).map(|(pos, span)| Modify::new(pos).with(Span::row(*span))).collect::<Vec<_>>();
+
+ Builder::from_iter(data).build().with(Style::ascii()).with(rspans).with(cspans).to_string()
+ },
+ "+------+-----++++++++++++++++++++++++++++------------+------------+------------+------------+------------+-----------+-----------+------------+------------+-----------+"
+ "| 2542785870 | 2879895075 | 513091574 |"
+ "+ + +------------+------------+------------+------------+------------+-----------+-----------+------------+------------+-----------+"
+ "| | | 1611436878 | 1682224972 | 3249055253 | 1562255501 | 1370527728 | 240481955 | 334260406 | 2247343342 | 3000635978 | 395723768 |"
+ "+------+-----++++++++++++++++++++++++++++------------+------------+------------+------------+------------+-----------+-----------+------------+------------+-----------+"
+);
+
+fn create_span_list(count_rows: usize, count_cols: usize) -> impl Iterator<Item = Position> {
+ (0..count_rows).flat_map(move |r| (0..count_cols).map(move |c| (r, c)))
+}
diff --git a/vendor/tabled/tests/settings/split_test.rs b/vendor/tabled/tests/settings/split_test.rs
new file mode 100644
index 000000000..ac13d8071
--- /dev/null
+++ b/vendor/tabled/tests/settings/split_test.rs
@@ -0,0 +1,277 @@
+#![cfg(feature = "std")]
+
+use std::iter::FromIterator;
+
+use tabled::{builder::Builder, settings::split::Split, Table};
+
+use testing_table::test_table;
+
+test_table!(
+ split_column_test,
+ Table::from_iter(['a'..='z']).with(Split::column(12)),
+ "+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | b | c | d | e | f | g | h | i | j | k | l |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| m | n | o | p | q | r | s | t | u | v | w | x |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| y | z | | | | | | | | | | |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_column_2_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::column(12))
+ .with(Split::column(4)),
+ "+---+---+---+---+"
+ "| a | b | c | d |"
+ "+---+---+---+---+"
+ "| e | f | g | h |"
+ "+---+---+---+---+"
+ "| i | j | k | l |"
+ "+---+---+---+---+"
+ "| m | n | o | p |"
+ "+---+---+---+---+"
+ "| q | r | s | t |"
+ "+---+---+---+---+"
+ "| u | v | w | x |"
+ "+---+---+---+---+"
+ "| y | z | | |"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ split_column_retain_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::column(12))
+ .with(Split::column(4).retain()),
+ "+---+---+---+---+"
+ "| a | b | c | d |"
+ "+---+---+---+---+"
+ "| e | f | g | h |"
+ "+---+---+---+---+"
+ "| i | j | k | l |"
+ "+---+---+---+---+"
+ "| m | n | o | p |"
+ "+---+---+---+---+"
+ "| q | r | s | t |"
+ "+---+---+---+---+"
+ "| u | v | w | x |"
+ "+---+---+---+---+"
+ "| y | z | | |"
+ "+---+---+---+---+"
+ "| | | | |"
+ "+---+---+---+---+"
+ "| | | | |"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ split_row_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::column(12))
+ .with(Split::column(4))
+ .with(Split::row(1).concat()), // take it back to the original shape
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_row_2_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::column(12))
+ .with(Split::column(4))
+ .with(Split::row(2).concat()),
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | b | c | d | i | j | k | l | q | r | s | t | y | z |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| e | f | g | h | m | n | o | p | u | v | w | x | | |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_colum_index_beyond_size_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::column(10000)),
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_row_index_beyond_size_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::row(10000)),
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_empty_table_test,
+ Builder::default().build().with(Split::column(10000)),
+ ""
+);
+
+test_table!(
+ split_column_zero_argument_test,
+ Table::from_iter(['a'..='z']).with(Split::column(0)),
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_row_zero_argument_test,
+ Table::from_iter(['a'..='z']).with(Split::row(0)),
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_blank_table_test,
+ Table::from_iter([vec![String::new(); 26]]).with(Split::column(12)),
+ "+--+--+--+--+--+--+--+--+--+--+--+--+"
+ "| | | | | | | | | | | | |" // first section is protected
+ "+--+--+--+--+--+--+--+--+--+--+--+--+"
+);
+
+test_table!(
+ split_blank_table_2_test,
+ Table::from_iter([vec![String::new(); 26]]).with(Split::column(12).retain()),
+ "+--+--+--+--+--+--+--+--+--+--+--+--+"
+ "| | | | | | | | | | | | |"
+ "+--+--+--+--+--+--+--+--+--+--+--+--+"
+ "| | | | | | | | | | | | |"
+ "+--+--+--+--+--+--+--+--+--+--+--+--+"
+ "| | | | | | | | | | | | |"
+ "+--+--+--+--+--+--+--+--+--+--+--+--+"
+);
+
+test_table!(
+ split_zip_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::column(6))
+ .with(Split::row(2)),
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | m | y | b | n | z | c | o | d | p | e | q | f | r |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| g | s | | h | t | | i | u | j | v | k | w | l | x |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_concat_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::column(6))
+ .with(Split::row(2).concat()),
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | b | c | d | e | f | m | n | o | p | q | r | y | z |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| g | h | i | j | k | l | s | t | u | v | w | x | | |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_clean_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::column(12))
+ .with(Split::row(2)),
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| a | y | b | z | c | d | e | f | g | h | i | j | k | l |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+ "| m | | n | | o | p | q | r | s | t | u | v | w | x |"
+ "+---+---+---+---+---+---+---+---+---+---+---+---+---+---+"
+);
+
+test_table!(
+ split_retain_test,
+ Table::from_iter(['a'..='z'])
+ .with(Split::column(12))
+ .with(Split::row(2).retain()),
+ "+---+---+---+---+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+"
+ "| a | y | b | z | c | | d | | e | | f | | g | | h | | i | | j | | k | | l | |"
+ "+---+---+---+---+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+"
+ "| m | | n | | o | | p | | q | | r | | s | | t | | u | | v | | w | | x | |"
+ "+---+---+---+---+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+"
+);
+
+test_table!(
+ split_mostly_blank_test,
+ Table::from_iter([vec![
+ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "", "", "A",
+ ]]).with(Split::column(5))
+ .with(Split::row(2)),
+ "+--+--+--+---+--+"
+ "| | | | | |"
+ "+--+--+--+---+--+"
+ "| | | | A | |"
+ "+--+--+--+---+--+"
+);
+
+test_table!(
+ split_mostly_blank_retain_test,
+ Table::from_iter([vec![
+ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "", "", "A",
+ ]]).with(Split::column(5).retain()),
+ "+--+--+--+---+--+"
+ "| | | | | |"
+ "+--+--+--+---+--+"
+ "| | | | | |"
+ "+--+--+--+---+--+"
+ "| | | | | |"
+ "+--+--+--+---+--+"
+ "| | | | | |"
+ "+--+--+--+---+--+"
+ "| | | | | |"
+ "+--+--+--+---+--+"
+ "| | | | | |"
+ "+--+--+--+---+--+"
+ "| | | | A | |"
+ "+--+--+--+---+--+"
+);
+
+test_table!(
+ split_scattered_values_test,
+ Table::from_iter([vec![
+ "", "", "", "", "", "g", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "", "", "A",
+ ]]).with(Split::column(5)),
+ "+---+--+--+---+--+"
+ "| | | | | |"
+ "+---+--+--+---+--+"
+ "| g | | | | |"
+ "+---+--+--+---+--+"
+ "| | | | A | |"
+ "+---+--+--+---+--+"
+);
+
+test_table!(
+ split_scattered_values_column_and_row_test,
+ Table::from_iter([vec![
+ "", "", "", "", "", "g", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "", "", "A",
+ ]]).with(Split::column(5)).with(Split::row(2)),
+ "+---+--+--+--+---+--+"
+ "| | | | | A | |"
+ "+---+--+--+--+---+--+"
+ "| g | | | | | |"
+ "+---+--+--+--+---+--+"
+);
+
+test_table!(
+ split_scattered_values_column_and_row_retain_test,
+ Table::from_iter([vec![
+ "", "", "", "", "", "g", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+ "", "", "", "", "", "", "", "", "", "", "A",
+ ]]).with(Split::column(5).retain()).with(Split::row(2).retain()),
+ "+---+--+--+--+--+--+--+--+--+--+--+--+--+--+--+---+--+--+--+--+"
+ "| | | | | | | | | | | | | | | | A | | | | |"
+ "+---+--+--+--+--+--+--+--+--+--+--+--+--+--+--+---+--+--+--+--+"
+ "| g | | | | | | | | | | | | | | | | | | | |"
+ "+---+--+--+--+--+--+--+--+--+--+--+--+--+--+--+---+--+--+--+--+"
+);
diff --git a/vendor/tabled/tests/settings/style_test.rs b/vendor/tabled/tests/settings/style_test.rs
new file mode 100644
index 000000000..884192471
--- /dev/null
+++ b/vendor/tabled/tests/settings/style_test.rs
@@ -0,0 +1,2606 @@
+#![cfg(feature = "std")]
+
+use std::iter::FromIterator;
+
+use tabled::{
+ builder::Builder,
+ settings::{
+ object::{Columns, Rows, Segment},
+ style::{
+ Border, BorderChar, BorderColor, BorderSpanCorrection, BorderText, HorizontalLine,
+ Line, Offset, RawStyle, Style, VerticalLine,
+ },
+ Color, Format, Highlight, Modify, Padding, Span,
+ },
+ Table,
+};
+
+use crate::matrix::Matrix;
+use testing_table::{static_table, test_table};
+
+#[cfg(feature = "color")]
+use ::{owo_colors::OwoColorize, std::convert::TryFrom};
+
+test_table!(
+ default_style,
+ Matrix::new(3, 3).with(Style::ascii()),
+ "+---+----------+----------+----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+----------+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+---+----------+----------+----------+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+---+----------+----------+----------+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+---+----------+----------+----------+"
+);
+
+test_table!(
+ psql_style,
+ Matrix::new(3, 3).with(Style::psql()),
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | 0-0 | 0-1 | 0-2 "
+ " 1 | 1-0 | 1-1 | 1-2 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+);
+
+test_table!(
+ markdown_style,
+ Matrix::new(3, 3).with(Style::markdown()),
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ modern_style,
+ Matrix::new(3, 3).with(Style::modern()),
+ "┌───┬──────────┬──────────┬──────────┐"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└───┴──────────┴──────────┴──────────┘"
+);
+
+test_table!(
+ rounded_style,
+ Matrix::new(3, 3).with(Style::rounded()),
+ "╭───┬──────────┬──────────┬──────────╮"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "╰───┴──────────┴──────────┴──────────╯"
+);
+
+test_table!(
+ sharp_style,
+ Matrix::new(3, 3).with(Style::sharp()),
+ "┌───┬──────────┬──────────┬──────────┐"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└───┴──────────┴──────────┴──────────┘"
+);
+
+test_table!(
+ modern_clean_style,
+ Matrix::new(3, 3).with(Style::modern().remove_horizontal().horizontals(vec![HorizontalLine::new(1, Style::modern().get_horizontal())])),
+ "┌───┬──────────┬──────────┬──────────┐"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└───┴──────────┴──────────┴──────────┘"
+);
+
+test_table!(
+ blank_style,
+ Matrix::new(3, 3).with(Style::blank()),
+ " N column 0 column 1 column 2 "
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+);
+
+test_table!(
+ extended_style,
+ Matrix::new(3, 3).with(Style::extended()),
+ "╔═══╦══════════╦══════════╦══════════╗"
+ "║ N ║ column 0 ║ column 1 ║ column 2 ║"
+ "╠═══╬══════════╬══════════╬══════════╣"
+ "║ 0 ║ 0-0 ║ 0-1 ║ 0-2 ║"
+ "╠═══╬══════════╬══════════╬══════════╣"
+ "║ 1 ║ 1-0 ║ 1-1 ║ 1-2 ║"
+ "╠═══╬══════════╬══════════╬══════════╣"
+ "║ 2 ║ 2-0 ║ 2-1 ║ 2-2 ║"
+ "╚═══╩══════════╩══════════╩══════════╝"
+);
+
+test_table!(
+ ascii_dots_style,
+ Matrix::new(3, 3).with(Style::dots()),
+ "......................................"
+ ": N : column 0 : column 1 : column 2 :"
+ ":...:..........:..........:..........:"
+ ": 0 : 0-0 : 0-1 : 0-2 :"
+ ":...:..........:..........:..........:"
+ ": 1 : 1-0 : 1-1 : 1-2 :"
+ ":...:..........:..........:..........:"
+ ": 2 : 2-0 : 2-1 : 2-2 :"
+ ":...:..........:..........:..........:"
+);
+
+test_table!(
+ re_structured_text_style,
+ Matrix::new(3, 3).with(Style::re_structured_text()),
+ "=== ========== ========== =========="
+ " N column 0 column 1 column 2 "
+ "=== ========== ========== =========="
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ "=== ========== ========== =========="
+);
+
+test_table!(
+ ascii_rounded_style,
+ Matrix::new(3, 3).with(Style::ascii_rounded()),
+ ".------------------------------------."
+ "| N | column 0 | column 1 | column 2 |"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "'------------------------------------'"
+);
+
+test_table!(
+ style_head_changes,
+ Matrix::new(3, 3).with(Style::modern().remove_horizontal()),
+ "┌───┬──────────┬──────────┬──────────┐"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└───┴──────────┴──────────┴──────────┘"
+);
+
+test_table!(
+ style_frame_changes,
+ Matrix::new(3, 3).with(Style::modern().remove_top().remove_bottom().remove_horizontal()),
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+);
+
+test_table!(
+ custom_style,
+ Matrix::new(3, 3)
+ .with(Style::blank()
+ .bottom('*')
+ .vertical('\'')
+ .horizontal('`')
+ .intersection('\'')
+ .intersection_bottom('\'')
+ .horizontals(vec![HorizontalLine::new(1, Line::full('x', '*', 'q', 'w'))])),
+ " N ' column 0 ' column 1 ' column 2 "
+ "qxxx*xxxxxxxxxx*xxxxxxxxxx*xxxxxxxxxxw"
+ " 0 ' 0-0 ' 0-1 ' 0-2 "
+ " ```'``````````'``````````'`````````` "
+ " 1 ' 1-0 ' 1-1 ' 1-2 "
+ " ```'``````````'``````````'`````````` "
+ " 2 ' 2-0 ' 2-1 ' 2-2 "
+ " ***'**********'**********'********** "
+);
+
+test_table!(
+ style_single_cell_0,
+ Matrix::table(0, 0),
+ "+---+"
+ "| N |"
+ "+---+"
+);
+
+test_table!(
+ style_single_cell_1,
+ Matrix::table(0, 0).with(Style::blank()),
+ " N "
+);
+
+test_table!(
+ top_border_override_first_test,
+ Matrix::table(2, 2).with(BorderText::new("-Table").horizontal(Rows::first())),
+ "-Table---------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+----------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ top_border_override_last_test,
+ Matrix::table(2, 2).with(BorderText::new("-Table").horizontal(Rows::last())),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+----------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "-Table---------+----------+"
+);
+
+test_table!(
+ top_border_override_new_test,
+ Matrix::table(2, 2)
+ .with(BorderText::new("-Table").horizontal(1))
+ .with(BorderText::new("-Table").horizontal(2)),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "-Table---------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "-Table---------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ top_border_override_new_doesnt_panic_when_index_is_invalid,
+ Matrix::table(2, 2).with(BorderText::new("-Table").horizontal(100)),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+----------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ top_override_doesnt_work_with_style_with_no_top_border_test,
+ Matrix::table(2, 2)
+ .with(Style::psql())
+ .with(BorderText::new("-Table").horizontal(Rows::first())),
+ " N | column 0 | column 1 "
+ "---+----------+----------"
+ " 0 | 0-0 | 0-1 "
+ " 1 | 1-0 | 1-1 "
+);
+
+test_table!(
+ top_border_override_cleared_after_restyling_test,
+ Matrix::table(2, 2)
+ .with(BorderText::new("-Table").horizontal(Rows::first()))
+ .with(Style::ascii()),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+----------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ top_border_override_with_big_string_test,
+ Matrix::table(2, 2)
+ .with(BorderText::new("-Tableeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1231").horizontal(Rows::first())),
+ "-Tableeeeeeeeeeeeeeeeeeeeee"
+ "| N | column 0 | column 1 |"
+ "+---+----------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_text_0,
+ Matrix::table(2, 2)
+ .with(Style::empty())
+ .with(Modify::new(Rows::first()).with(Border::default().bottom('-')))
+ .with(BorderText::new("-Table").horizontal(1)),
+ " N column 0 column 1 "
+ "-Table-----------------"
+ " 0 0-0 0-1 "
+ " 1 1-0 1-1 "
+);
+
+test_table!(
+ border_color_global,
+ { Matrix::table(2, 2).with(BorderColor::default().bottom(Color::FG_RED)) },
+ "+---+----------+----------+\n\
+ | N | column 0 | column 1 |\n\
+ +\u{1b}[31m---\u{1b}[39m+\u{1b}[31m----------\u{1b}[39m+\u{1b}[31m----------\u{1b}[39m+\n\
+ | 0 | 0-0 | 0-1 |\n\
+ +\u{1b}[31m---\u{1b}[39m+\u{1b}[31m----------\u{1b}[39m+\u{1b}[31m----------\u{1b}[39m+\n\
+ | 1 | 1-0 | 1-1 |\n\
+ +\u{1b}[31m---\u{1b}[39m+\u{1b}[31m----------\u{1b}[39m+\u{1b}[31m----------\u{1b}[39m+"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ border_text_colored,
+ Matrix::table(2, 2)
+ .with(BorderText::new("-Table").horizontal(1))
+ .with(BorderText::new("-Table213123").horizontal(2))
+ .with(Modify::new(Rows::single(1)).with(BorderColor::default().bottom(Color::FG_RED)))
+ .with(Modify::new(Rows::single(2)).with(BorderColor::default().bottom(Color::try_from(" ".blue().on_green().to_string()).unwrap()))),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "-Table---------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "-\u{1b}[31mTab\u{1b}[39ml\u{1b}[31me213123---\u{1b}[39m+\u{1b}[31m----------\u{1b}[39m+"
+ "| 1 | 1-0 | 1-1 |"
+ "+\u{1b}[34m\u{1b}[42m---\u{1b}[39m\u{1b}[49m+\u{1b}[34m\u{1b}[42m----------\u{1b}[39m\u{1b}[49m+\u{1b}[34m\u{1b}[42m----------\u{1b}[39m\u{1b}[49m+"
+);
+
+test_table!(
+ border_text_offset_test_0,
+ Matrix::table(2, 2).with(BorderText::new("-Table").horizontal(1).offset(Offset::Begin(5))),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+-Table----+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_text_offset_test_1,
+ Matrix::table(2, 2).with(BorderText::new("-Table").horizontal(1).offset(Offset::Begin(15))),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+-----------Table-----+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_text_offset_test_2,
+ Matrix::table(2, 2).with(BorderText::new("Table").horizontal(1).offset(Offset::End(5))),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+----------+------Table"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_text_offset_test_3,
+ Matrix::table(2, 2).with(BorderText::new("Table").horizontal(1).offset(Offset::End(15))),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+-------Table---------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_text_offset_test_4,
+ Matrix::table(2, 2).with(BorderText::new("Table").horizontal(1).offset(Offset::End(21))),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+-Table----+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_text_offset_test_5,
+ Matrix::table(2, 2).with(BorderText::new("Table").horizontal(1).offset(Offset::End(25))),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+-Table--------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_text_offset_test_6,
+ Matrix::table(2, 2).with(BorderText::new("-Table").horizontal(1).offset(Offset::Begin(21))),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+----------+------Table"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_override_color,
+ Matrix::table(2, 2).with(BorderText::new("-Table").horizontal(Rows::first()).color(Color::FG_BLUE)),
+ "\u{1b}[34m-\u{1b}[39m\u{1b}[34mT\u{1b}[39m\u{1b}[34ma\u{1b}[39m\u{1b}[34mb\u{1b}[39m\u{1b}[34ml\u{1b}[39m\u{1b}[34me\u{1b}[39m---------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+----------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ empty_style,
+ Matrix::new(3, 3)
+ .with(Style::empty())
+ .with(Modify::new(Segment::all()).with(Padding::zero())),
+ "Ncolumn 0column 1column 2"
+ "0 0-0 0-1 0-2 "
+ "1 1-0 1-1 1-2 "
+ "2 2-0 2-1 2-2 "
+);
+
+test_table!(
+ single_column_style_0,
+ Matrix::table(2, 0).with(Style::modern()),
+ "┌───┐"
+ "│ N │"
+ "├───┤"
+ "│ 0 │"
+ "├───┤"
+ "│ 1 │"
+ "└───┘"
+);
+
+test_table!(
+ single_column_style_1,
+ Matrix::table(2, 0).with(Style::blank()),
+ " N "
+ " 0 "
+ " 1 "
+);
+
+test_table!(
+ single_column_last_row_style,
+ Matrix::table(3, 0).with(Style::re_structured_text()),
+ "==="
+ " N "
+ "==="
+ " 0 "
+ " 1 "
+ " 2 "
+ "==="
+);
+
+test_table!(
+ single_cell_style,
+ Builder::from_iter([[""]]).build().with(Style::modern()),
+ "┌──┐"
+ "│ │"
+ "└──┘"
+);
+
+test_table!(
+ border_test_0,
+ Matrix::table(2, 2).with(Modify::new(Rows::single(1)).with(Border::filled('*').top('#'))),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "*###*##########*##########*"
+ "* 0 * 0-0 * 0-1 *"
+ "***************************"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_test_1,
+ Matrix::table(2, 2)
+ .with(Style::empty())
+ .with(Modify::new(Rows::single(1)).with(Border::filled('*').top('#'))),
+ " N column 0 column 1 "
+ "*###*##########*##########*"
+ "* 0 * 0-0 * 0-1 *"
+ "***************************"
+ " 1 1-0 1-1 "
+);
+
+test_table!(
+ style_frame_test_0,
+ Matrix::table(2, 2).with(Highlight::new(Rows::single(1), Style::modern().get_frame())),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "┌─────────────────────────┐"
+ "│ 0 | 0-0 | 0-1 │"
+ "└─────────────────────────┘"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ style_frame_test_1,
+ Matrix::table(2, 2)
+ .with(Style::blank())
+ .with(Highlight::new(Rows::single(0), Style::extended().get_frame()))
+ .with(Highlight::new(Rows::single(2), Style::extended().get_frame())),
+ "╔═════════════════════════╗"
+ "║ N column 0 column 1 ║"
+ "╚═════════════════════════╝"
+ " 0 0-0 0-1 "
+ "╔═════════════════════════╗"
+ "║ 1 1-0 1-1 ║"
+ "╚═════════════════════════╝"
+);
+
+test_table!(
+ single_column_off_horizontal_test,
+ Matrix::table(3, 0).with(Style::ascii().remove_horizontal().remove_vertical()),
+ "+---+"
+ "| N |"
+ "| 0 |"
+ "| 1 |"
+ "| 2 |"
+ "+---+"
+);
+
+test_table!(
+ single_row_test,
+ Matrix::table(0, 3).with(Style::modern()),
+ "┌───┬──────────┬──────────┬──────────┐"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "└───┴──────────┴──────────┴──────────┘"
+);
+
+test_table!(
+ empty_border_text_doesnt_panic_test,
+ Matrix::table(2, 2).with(BorderText::new("").horizontal(0)),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+----------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ span_correct_test_0,
+ Matrix::table(6, 4)
+ .with(Modify::new((0, 3)).with(Span::column(2)))
+ .with(Modify::new((1, 0)).with(Span::column(3)))
+ .with(Modify::new((2, 0)).with(Span::column(2)))
+ .with(Modify::new((2, 3)).with(Span::column(2)))
+ .with(Modify::new((3, 0)).with(Span::column(5)))
+ .with(Modify::new((4, 1)).with(Span::column(4)))
+ .with(Modify::new((5, 0)).with(Span::column(5)))
+ .with(Modify::new((6, 0)).with(Span::column(5)))
+ .with(BorderSpanCorrection),
+ "+---+----------+----------+-----------+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+---+----------+----------+-----+-----+"
+ "| 0 | 0-2 | 0-3 |"
+ "+--------------+----------+-----+-----+"
+ "| 1 | 1-1 | 1-2 |"
+ "+--------------+----------+-----------+"
+ "| 2 |"
+ "+---+---------------------------------+"
+ "| 3 | 3-0 |"
+ "+---+---------------------------------+"
+ "| 4 |"
+ "+-------------------------------------+"
+ "| 5 |"
+ "+-------------------------------------+"
+);
+
+test_table!(
+ span_correct_test_1,
+ Matrix::table(6, 4)
+ .with(Modify::new((0, 0)).with(Span::column(5)))
+ .with(Modify::new((1, 0)).with(Span::column(3)))
+ .with(Modify::new((2, 0)).with(Span::column(2)))
+ .with(Modify::new((2, 3)).with(Span::column(2)))
+ .with(Modify::new((3, 0)).with(Span::column(5)))
+ .with(Modify::new((4, 1)).with(Span::column(4)))
+ .with(Modify::new((5, 0)).with(Span::column(5)))
+ .with(Modify::new((6, 0)).with(Span::column(5)))
+ .with(BorderSpanCorrection),
+ "+----------------------+"
+ "| N |"
+ "+----------+-----+-----+"
+ "| 0 | 0-2 | 0-3 |"
+ "+----+-----+-----+-----+"
+ "| 1 | 1-1 | 1-2 |"
+ "+----+-----+-----------+"
+ "| 2 |"
+ "+---+------------------+"
+ "| 3 | 3-0 |"
+ "+---+------------------+"
+ "| 4 |"
+ "+----------------------+"
+ "| 5 |"
+ "+----------------------+"
+);
+
+test_table!(
+ style_settings_usage_test_0,
+ Matrix::new(3, 3)
+ .insert((1, 1), "a longer string")
+ .with({
+ let mut style: RawStyle = Style::modern().into();
+ style
+ .set_bottom(Some('a'))
+ .set_left(Some('b'))
+ .set_right(None)
+ .set_top(None)
+ .set_intersection(Some('x'))
+ .set_intersection_top(None)
+ .set_corner_top_left(None)
+ .set_corner_top_right(None);
+ style
+ }),
+ "b N │ column 0 │ column 1 │ column 2 "
+ "├───x─────────────────x──────────x──────────┤"
+ "b 0 │ a longer string │ 0-1 │ 0-2 "
+ "├───x─────────────────x──────────x──────────┤"
+ "b 1 │ 1-0 │ 1-1 │ 1-2 "
+ "├───x─────────────────x──────────x──────────┤"
+ "b 2 │ 2-0 │ 2-1 │ 2-2 "
+ "└aaa┴aaaaaaaaaaaaaaaaa┴aaaaaaaaaa┴aaaaaaaaaa┘"
+);
+
+test_table!(
+ style_settings_usage_test_1,
+ Matrix::new(3, 3)
+ .insert((1, 1), "a longer string")
+ .with({
+ let mut style: RawStyle = Style::modern().into();
+ style.set_bottom(None);
+ style
+ }),
+ "┌───┬─────────────────┬──────────┬──────────┐"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "├───┼─────────────────┼──────────┼──────────┤"
+ "│ 0 │ a longer string │ 0-1 │ 0-2 │"
+ "├───┼─────────────────┼──────────┼──────────┤"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "├───┼─────────────────┼──────────┼──────────┤"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "└ ┴ ┴ ┴ ┘"
+);
+
+test_table!(
+ style_settings_usage_test_2,
+ Matrix::new(3, 3)
+ .insert((1, 1), "a longer string")
+ .with({
+ let mut style: RawStyle = Style::modern().into();
+ style.set_bottom(None);
+ style
+ })
+ .with(Modify::new(Rows::last()).with(Border::default().corner_bottom_left('*'))),
+ "┌───┬─────────────────┬──────────┬──────────┐"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "├───┼─────────────────┼──────────┼──────────┤"
+ "│ 0 │ a longer string │ 0-1 │ 0-2 │"
+ "├───┼─────────────────┼──────────┼──────────┤"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "├───┼─────────────────┼──────────┼──────────┤"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "* * * * ┘"
+);
+
+test_table!(
+ border_none_test_0,
+ Matrix::table(2, 2)
+ .with(Style::ascii())
+ .with(Modify::new(Rows::single(1)).with(Border::filled('*').top('#')))
+ .with(Modify::new(Rows::single(1)).with(Border::empty())),
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "+---+----------+----------+"
+ "| 0 | 0-0 | 0-1 |"
+ "+---+----------+----------+"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+);
+
+test_table!(
+ border_none_test_1,
+ Matrix::table(2, 2)
+ .with(Style::empty())
+ .with(Modify::new(Rows::single(1)).with(Border::filled('*').top('#')))
+ .with(Modify::new(Columns::single(1)).with(Border::empty())),
+ " N column 0 column 1 "
+ "*### ##########*"
+ "* 0 0-0 0-1 *"
+ "**** ***********"
+ " 1 1-0 1-1 "
+);
+
+#[test]
+fn custom_style_test() {
+ macro_rules! test_style {
+ ($style:expr, $expected:expr $(,)*) => {
+ let table = Matrix::new(3, 3).with($style).to_string();
+ assert_eq!(table, $expected);
+ };
+ }
+
+ // Single
+
+ test_style!(
+ Style::empty().top('-'),
+ static_table!(
+ "---------------------------------"
+ " N column 0 column 1 column 2 "
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ ),
+ );
+ test_style!(
+ Style::empty().bottom('-'),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ "---------------------------------"
+ ),
+ );
+ test_style!(
+ Style::empty().left('-'),
+ static_table!(
+ "- N column 0 column 1 column 2 "
+ "- 0 0-0 0-1 0-2 "
+ "- 1 1-0 1-1 1-2 "
+ "- 2 2-0 2-1 2-2 "
+ ),
+ );
+ test_style!(
+ Style::empty().right('-'),
+ static_table!(
+ " N column 0 column 1 column 2 -"
+ " 0 0-0 0-1 0-2 -"
+ " 1 1-0 1-1 1-2 -"
+ " 2 2-0 2-1 2-2 -"
+ ),
+ );
+ test_style!(
+ Style::empty().horizontal('-'),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ "---------------------------------"
+ " 0 0-0 0-1 0-2 "
+ "---------------------------------"
+ " 1 1-0 1-1 1-2 "
+ "---------------------------------"
+ " 2 2-0 2-1 2-2 "
+ ),
+ );
+ test_style!(
+ Style::empty().horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('-'))]),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ "---------------------------------"
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ ),
+ );
+ test_style!(
+ Style::empty().vertical('-'),
+ static_table!(
+ " N - column 0 - column 1 - column 2 "
+ " 0 - 0-0 - 0-1 - 0-2 "
+ " 1 - 1-0 - 1-1 - 1-2 "
+ " 2 - 2-0 - 2-1 - 2-2 "
+ ),
+ );
+
+ // Combinations
+
+ test_style!(
+ Style::empty().top('-').bottom('+'),
+ static_table!(
+ "---------------------------------"
+ " N column 0 column 1 column 2 "
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ "+++++++++++++++++++++++++++++++++"
+ )
+ );
+ test_style!(
+ Style::empty().top('-').left('+'),
+ static_table!(
+ "+---------------------------------"
+ "+ N column 0 column 1 column 2 "
+ "+ 0 0-0 0-1 0-2 "
+ "+ 1 1-0 1-1 1-2 "
+ "+ 2 2-0 2-1 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty().top('-').right('+'),
+ static_table!(
+ "---------------------------------+"
+ " N column 0 column 1 column 2 +"
+ " 0 0-0 0-1 0-2 +"
+ " 1 1-0 1-1 1-2 +"
+ " 2 2-0 2-1 2-2 +"
+ )
+ );
+ test_style!(
+ Style::empty().top('-').horizontal('+'),
+ static_table!(
+ "---------------------------------"
+ " N column 0 column 1 column 2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 0 0-0 0-1 0-2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 1 1-0 1-1 1-2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 2 2-0 2-1 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty().top('-').vertical('+'),
+ static_table!(
+ "---+----------+----------+----------"
+ " N + column 0 + column 1 + column 2 "
+ " 0 + 0-0 + 0-1 + 0-2 "
+ " 1 + 1-0 + 1-1 + 1-2 "
+ " 2 + 2-0 + 2-1 + 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty()
+ .top('-')
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('+'))]),
+ static_table!(
+ "---------------------------------"
+ " N column 0 column 1 column 2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ );
+
+ test_style!(
+ Style::empty().bottom('-').top('+'),
+ static_table!(
+ "+++++++++++++++++++++++++++++++++"
+ " N column 0 column 1 column 2 "
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ "---------------------------------"
+ )
+ );
+ test_style!(
+ Style::empty().bottom('-').left('+'),
+ static_table!(
+ "+ N column 0 column 1 column 2 "
+ "+ 0 0-0 0-1 0-2 "
+ "+ 1 1-0 1-1 1-2 "
+ "+ 2 2-0 2-1 2-2 "
+ "+---------------------------------"
+ )
+ );
+ test_style!(
+ Style::empty().bottom('-').right('+'),
+ static_table!(
+ " N column 0 column 1 column 2 +"
+ " 0 0-0 0-1 0-2 +"
+ " 1 1-0 1-1 1-2 +"
+ " 2 2-0 2-1 2-2 +"
+ "---------------------------------+"
+ )
+ );
+ test_style!(
+ Style::empty().bottom('-').vertical('+'),
+ static_table!(
+ " N + column 0 + column 1 + column 2 "
+ " 0 + 0-0 + 0-1 + 0-2 "
+ " 1 + 1-0 + 1-1 + 1-2 "
+ " 2 + 2-0 + 2-1 + 2-2 "
+ "---+----------+----------+----------"
+ )
+ );
+ test_style!(
+ Style::empty().bottom('-').horizontal('+'),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 0 0-0 0-1 0-2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 1 1-0 1-1 1-2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 2 2-0 2-1 2-2 "
+ "---------------------------------"
+ )
+ );
+ test_style!(
+ Style::empty()
+ .bottom('-')
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('+'))]),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ "---------------------------------"
+ )
+ );
+
+ test_style!(
+ Style::empty().left('-').top('+'),
+ static_table!(
+ "++++++++++++++++++++++++++++++++++"
+ "- N column 0 column 1 column 2 "
+ "- 0 0-0 0-1 0-2 "
+ "- 1 1-0 1-1 1-2 "
+ "- 2 2-0 2-1 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty().left('-').bottom('+'),
+ static_table!(
+ "- N column 0 column 1 column 2 "
+ "- 0 0-0 0-1 0-2 "
+ "- 1 1-0 1-1 1-2 "
+ "- 2 2-0 2-1 2-2 "
+ "++++++++++++++++++++++++++++++++++"
+ )
+ );
+ test_style!(
+ Style::empty().left('-').right('+'),
+ static_table!(
+ "- N column 0 column 1 column 2 +"
+ "- 0 0-0 0-1 0-2 +"
+ "- 1 1-0 1-1 1-2 +"
+ "- 2 2-0 2-1 2-2 +"
+ )
+ );
+ test_style!(
+ Style::empty().left('-').vertical('+'),
+ static_table!(
+ "- N + column 0 + column 1 + column 2 "
+ "- 0 + 0-0 + 0-1 + 0-2 "
+ "- 1 + 1-0 + 1-1 + 1-2 "
+ "- 2 + 2-0 + 2-1 + 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty().left('-').horizontal('+'),
+ static_table!(
+ "- N column 0 column 1 column 2 "
+ "++++++++++++++++++++++++++++++++++"
+ "- 0 0-0 0-1 0-2 "
+ "++++++++++++++++++++++++++++++++++"
+ "- 1 1-0 1-1 1-2 "
+ "++++++++++++++++++++++++++++++++++"
+ "- 2 2-0 2-1 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty()
+ .left('-')
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('+'))]),
+ static_table!(
+ "- N column 0 column 1 column 2 "
+ " +++++++++++++++++++++++++++++++++"
+ "- 0 0-0 0-1 0-2 "
+ "- 1 1-0 1-1 1-2 "
+ "- 2 2-0 2-1 2-2 "
+ )
+ );
+
+ test_style!(
+ Style::empty().right('-').top('+'),
+ static_table!(
+ "++++++++++++++++++++++++++++++++++"
+ " N column 0 column 1 column 2 -"
+ " 0 0-0 0-1 0-2 -"
+ " 1 1-0 1-1 1-2 -"
+ " 2 2-0 2-1 2-2 -"
+ )
+ );
+ test_style!(
+ Style::empty().right('-').bottom('+'),
+ static_table!(
+ " N column 0 column 1 column 2 -"
+ " 0 0-0 0-1 0-2 -"
+ " 1 1-0 1-1 1-2 -"
+ " 2 2-0 2-1 2-2 -"
+ "++++++++++++++++++++++++++++++++++"
+ )
+ );
+ test_style!(
+ Style::empty().right('-').left('+'),
+ static_table!(
+ "+ N column 0 column 1 column 2 -"
+ "+ 0 0-0 0-1 0-2 -"
+ "+ 1 1-0 1-1 1-2 -"
+ "+ 2 2-0 2-1 2-2 -"
+ )
+ );
+ test_style!(
+ Style::empty().right('-').vertical('+'),
+ static_table!(
+ " N + column 0 + column 1 + column 2 -"
+ " 0 + 0-0 + 0-1 + 0-2 -"
+ " 1 + 1-0 + 1-1 + 1-2 -"
+ " 2 + 2-0 + 2-1 + 2-2 -"
+ )
+ );
+ test_style!(
+ Style::empty().right('-').horizontal('+'),
+ static_table!(
+ " N column 0 column 1 column 2 -"
+ "++++++++++++++++++++++++++++++++++"
+ " 0 0-0 0-1 0-2 -"
+ "++++++++++++++++++++++++++++++++++"
+ " 1 1-0 1-1 1-2 -"
+ "++++++++++++++++++++++++++++++++++"
+ " 2 2-0 2-1 2-2 -"
+ )
+ );
+ test_style!(
+ Style::empty()
+ .right('-')
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('+'))]),
+ static_table!(
+ " N column 0 column 1 column 2 -"
+ "+++++++++++++++++++++++++++++++++ "
+ " 0 0-0 0-1 0-2 -"
+ " 1 1-0 1-1 1-2 -"
+ " 2 2-0 2-1 2-2 -"
+ )
+ );
+
+ test_style!(
+ Style::empty().vertical('-').top('+'),
+ static_table!(
+ "++++++++++++++++++++++++++++++++++++"
+ " N - column 0 - column 1 - column 2 "
+ " 0 - 0-0 - 0-1 - 0-2 "
+ " 1 - 1-0 - 1-1 - 1-2 "
+ " 2 - 2-0 - 2-1 - 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty().vertical('-').bottom('+'),
+ static_table!(
+ " N - column 0 - column 1 - column 2 "
+ " 0 - 0-0 - 0-1 - 0-2 "
+ " 1 - 1-0 - 1-1 - 1-2 "
+ " 2 - 2-0 - 2-1 - 2-2 "
+ "++++++++++++++++++++++++++++++++++++"
+ )
+ );
+ test_style!(
+ Style::empty().vertical('-').left('+'),
+ static_table!(
+ "+ N - column 0 - column 1 - column 2 "
+ "+ 0 - 0-0 - 0-1 - 0-2 "
+ "+ 1 - 1-0 - 1-1 - 1-2 "
+ "+ 2 - 2-0 - 2-1 - 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty().vertical('-').right('+'),
+ static_table!(
+ " N - column 0 - column 1 - column 2 +"
+ " 0 - 0-0 - 0-1 - 0-2 +"
+ " 1 - 1-0 - 1-1 - 1-2 +"
+ " 2 - 2-0 - 2-1 - 2-2 +"
+ )
+ );
+ test_style!(
+ Style::empty().vertical('-').horizontal('+'),
+ static_table!(
+ " N - column 0 - column 1 - column 2 "
+ "++++++++++++++++++++++++++++++++++++"
+ " 0 - 0-0 - 0-1 - 0-2 "
+ "++++++++++++++++++++++++++++++++++++"
+ " 1 - 1-0 - 1-1 - 1-2 "
+ "++++++++++++++++++++++++++++++++++++"
+ " 2 - 2-0 - 2-1 - 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty()
+ .vertical('-')
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('+'))]),
+ static_table!(
+ " N - column 0 - column 1 - column 2 "
+ "+++ ++++++++++ ++++++++++ ++++++++++"
+ " 0 - 0-0 - 0-1 - 0-2 "
+ " 1 - 1-0 - 1-1 - 1-2 "
+ " 2 - 2-0 - 2-1 - 2-2 "
+ )
+ );
+
+ test_style!(
+ Style::empty().horizontal('-').top('+'),
+ static_table!(
+ "+++++++++++++++++++++++++++++++++"
+ " N column 0 column 1 column 2 "
+ "---------------------------------"
+ " 0 0-0 0-1 0-2 "
+ "---------------------------------"
+ " 1 1-0 1-1 1-2 "
+ "---------------------------------"
+ " 2 2-0 2-1 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty().horizontal('-').bottom('+'),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ "---------------------------------"
+ " 0 0-0 0-1 0-2 "
+ "---------------------------------"
+ " 1 1-0 1-1 1-2 "
+ "---------------------------------"
+ " 2 2-0 2-1 2-2 "
+ "+++++++++++++++++++++++++++++++++"
+ )
+ );
+ test_style!(
+ Style::empty().horizontal('-').left('+'),
+ static_table!(
+ "+ N column 0 column 1 column 2 "
+ "+---------------------------------"
+ "+ 0 0-0 0-1 0-2 "
+ "+---------------------------------"
+ "+ 1 1-0 1-1 1-2 "
+ "+---------------------------------"
+ "+ 2 2-0 2-1 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty().horizontal('-').right('+'),
+ static_table!(
+ " N column 0 column 1 column 2 +"
+ "---------------------------------+"
+ " 0 0-0 0-1 0-2 +"
+ "---------------------------------+"
+ " 1 1-0 1-1 1-2 +"
+ "---------------------------------+"
+ " 2 2-0 2-1 2-2 +"
+ )
+ );
+ test_style!(
+ Style::empty().horizontal('-').vertical('+'),
+ static_table!(
+ " N + column 0 + column 1 + column 2 "
+ "---+----------+----------+----------"
+ " 0 + 0-0 + 0-1 + 0-2 "
+ "---+----------+----------+----------"
+ " 1 + 1-0 + 1-1 + 1-2 "
+ "---+----------+----------+----------"
+ " 2 + 2-0 + 2-1 + 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty()
+ .horizontal('-')
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('+'))]),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 0 0-0 0-1 0-2 "
+ "---------------------------------"
+ " 1 1-0 1-1 1-2 "
+ "---------------------------------"
+ " 2 2-0 2-1 2-2 "
+ )
+ );
+
+ test_style!(
+ Style::empty()
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('-'))])
+ .top('+'),
+ static_table!(
+ "+++++++++++++++++++++++++++++++++"
+ " N column 0 column 1 column 2 "
+ "---------------------------------"
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty()
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('-'))])
+ .bottom('+'),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ "---------------------------------"
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ "+++++++++++++++++++++++++++++++++"
+ )
+ );
+ test_style!(
+ Style::empty()
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('-'))])
+ .left('+'),
+ static_table!(
+ "+ N column 0 column 1 column 2 "
+ "+---------------------------------"
+ "+ 0 0-0 0-1 0-2 "
+ "+ 1 1-0 1-1 1-2 "
+ "+ 2 2-0 2-1 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty()
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('-'))])
+ .right('+'),
+ static_table!(
+ " N column 0 column 1 column 2 +"
+ "---------------------------------+"
+ " 0 0-0 0-1 0-2 +"
+ " 1 1-0 1-1 1-2 +"
+ " 2 2-0 2-1 2-2 +"
+ )
+ );
+ test_style!(
+ Style::empty()
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('-'))])
+ .vertical('+'),
+ static_table!(
+ " N + column 0 + column 1 + column 2 "
+ "---+----------+----------+----------"
+ " 0 + 0-0 + 0-1 + 0-2 "
+ " 1 + 1-0 + 1-1 + 1-2 "
+ " 2 + 2-0 + 2-1 + 2-2 "
+ )
+ );
+ test_style!(
+ Style::empty()
+ .horizontals(vec![HorizontalLine::new(1, Line::default()).main(Some('-'))])
+ .horizontal('+'),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ "---------------------------------"
+ " 0 0-0 0-1 0-2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 1 1-0 1-1 1-2 "
+ "+++++++++++++++++++++++++++++++++"
+ " 2 2-0 2-1 2-2 "
+ )
+ );
+
+ // Full
+
+ test_style!(
+ Style::empty()
+ .top('-')
+ .bottom('+')
+ .left('|')
+ .right('*')
+ .horizontal('x')
+ .horizontals(vec![HorizontalLine::new(1, Line::filled('z'))])
+ .vertical('#'),
+ static_table!(
+ "|---#----------#----------#----------*"
+ "| N # column 0 # column 1 # column 2 *"
+ "zzzz#zzzzzzzzzz#zzzzzzzzzz#zzzzzzzzzzz"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "xxxx#xxxxxxxxxx#xxxxxxxxxx#xxxxxxxxxxx"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "xxxx#xxxxxxxxxx#xxxxxxxxxx#xxxxxxxxxxx"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ "|+++#++++++++++#++++++++++#++++++++++*"
+ ),
+ );
+
+ let full_style = Style::empty()
+ .top('-')
+ .bottom('+')
+ .left('|')
+ .right('*')
+ .horizontal('x')
+ .horizontals(vec![HorizontalLine::new(1, Line::filled(','))])
+ .vertical('#')
+ .intersection_bottom('@')
+ .intersection_top('!')
+ .intersection_left('=')
+ .intersection_right('$')
+ .intersection('+')
+ .corner_top_left(';')
+ .corner_bottom_left('?')
+ .corner_top_right('.')
+ .corner_bottom_right('%');
+ test_style!(
+ full_style.clone(),
+ static_table!(
+ ";---!----------!----------!----------."
+ "| N # column 0 # column 1 # column 2 *"
+ ",,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ "?+++@++++++++++@++++++++++@++++++++++%"
+ )
+ );
+
+ // Overwrite intersections and corners
+
+ test_style!(
+ full_style.clone().top('q'),
+ static_table!(
+ "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
+ "| N # column 0 # column 1 # column 2 *"
+ ",,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ "?+++@++++++++++@++++++++++@++++++++++%"
+ )
+ );
+ test_style!(
+ full_style.clone().bottom('q'),
+ static_table!(
+ ";---!----------!----------!----------."
+ "| N # column 0 # column 1 # column 2 *"
+ ",,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
+ )
+ );
+ test_style!(
+ full_style.clone().left('w'),
+ static_table!(
+ "w---!----------!----------!----------."
+ "w N # column 0 # column 1 # column 2 *"
+ "w,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,"
+ "w 0 # 0-0 # 0-1 # 0-2 *"
+ "wxxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "w 1 # 1-0 # 1-1 # 1-2 *"
+ "wxxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "w 2 # 2-0 # 2-1 # 2-2 *"
+ "w+++@++++++++++@++++++++++@++++++++++%"
+ )
+ );
+ test_style!(
+ full_style.clone().right('i'),
+ static_table!(
+ ";---!----------!----------!----------i"
+ "| N # column 0 # column 1 # column 2 i"
+ ",,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,i"
+ "| 0 # 0-0 # 0-1 # 0-2 i"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxxi"
+ "| 1 # 1-0 # 1-1 # 1-2 i"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxxi"
+ "| 2 # 2-0 # 2-1 # 2-2 i"
+ "?+++@++++++++++@++++++++++@++++++++++i"
+ )
+ );
+ test_style!(
+ full_style.clone().horizontal('q'),
+ static_table!(
+ ";---!----------!----------!----------."
+ "| N # column 0 # column 1 # column 2 *"
+ ",,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ "?+++@++++++++++@++++++++++@++++++++++%"
+ )
+ );
+ test_style!(
+ full_style.clone().vertical('q'),
+ static_table!(
+ ";---q----------q----------q----------."
+ "| N q column 0 q column 1 q column 2 *"
+ ",,,,q,,,,,,,,,,q,,,,,,,,,,q,,,,,,,,,,,"
+ "| 0 q 0-0 q 0-1 q 0-2 *"
+ "=xxxqxxxxxxxxxxqxxxxxxxxxxqxxxxxxxxxx$"
+ "| 1 q 1-0 q 1-1 q 1-2 *"
+ "=xxxqxxxxxxxxxxqxxxxxxxxxxqxxxxxxxxxx$"
+ "| 2 q 2-0 q 2-1 q 2-2 *"
+ "?+++q++++++++++q++++++++++q++++++++++%"
+ )
+ );
+ test_style!(
+ full_style
+ .clone()
+ .horizontals(vec![HorizontalLine::new(1, Line::filled('q'))]),
+ static_table!(
+ ";---!----------!----------!----------."
+ "| N # column 0 # column 1 # column 2 *"
+ "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ "?+++@++++++++++@++++++++++@++++++++++%"
+ )
+ );
+
+ // Turn off borders
+
+ let empty_table = static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ );
+ test_style!(Style::empty().top('-').remove_top(), empty_table);
+ test_style!(Style::empty().bottom('-').remove_bottom(), empty_table);
+ test_style!(Style::empty().right('-').remove_right(), empty_table);
+ test_style!(Style::empty().left('-').remove_left(), empty_table);
+ test_style!(
+ Style::empty().horizontal('-').remove_horizontal(),
+ empty_table
+ );
+ test_style!(Style::empty().vertical('-').remove_vertical(), empty_table);
+ test_style!(
+ Style::empty().horizontals(vec![HorizontalLine::new(
+ 1,
+ Line::new(Some('-'), None, None, None)
+ )]),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ "---------------------------------"
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ );
+
+ test_style!(
+ full_style.clone().remove_top(),
+ static_table!(
+ "| N # column 0 # column 1 # column 2 *"
+ ",,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ "?+++@++++++++++@++++++++++@++++++++++%"
+ )
+ );
+ test_style!(
+ full_style.clone().remove_bottom(),
+ static_table!(
+ ";---!----------!----------!----------."
+ "| N # column 0 # column 1 # column 2 *"
+ ",,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ )
+ );
+ test_style!(
+ full_style.clone().remove_right(),
+ static_table!(
+ ";---!----------!----------!----------"
+ "| N # column 0 # column 1 # column 2 "
+ ",,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,"
+ "| 0 # 0-0 # 0-1 # 0-2 "
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx"
+ "| 1 # 1-0 # 1-1 # 1-2 "
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx"
+ "| 2 # 2-0 # 2-1 # 2-2 "
+ "?+++@++++++++++@++++++++++@++++++++++"
+ )
+ );
+ test_style!(
+ full_style.clone().remove_left(),
+ static_table!(
+ "---!----------!----------!----------."
+ " N # column 0 # column 1 # column 2 *"
+ ",,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,"
+ " 0 # 0-0 # 0-1 # 0-2 *"
+ "xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ " 1 # 1-0 # 1-1 # 1-2 *"
+ "xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ " 2 # 2-0 # 2-1 # 2-2 *"
+ "+++@++++++++++@++++++++++@++++++++++%"
+ )
+ );
+ test_style!(
+ full_style.clone().remove_horizontal(),
+ static_table!(
+ ";---!----------!----------!----------."
+ "| N # column 0 # column 1 # column 2 *"
+ ",,,,#,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ "?+++@++++++++++@++++++++++@++++++++++%"
+ )
+ );
+ test_style!(
+ full_style.clone().remove_vertical(),
+ static_table!(
+ ";---------------------------------."
+ "| N column 0 column 1 column 2 *"
+ ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"
+ "| 0 0-0 0-1 0-2 *"
+ "=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx$"
+ "| 1 1-0 1-1 1-2 *"
+ "=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx$"
+ "| 2 2-0 2-1 2-2 *"
+ "?+++++++++++++++++++++++++++++++++%"
+ )
+ );
+ test_style!(
+ full_style.remove_horizontals(),
+ static_table!(
+ ";---!----------!----------!----------."
+ "| N # column 0 # column 1 # column 2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 0 # 0-0 # 0-1 # 0-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 1 # 1-0 # 1-1 # 1-2 *"
+ "=xxx+xxxxxxxxxx+xxxxxxxxxx+xxxxxxxxxx$"
+ "| 2 # 2-0 # 2-1 # 2-2 *"
+ "?+++@++++++++++@++++++++++@++++++++++%"
+ )
+ );
+}
+
+#[test]
+fn test_default_border_usage() {
+ macro_rules! test_border {
+ ($modify:expr, $expected:expr) => {
+ let table = Matrix::new(3, 3)
+ .insert((1, 1), "a longer string")
+ .with(Style::empty())
+ .with($modify)
+ .to_string();
+
+ assert_eq!(table, $expected);
+ };
+ }
+
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().corner_bottom_left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ " * "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().corner_bottom_right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ " * "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().bottom('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ " ********** "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().bottom('*').corner_bottom_left('#')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ " #********** "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().bottom('*').corner_bottom_right('#')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ " **********# "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 * 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().corner_top_left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " * "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().left('#').corner_top_left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " * "
+ " 2 2-0 # 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().left('#').corner_bottom_left('@').corner_top_left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " * "
+ " 2 2-0 # 2-1 2-2 "
+ " @ "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 * 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().corner_top_right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " * "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().right('#').corner_top_right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " * "
+ " 2 2-0 2-1 # 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().right('#').corner_top_right('*').corner_bottom_right('@')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " * "
+ " 2 2-0 2-1 # 2-2 "
+ " @ "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::default().right('#').corner_top_right('*').corner_bottom_left('@')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " * "
+ " 2 2-0 2-1 # 2-2 "
+ " @ "
+ )
+ }
+ test_border! {
+ Modify::new((3, 2)).with(Border::filled('@')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " @@@@@@@@@@@@ "
+ " 2 2-0 @ 2-1 @ 2-2 "
+ " @@@@@@@@@@@@ "
+ )
+ }
+
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().corner_bottom_left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " * "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().corner_bottom_right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " * "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().bottom('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " ********** "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().bottom('*').corner_bottom_left('#')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " #********** "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().bottom('*').corner_bottom_right('#')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " **********# "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string * 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().corner_top_left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " * "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().left('#').corner_top_left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " * "
+ " 0 a longer string # 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().left('#').corner_bottom_left('@').corner_top_left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " * "
+ " 0 a longer string # 0-1 0-2 "
+ " @ "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 * 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().corner_top_right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " * "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().right('#').corner_top_right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " * "
+ " 0 a longer string 0-1 # 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().right('#').corner_top_right('*').corner_bottom_right('@')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " * "
+ " 0 a longer string 0-1 # 0-2 "
+ " @ "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::default().right('#').corner_top_right('*').corner_bottom_left('@')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " * "
+ " 0 a longer string 0-1 # 0-2 "
+ " @ "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((1, 2)).with(Border::filled('@')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " @@@@@@@@@@@@ "
+ " 0 a longer string @ 0-1 @ 0-2 "
+ " @@@@@@@@@@@@ "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().corner_bottom_left('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " * "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().corner_bottom_right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " *"
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().bottom('*')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " **********"
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().bottom('*').corner_bottom_left('#')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " #**********"
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().bottom('*').corner_bottom_right('#')),
+ static_table!(
+ " N column 0 column 1 column 2 "
+ " **********#"
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().left('*')),
+ static_table!(
+ " N column 0 column 1 * column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().corner_top_left('*')),
+ static_table!(
+ " * "
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().left('#').corner_top_left('*')),
+ static_table!(
+ " * "
+ " N column 0 column 1 # column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().left('#').corner_bottom_left('@').corner_top_left('*')),
+ static_table!(
+ " * "
+ " N column 0 column 1 # column 2 "
+ " @ "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().right('*')),
+ static_table!(
+ " N column 0 column 1 column 2 *"
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().corner_top_right('*')),
+ static_table!(
+ " *"
+ " N column 0 column 1 column 2 "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().right('#').corner_top_right('*')),
+ static_table!(
+ " *"
+ " N column 0 column 1 column 2 #"
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().right('#').corner_top_right('*').corner_bottom_right('@')),
+ static_table!(
+ " *"
+ " N column 0 column 1 column 2 #"
+ " @"
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::default().right('#').corner_top_right('*').corner_bottom_left('@')),
+ static_table!(
+ " *"
+ " N column 0 column 1 column 2 #"
+ " @ "
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+ test_border! {
+ Modify::new((0, 3)).with(Border::filled('@')),
+ static_table!(
+ " @@@@@@@@@@@@"
+ " N column 0 column 1 @ column 2 @"
+ " @@@@@@@@@@@@"
+ " 0 a longer string 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ )
+ }
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn border_colored_test() {
+ let table = Matrix::table(2, 2)
+ .with(Style::ascii())
+ .with(
+ Modify::new(Rows::single(1))
+ .with(
+ BorderColor::filled(Color::try_from('*'.blue().to_string()).unwrap())
+ .top(Color::try_from('#'.truecolor(12, 220, 100).to_string()).unwrap()),
+ )
+ .with(Border::filled('*').top('#')),
+ )
+ .to_string();
+
+ assert_eq!(
+ ansi_str::AnsiStr::ansi_strip(&table),
+ static_table!(
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "*###*##########*##########*"
+ "* 0 * 0-0 * 0-1 *"
+ "***************************"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+ )
+ );
+
+ assert_eq!(
+ table,
+ static_table!(
+ "+---+----------+----------+"
+ "| N | column 0 | column 1 |"
+ "\u{1b}[34m*\u{1b}[39m\u{1b}[38;2;12;220;100m###\u{1b}[39m\u{1b}[34m*\u{1b}[39m\u{1b}[38;2;12;220;100m##########\u{1b}[39m\u{1b}[34m*\u{1b}[39m\u{1b}[38;2;12;220;100m##########\u{1b}[39m\u{1b}[34m*\u{1b}[39m"
+ "\u{1b}[34m*\u{1b}[39m 0 \u{1b}[34m*\u{1b}[39m 0-0 \u{1b}[34m*\u{1b}[39m 0-1 \u{1b}[34m*\u{1b}[39m"
+ "\u{1b}[34m***************************\u{1b}[39m"
+ "| 1 | 1-0 | 1-1 |"
+ "+---+----------+----------+"
+ )
+ );
+
+ let table = Matrix::table(2, 2)
+ .with(Style::empty())
+ .with(
+ Modify::new(Rows::single(1))
+ .with(
+ BorderColor::filled(Color::try_from('*'.blue().to_string()).unwrap())
+ .top(Color::try_from('#'.truecolor(12, 220, 100).to_string()).unwrap()),
+ )
+ .with(Border::filled('*').top('#')),
+ )
+ .to_string();
+
+ assert_eq!(
+ ansi_str::AnsiStr::ansi_strip(&table),
+ static_table!(
+ " N column 0 column 1 "
+ "*###*##########*##########*"
+ "* 0 * 0-0 * 0-1 *"
+ "***************************"
+ " 1 1-0 1-1 "
+ )
+ );
+
+ assert_eq!(
+ table,
+ " N column 0 column 1 \n\u{1b}[34m*\u{1b}[39m\u{1b}[38;2;12;220;100m###\u{1b}[39m\u{1b}[34m*\u{1b}[39m\u{1b}[38;2;12;220;100m##########\u{1b}[39m\u{1b}[34m*\u{1b}[39m\u{1b}[38;2;12;220;100m##########\u{1b}[39m\u{1b}[34m*\u{1b}[39m\n\u{1b}[34m*\u{1b}[39m 0 \u{1b}[34m*\u{1b}[39m 0-0 \u{1b}[34m*\u{1b}[39m 0-1 \u{1b}[34m*\u{1b}[39m\n\u{1b}[34m***************************\u{1b}[39m\n 1 1-0 1-1 ",
+ );
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn style_with_color_test() {
+ let mut style: RawStyle = Style::ascii().into();
+ style
+ .set_left(Some('['))
+ .set_right(Some(']'))
+ .set_top(Some('-'))
+ .set_bottom(Some('-'))
+ .set_vertical(Some('|'))
+ .set_intersection(Some('+'));
+ style
+ .set_color_left(Color::FG_RED)
+ .set_color_right(Color::FG_RED)
+ .set_color_top(Color::FG_BLUE)
+ .set_color_bottom(Color::FG_BLUE)
+ .set_color_vertical(Color::FG_YELLOW)
+ .set_color_intersection(Color::try_from(' '.purple().to_string()).unwrap());
+
+ let table = Matrix::new(3, 3).with(style).to_string();
+
+ assert_eq!(
+ ansi_str::AnsiStr::ansi_strip(&table),
+ static_table!(
+ "+---+----------+----------+----------+"
+ "[ N | column 0 | column 1 | column 2 ]"
+ "+---+----------+----------+----------+"
+ "[ 0 | 0-0 | 0-1 | 0-2 ]"
+ "+---+----------+----------+----------+"
+ "[ 1 | 1-0 | 1-1 | 1-2 ]"
+ "+---+----------+----------+----------+"
+ "[ 2 | 2-0 | 2-1 | 2-2 ]"
+ "+---+----------+----------+----------+"
+ )
+ );
+
+ assert_eq!(table, "+\u{1b}[34m---\u{1b}[39m+\u{1b}[34m----------\u{1b}[39m+\u{1b}[34m----------\u{1b}[39m+\u{1b}[34m----------\u{1b}[39m+\n\u{1b}[31m[\u{1b}[39m N \u{1b}[33m|\u{1b}[39m column 0 \u{1b}[33m|\u{1b}[39m column 1 \u{1b}[33m|\u{1b}[39m column 2 \u{1b}[31m]\u{1b}[39m\n+---\u{1b}[35m+\u{1b}[39m----------\u{1b}[35m+\u{1b}[39m----------\u{1b}[35m+\u{1b}[39m----------+\n\u{1b}[31m[\u{1b}[39m 0 \u{1b}[33m|\u{1b}[39m 0-0 \u{1b}[33m|\u{1b}[39m 0-1 \u{1b}[33m|\u{1b}[39m 0-2 \u{1b}[31m]\u{1b}[39m\n+---\u{1b}[35m+\u{1b}[39m----------\u{1b}[35m+\u{1b}[39m----------\u{1b}[35m+\u{1b}[39m----------+\n\u{1b}[31m[\u{1b}[39m 1 \u{1b}[33m|\u{1b}[39m 1-0 \u{1b}[33m|\u{1b}[39m 1-1 \u{1b}[33m|\u{1b}[39m 1-2 \u{1b}[31m]\u{1b}[39m\n+---\u{1b}[35m+\u{1b}[39m----------\u{1b}[35m+\u{1b}[39m----------\u{1b}[35m+\u{1b}[39m----------+\n\u{1b}[31m[\u{1b}[39m 2 \u{1b}[33m|\u{1b}[39m 2-0 \u{1b}[33m|\u{1b}[39m 2-1 \u{1b}[33m|\u{1b}[39m 2-2 \u{1b}[31m]\u{1b}[39m\n+\u{1b}[34m---\u{1b}[39m+\u{1b}[34m----------\u{1b}[39m+\u{1b}[34m----------\u{1b}[39m+\u{1b}[34m----------\u{1b}[39m+");
+}
+
+test_table!(
+ empty_line_clears_lines,
+ Matrix::new(3, 3).with(Style::rounded().remove_horizontals()),
+ "╭───┬──────────┬──────────┬──────────╮"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "╰───┴──────────┴──────────┴──────────╯"
+);
+
+test_table!(
+ empty_line_clears_lines_1,
+ Matrix::new(3, 3).with(Style::rounded().remove_horizontals()),
+ "╭───┬──────────┬──────────┬──────────╮"
+ "│ N │ column 0 │ column 1 │ column 2 │"
+ "│ 0 │ 0-0 │ 0-1 │ 0-2 │"
+ "│ 1 │ 1-0 │ 1-1 │ 1-2 │"
+ "│ 2 │ 2-0 │ 2-1 │ 2-2 │"
+ "╰───┴──────────┴──────────┴──────────╯"
+);
+
+test_table!(
+ border_color,
+ {
+ use tabled::settings::Color;
+ Matrix::new(3, 3).with(Style::psql()).with(Color::BG_GREEN)
+ },
+ " \u{1b}[42mN\u{1b}[49m | \u{1b}[42mcolumn 0\u{1b}[49m | \u{1b}[42mcolumn 1\u{1b}[49m | \u{1b}[42mcolumn 2\u{1b}[49m \n---+----------+----------+----------\n \u{1b}[42m0\u{1b}[49m | \u{1b}[42m0-0\u{1b}[49m | \u{1b}[42m0-1\u{1b}[49m | \u{1b}[42m0-2\u{1b}[49m \n \u{1b}[42m1\u{1b}[49m | \u{1b}[42m1-0\u{1b}[49m | \u{1b}[42m1-1\u{1b}[49m | \u{1b}[42m1-2\u{1b}[49m \n \u{1b}[42m2\u{1b}[49m | \u{1b}[42m2-0\u{1b}[49m | \u{1b}[42m2-1\u{1b}[49m | \u{1b}[42m2-2\u{1b}[49m "
+);
+
+test_table!(
+ text_color,
+ {
+ use tabled::settings::Color;
+ Matrix::new(3, 3).with(Style::psql()).with(Modify::new(Segment::all()).with(Color::BG_BLACK))
+ },
+ " \u{1b}[40mN\u{1b}[49m | \u{1b}[40mcolumn 0\u{1b}[49m | \u{1b}[40mcolumn 1\u{1b}[49m | \u{1b}[40mcolumn 2\u{1b}[49m \n---+----------+----------+----------\n \u{1b}[40m0\u{1b}[49m | \u{1b}[40m0-0\u{1b}[49m | \u{1b}[40m0-1\u{1b}[49m | \u{1b}[40m0-2\u{1b}[49m \n \u{1b}[40m1\u{1b}[49m | \u{1b}[40m1-0\u{1b}[49m | \u{1b}[40m1-1\u{1b}[49m | \u{1b}[40m1-2\u{1b}[49m \n \u{1b}[40m2\u{1b}[49m | \u{1b}[40m2-0\u{1b}[49m | \u{1b}[40m2-1\u{1b}[49m | \u{1b}[40m2-2\u{1b}[49m "
+);
+
+test_table!(
+ verticals_0,
+ Matrix::new(3, 3)
+ .with(Style::rounded().verticals(vec![VerticalLine::new(0, Line::filled('+')), VerticalLine::new(4, Line::filled('+'))])),
+ "+───┬──────────┬──────────┬──────────+"
+ "+ N │ column 0 │ column 1 │ column 2 +"
+ "├───┼──────────┼──────────┼──────────┤"
+ "+ 0 │ 0-0 │ 0-1 │ 0-2 +"
+ "+ 1 │ 1-0 │ 1-1 │ 1-2 +"
+ "+ 2 │ 2-0 │ 2-1 │ 2-2 +"
+ "+───┴──────────┴──────────┴──────────+"
+);
+
+test_table!(
+ verticals_1,
+ Matrix::new(3, 3)
+ .with(Style::rounded().verticals((1..4).map(|i| VerticalLine::new(i, Line::filled('+'))))),
+ "╭───+──────────+──────────+──────────╮"
+ "│ N + column 0 + column 1 + column 2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 0 + 0-0 + 0-1 + 0-2 │"
+ "│ 1 + 1-0 + 1-1 + 1-2 │"
+ "│ 2 + 2-0 + 2-1 + 2-2 │"
+ "╰───+──────────+──────────+──────────╯"
+);
+
+test_table!(
+ verticals_2,
+ Matrix::new(3, 3).with(Style::rounded().verticals(vec![VerticalLine::new(1, Line::filled('+'))])),
+ "╭───+──────────┬──────────┬──────────╮"
+ "│ N + column 0 │ column 1 │ column 2 │"
+ "├───┼──────────┼──────────┼──────────┤"
+ "│ 0 + 0-0 │ 0-1 │ 0-2 │"
+ "│ 1 + 1-0 │ 1-1 │ 1-2 │"
+ "│ 2 + 2-0 │ 2-1 │ 2-2 │"
+ "╰───+──────────┴──────────┴──────────╯"
+);
+
+test_table!(
+ verticals_3,
+ Matrix::new(3, 3).with(Style::ascii().verticals([VerticalLine::new(1, Line::filled('*'))])),
+ "+---*----------+----------+----------+"
+ "| N * column 0 | column 1 | column 2 |"
+ "+---*----------+----------+----------+"
+ "| 0 * 0-0 | 0-1 | 0-2 |"
+ "+---*----------+----------+----------+"
+ "| 1 * 1-0 | 1-1 | 1-2 |"
+ "+---*----------+----------+----------+"
+ "| 2 * 2-0 | 2-1 | 2-2 |"
+ "+---*----------+----------+----------+"
+);
+
+test_table!(
+ verticals_4,
+ Matrix::new(3, 3).with(Style::ascii().verticals((0..10).map(|i| VerticalLine::new(i, Line::new(Some('*'), Some('x'), Some('c'), Some('2')))))),
+ "c---c----------c----------c----------c"
+ "* N * column 0 * column 1 * column 2 *"
+ "x---x----------x----------x----------x"
+ "* 0 * 0-0 * 0-1 * 0-2 *"
+ "x---x----------x----------x----------x"
+ "* 1 * 1-0 * 1-1 * 1-2 *"
+ "x---x----------x----------x----------x"
+ "* 2 * 2-0 * 2-1 * 2-2 *"
+ "2---2----------2----------2----------2"
+);
+
+test_table!(
+ vertical_line_0,
+ Matrix::new(3, 3)
+ .with(HorizontalLine::new(1, Line::new(Some('8'), Some('8'), Some('8'), Some('8'))))
+ .with(VerticalLine::new(1, Line::new(Some('*'), Some('x'), Some('c'), Some('2')))),
+ "+---c----------+----------+----------+"
+ "| N * column 0 | column 1 | column 2 |"
+ "88888888888888888888888888888888888888"
+ "| 0 * 0-0 | 0-1 | 0-2 |"
+ "+---x----------+----------+----------+"
+ "| 1 * 1-0 | 1-1 | 1-2 |"
+ "+---x----------+----------+----------+"
+ "| 2 * 2-0 | 2-1 | 2-2 |"
+ "+---2----------+----------+----------+"
+);
+
+test_table!(
+ vertical_line_1,
+ Matrix::new(3, 3)
+ .with(Style::empty())
+ .with(VerticalLine::new(1, Line::new(Some('*'), Some('x'), Some('c'), Some('2')))),
+ " c "
+ " N * column 0 column 1 column 2 "
+ " 0 * 0-0 0-1 0-2 "
+ " 1 * 1-0 1-1 1-2 "
+ " 2 * 2-0 2-1 2-2 "
+ " 2 "
+);
+
+test_table!(
+ vertical_line_2,
+ Matrix::new(3, 3)
+ .with(Style::empty())
+ .with(VerticalLine::new(1, Line::new(None, Some('x'), Some('c'), Some('2')))),
+ " c "
+ " N column 0 column 1 column 2 "
+ " 0 0-0 0-1 0-2 "
+ " 1 1-0 1-1 1-2 "
+ " 2 2-0 2-1 2-2 "
+ " 2 "
+);
+
+test_table!(
+ vertical_line_3,
+ Matrix::new(3, 3)
+ .with(Style::empty())
+ .with(VerticalLine::new(1, Line::new(Some('*'), Some('x'), None, None))),
+ " N * column 0 column 1 column 2 "
+ " 0 * 0-0 0-1 0-2 "
+ " 1 * 1-0 1-1 1-2 "
+ " 2 * 2-0 2-1 2-2 "
+);
+
+test_table!(
+ override_horizontal_border_on_line,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Rows::single(1))
+ .with(BorderChar::horizontal(':', Offset::Begin(0)))
+ .with(BorderChar::horizontal(':', Offset::End(0)))
+ ),
+ "| N | column 0 | column 1 | column 2 |"
+ "|:-:|:--------:|:--------:|:--------:|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ override_horizontal_border_on_borders,
+ Matrix::new(3, 3)
+ .with(Modify::new(Rows::new(..5))
+ .with(BorderChar::horizontal(':', Offset::Begin(0)))
+ .with(BorderChar::horizontal('y', Offset::Begin(3)))
+ .with(BorderChar::horizontal(':', Offset::End(0)))
+ .with(BorderChar::horizontal('x', Offset::End(3)))
+ ),
+ "+:-:+:--y--x--:+:--y--x--:+:--y--x--:+"
+ "| N | column 0 | column 1 | column 2 |"
+ "+:-:+:--y--x--:+:--y--x--:+:--y--x--:+"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "+:-:+:--y--x--:+:--y--x--:+:--y--x--:+"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "+:-:+:--y--x--:+:--y--x--:+:--y--x--:+"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ "+:-:+:--y--x--:+:--y--x--:+:--y--x--:+"
+);
+
+test_table!(
+ override_horizontal_border_on_border,
+ Matrix::new(3, 3)
+ .with(Modify::new(Rows::new(..5))
+ .with(Border::filled('['))
+ .with(BorderChar::horizontal(':', Offset::Begin(0)))
+ .with(BorderChar::horizontal('y', Offset::Begin(3)))
+ .with(BorderChar::horizontal(':', Offset::End(0)))
+ .with(BorderChar::horizontal('x', Offset::End(3)))
+ ),
+ "[:[:[:[[y[[x[[:[:[[y[[x[[:[:[[y[[x[[:["
+ "[ N [ column 0 [ column 1 [ column 2 ["
+ "[:[:[:[[y[[x[[:[:[[y[[x[[:[:[[y[[x[[:["
+ "[ 0 [ 0-0 [ 0-1 [ 0-2 ["
+ "[:[:[:[[y[[x[[:[:[[y[[x[[:[:[[y[[x[[:["
+ "[ 1 [ 1-0 [ 1-1 [ 1-2 ["
+ "[:[:[:[[y[[x[[:[:[[y[[x[[:[:[[y[[x[[:["
+ "[ 2 [ 2-0 [ 2-1 [ 2-2 ["
+ "[:[:[:[[y[[x[[:[:[[y[[x[[:[:[[y[[x[[:["
+);
+
+test_table!(
+ override_vertical_border_on_line,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::single(1))
+ .with(BorderChar::vertical(':', Offset::Begin(0)))
+ ),
+ "| N : column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 : 0-0 | 0-1 | 0-2 |"
+ "| 1 : 1-0 | 1-1 | 1-2 |"
+ "| 2 : 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ override_vertical_border_on_line_1,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::single(1))
+ .with(BorderChar::vertical(':', Offset::End(0)))
+ ),
+ "| N : column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 : 0-0 | 0-1 | 0-2 |"
+ "| 1 : 1-0 | 1-1 | 1-2 |"
+ "| 2 : 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ override_vertical_border_on_line_multiline,
+ Matrix::new(3, 3)
+ .with(Modify::new(Rows::single(1)).with(Format::content(|s| format!("\nsome text\ntext\n{s}\ntext\ntext\n"))))
+ .with(Style::markdown())
+ .with(Modify::new(Columns::single(1))
+ .with(BorderChar::vertical(':', Offset::Begin(4)))
+ ),
+ "| N | column 0 | column 1 | column 2 |"
+ "|-----------|-----------|-----------|-----------|"
+ "| | | | |"
+ "| some text | some text | some text | some text |"
+ "| text | text | text | text |"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| text : text | text | text |"
+ "| text | text | text | text |"
+ "| | | | |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ override_vertical_border_on_line_multiline_2,
+ Matrix::new(3, 3)
+ .with(Modify::new(Rows::single(1)).with(Format::content(|s| format!("\nsome text\ntext\n{s}\ntext\ntext\n"))))
+ .with(Style::markdown())
+ .with(Modify::new(Columns::single(1))
+ .with(BorderChar::vertical(':', Offset::End(4)))
+ ),
+ "| N | column 0 | column 1 | column 2 |"
+ "|-----------|-----------|-----------|-----------|"
+ "| | | | |"
+ "| some text | some text | some text | some text |"
+ "| text : text | text | text |"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| text | text | text | text |"
+ "| text | text | text | text |"
+ "| | | | |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ override_vertical_and_horizontal_border_on_line,
+ Matrix::new(3, 3)
+ .with(Modify::new(Rows::single(1)).with(Format::content(|s| format!("\nsome text\ntext\n{s}\ntext\ntext\n"))))
+ .with(Style::markdown())
+ .with(Modify::new(Columns::new(..5))
+ .with(BorderChar::vertical('y', Offset::Begin(0)))
+ .with(BorderChar::vertical('^', Offset::End(0)))
+ )
+ .with(Modify::new(Rows::single(1))
+ .with(BorderChar::horizontal('x', Offset::Begin(0)))
+ .with(BorderChar::horizontal('@', Offset::End(0)))
+ ),
+ "y N y column 0 y column 1 y column 2 y"
+ "|x---------@|x---------@|x---------@|x---------@|"
+ "y y y y y"
+ "| some text | some text | some text | some text |"
+ "| text | text | text | text |"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| text | text | text | text |"
+ "| text | text | text | text |"
+ "^ ^ ^ ^ ^"
+ "y 1 y 1-0 y 1-1 y 1-2 y"
+ "y 2 y 2-0 y 2-1 y 2-2 y"
+);
+
+test_table!(
+ table_format_alignment_left_test,
+ format!("{:<}", Table::new(vec!["hello", "world", "!"])),
+ "+-------+"
+ "| &str |"
+ "+-------+"
+ "| hello |"
+ "+-------+"
+ "| world |"
+ "+-------+"
+ "| ! |"
+ "+-------+"
+);
+
+test_table!(
+ table_format_alignment_right_test,
+ format!("{:>}", Table::new(vec!["hello", "world", "!"])),
+ "+-------+"
+ "| &str |"
+ "+-------+"
+ "| hello |"
+ "+-------+"
+ "| world |"
+ "+-------+"
+ "| ! |"
+ "+-------+"
+);
+
+test_table!(
+ table_format_alignment_center_test,
+ format!("{:^}", Table::new(vec!["hello", "world", "!"])),
+ "+-------+"
+ "| &str |"
+ "+-------+"
+ "| hello |"
+ "+-------+"
+ "| world |"
+ "+-------+"
+ "| ! |"
+ "+-------+"
+);
+
+test_table!(
+ table_format_width_0_test,
+ format!("{:<13}", Table::new(vec!["hello", "world", "!"])),
+ " +-------+"
+ " | &str |"
+ " +-------+"
+ " | hello |"
+ " +-------+"
+ " | world |"
+ " +-------+"
+ " | ! |"
+ " +-------+"
+);
+
+test_table!(
+ table_format_width_1_test,
+ format!("{:>13}", Table::new(vec!["hello", "world", "!"])),
+ "+-------+ "
+ "| &str | "
+ "+-------+ "
+ "| hello | "
+ "+-------+ "
+ "| world | "
+ "+-------+ "
+ "| ! | "
+ "+-------+ "
+);
+
+test_table!(
+ table_format_width_2_test,
+ format!("{:^13}", Table::new(vec!["hello", "world", "!"])),
+ " +-------+ "
+ " | &str | "
+ " +-------+ "
+ " | hello | "
+ " +-------+ "
+ " | world | "
+ " +-------+ "
+ " | ! | "
+ " +-------+ "
+);
+
+test_table!(
+ table_format_width_3_test,
+ format!("{:x^13}", Table::new(vec!["hello", "world", "!"])),
+ "xx+-------+xx"
+ "xx| &str |xx"
+ "xx+-------+xx"
+ "xx| hello |xx"
+ "xx+-------+xx"
+ "xx| world |xx"
+ "xx+-------+xx"
+ "xx| ! |xx"
+ "xx+-------+xx"
+);
+
+test_table!(
+ table_format_width_4_test,
+ format!("{:x<13}", Table::new(vec!["hello", "world", "!"])),
+ "xxxx+-------+"
+ "xxxx| &str |"
+ "xxxx+-------+"
+ "xxxx| hello |"
+ "xxxx+-------+"
+ "xxxx| world |"
+ "xxxx+-------+"
+ "xxxx| ! |"
+ "xxxx+-------+"
+);
+
+test_table!(
+ table_format_width_5_test,
+ format!("{:x>13}", Table::new(vec!["hello", "world", "!"])),
+ "+-------+xxxx"
+ "| &str |xxxx"
+ "+-------+xxxx"
+ "| hello |xxxx"
+ "+-------+xxxx"
+ "| world |xxxx"
+ "+-------+xxxx"
+ "| ! |xxxx"
+ "+-------+xxxx"
+);
+
+test_table!(
+ table_style_no_bottom_no_new_line,
+ Matrix::table(0, 0).with(Style::markdown().remove_horizontals()),
+ "| N |"
+);
diff --git a/vendor/tabled/tests/settings/width_test.rs b/vendor/tabled/tests/settings/width_test.rs
new file mode 100644
index 000000000..d2bc84a46
--- /dev/null
+++ b/vendor/tabled/tests/settings/width_test.rs
@@ -0,0 +1,2836 @@
+#![cfg(feature = "std")]
+
+use tabled::{
+ grid::util::string::string_width_multiline,
+ settings::{
+ formatting::{TabSize, TrimStrategy},
+ object::{Columns, Object, Rows, Segment},
+ peaker::{PriorityMax, PriorityMin},
+ width::{Justify, MinWidth, SuffixLimit, Width},
+ Alignment, Margin, Modify, Padding, Panel, Settings, Span, Style,
+ },
+};
+
+use crate::matrix::Matrix;
+use testing_table::{is_lines_equal, static_table, test_table};
+
+#[cfg(feature = "color")]
+use ::{ansi_str::AnsiStr, owo_colors::OwoColorize};
+
+#[cfg(all(feature = "derive", feature = "color"))]
+use ::owo_colors::AnsiColors;
+
+test_table!(
+ max_width,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::new(1..).not(Rows::single(0))).with(Width::truncate(1))),
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0 | 0 | 0 |"
+ "| 1 | 1 | 1 | 1 |"
+ "| 2 | 2 | 2 | 2 |"
+);
+
+test_table!(
+ max_width_with_suffix,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(
+ Modify::new(Columns::new(1..).not(Rows::single(0)))
+ .with(Width::truncate(2).suffix("...")),
+ ),
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | .. | .. | .. |"
+ "| 1 | .. | .. | .. |"
+ "| 2 | .. | .. | .. |"
+);
+
+test_table!(
+ max_width_doesnt_icrease_width_if_it_is_smaller,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::new(1..).not(Rows::single(0))).with(Width::truncate(50))),
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ max_width_wrapped,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::new(1..).not(Rows::single(0))).with(Width::wrap(2))),
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0- | 0- | 0- |"
+ "| | 0 | 1 | 2 |"
+ "| 1 | 1- | 1- | 1- |"
+ "| | 0 | 1 | 2 |"
+ "| 2 | 2- | 2- | 2- |"
+ "| | 0 | 1 | 2 |"
+);
+
+test_table!(
+ max_width_wrapped_does_nothing_if_str_is_smaller,
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Columns::new(1..).not(Rows::single(0))).with(Width::wrap(100))),
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+);
+
+test_table!(
+ max_width_wrapped_keep_words_0,
+ {
+ let table = Matrix::iter(vec!["this is a long sentence"])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ assert!(is_lines_equal(&table, 17 + 2 + 2));
+
+ table
+ },
+ "| &str |"
+ "|-------------------|"
+ "| this is a long |"
+ "| sentence |"
+);
+
+test_table!(
+ max_width_wrapped_keep_words_1,
+ {
+ let table = Matrix::iter(vec!["this is a long sentence"])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ assert!(is_lines_equal(&table, 17 + 2 + 2));
+
+ table
+ },
+ "| &str |"
+ "|-------------------|"
+ "| this is a long |"
+ "| sentence |"
+);
+
+test_table!(
+ max_width_wrapped_keep_words_2,
+ {
+ let table = Matrix::iter(vec!["this is a long sentence"])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ assert!(is_lines_equal(&table, 17 + 2 + 2));
+
+ table
+ },
+ "| &str |"
+ "|-------------------|"
+ "| this is a long |"
+ "| sentence |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_3,
+ {
+ let table = Matrix::iter(vec!["this is a long sentence"])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ assert!(is_lines_equal(&table, 17 + 2 + 2));
+
+ table
+ },
+ // 'sentence' doesn't have a space ' sentence' because we use left alignment
+ "| &str |"
+ "|-------------------|"
+ "| this is a long |"
+ "| sentence |"
+);
+
+#[cfg(not(feature = "color"))]
+test_table!(
+ max_width_wrapped_keep_words_3,
+ {
+ let table = Matrix::iter(vec!["this is a long sentence"])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ assert!(is_lines_equal(&table, 17 + 2 + 2));
+
+ table
+ },
+ // 'sentence' doesn't have a space ' sentence' because we use left alignment
+ "| &str |"
+ "|-------------------|"
+ "| this is a long |"
+ "| sentence |"
+);
+
+test_table!(
+ max_width_wrapped_keep_words_4,
+ {
+ let table = Matrix::iter(vec!["this"])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Width::wrap(10).keep_words()))
+ .to_string();
+
+ assert!(is_lines_equal(&table, 8));
+
+ table
+ },
+ "| &str |"
+ "|------|"
+ "| this |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_0,
+ {
+ let table = Matrix::iter(vec!["this is a long sentence".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ AnsiStr::ansi_strip(&table).to_string()
+ },
+ "| String |"
+ "|-------------------|"
+ "| this is a long |"
+ "| sentence |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_0_1,
+ Matrix::iter(vec!["this is a long sentence".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words())),
+ "| String |"
+ "|-------------------|"
+ "| \u{1b}[32m\u{1b}[40mthis is a long \u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[32m\u{1b}[40msentence\u{1b}[39m\u{1b}[49m |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_1,
+ {
+ let table = Matrix::iter(vec!["this is a long sentence".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ AnsiStr::ansi_strip(&table).to_string()
+ },
+ "| String |"
+ "|-------------------|"
+ "| this is a long |"
+ "| sentence |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_1_1,
+ Matrix::iter(vec!["this is a long sentence".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words())),
+ "| String |"
+ "|-------------------|"
+ "| \u{1b}[32m\u{1b}[40mthis is a long \u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[32m\u{1b}[40msentence\u{1b}[39m\u{1b}[49m |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_2,
+ {
+ let table = Matrix::iter(vec!["this is a long sentence".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ AnsiStr::ansi_strip(&table).to_string()
+ },
+ "| String |"
+ "|-------------------|"
+ "| this is a long |"
+ "| sentence |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_2_1,
+ Matrix::iter(vec!["this is a long sentence".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words())),
+ "| String |"
+ "|-------------------|"
+ "| \u{1b}[32m\u{1b}[40mthis is a long \u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[32m\u{1b}[40msentence\u{1b}[39m\u{1b}[49m |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_3,
+ {
+ let table = Matrix::iter(vec!["this is a long sentence".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ AnsiStr::ansi_strip(&table).to_string()
+ },
+ "| String |"
+ "|-------------------|"
+ "| this is a long |"
+ "| sentence |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_3_1,
+ Matrix::iter(vec!["this is a long sentence".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words())),
+ "| String |"
+ "|-------------------|"
+ "| \u{1b}[32m\u{1b}[40mthis is a long \u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[32m\u{1b}[40m sentence\u{1b}[39m\u{1b}[49m |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_4,
+ {
+ let table = Matrix::iter(vec!["this".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Width::wrap(10).keep_words()))
+ .to_string();
+
+ AnsiStr::ansi_strip(&table).to_string()
+ },
+ "| String |"
+ "|--------|"
+ "| this |"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ max_width_wrapped_keep_words_color_4_1,
+ Matrix::iter(vec!["this".on_black().green().to_string()])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Width::wrap(10).keep_words())),
+ "| String |"
+ "|--------|"
+ "| \u{1b}[32;40mthis\u{1b}[0m |"
+);
+
+test_table!(
+ max_width_wrapped_keep_words_long_word,
+ Matrix::iter(["this is a long sentencesentencesentence"])
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words())),
+ "| &str |"
+ "|-------------------|"
+ "| this is a long se |"
+ "| ntencesentencesen |"
+ "| tence |"
+);
+
+#[cfg(feature = "color")]
+#[test]
+fn max_width_wrapped_keep_words_long_word_color() {
+ let data = vec!["this is a long sentencesentencesentence"
+ .on_black()
+ .green()
+ .to_string()];
+ let table = Matrix::iter(data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Modify::new(Segment::all()).with(Width::wrap(17).keep_words()))
+ .to_string();
+
+ assert_eq!(
+ ansi_str::AnsiStr::ansi_strip(&table),
+ static_table!(
+ "| String |"
+ "|-------------------|"
+ "| this is a long se |"
+ "| ntencesentencesen |"
+ "| tence |"
+ )
+ );
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| String |"
+ "|-------------------|"
+ "| \u{1b}[32m\u{1b}[40mthis is a long se\u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[32m\u{1b}[40mntencesentencesen\u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[32m\u{1b}[40mtence\u{1b}[39m\u{1b}[49m |"
+ )
+ );
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn max_width_keep_words_1() {
+ use tabled::settings::style::HorizontalLine;
+
+ let table = Matrix::iter(["asdf"])
+ .with(Width::wrap(7).keep_words())
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "+-----+"
+ "| &st |"
+ "| r |"
+ "+-----+"
+ "| asd |"
+ "| f |"
+ "+-----+"
+ )
+ );
+
+ let table = Matrix::iter(["qweqw eqwe"])
+ .with(Width::wrap(8).keep_words())
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "+------+"
+ "| &str |"
+ "+------+"
+ "| qweq |"
+ "| w |"
+ "| eqwe |"
+ "+------+"
+ )
+ );
+
+ let table = Matrix::iter([
+ ["123 45678", "qweqw eqwe", "..."],
+ ["0", "1", "..."],
+ ["0", "1", "..."],
+ ])
+ .with(
+ Style::modern()
+ .remove_horizontal()
+ .horizontals([HorizontalLine::new(1, Style::modern().get_horizontal())]),
+ )
+ .with(Width::wrap(21).keep_words().priority::<PriorityMax>())
+ .with(Alignment::center())
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "┌──────┬──────┬─────┐"
+ "│ 0 │ 1 │ 2 │"
+ "├──────┼──────┼─────┤"
+ "│ 123 │ qweq │ ... │"
+ "│ 4567 │ w │ │"
+ "│ 8 │ eqwe │ │"
+ "│ 0 │ 1 │ ... │"
+ "│ 0 │ 1 │ ... │"
+ "└──────┴──────┴─────┘"
+ )
+ );
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn max_width_wrapped_collored() {
+ let data = &[
+ "asd".red().to_string(),
+ "zxc2".blue().to_string(),
+ "asdasd".on_black().green().to_string(),
+ ];
+
+ let table = Matrix::iter(data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Width::wrap(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ "| St |\n| ri |\n| ng |\n|----|\n| \u{1b}[31mas\u{1b}[39m |\n| \u{1b}[31md\u{1b}[39m |\n| \u{1b}[34mzx\u{1b}[39m |\n| \u{1b}[34mc2\u{1b}[39m |\n| \u{1b}[32m\u{1b}[40mas\u{1b}[39m\u{1b}[49m |\n| \u{1b}[32m\u{1b}[40mda\u{1b}[39m\u{1b}[49m |\n| \u{1b}[32m\u{1b}[40msd\u{1b}[39m\u{1b}[49m |"
+ );
+}
+
+#[test]
+fn dont_change_content_if_width_is_less_then_max_width() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Width::truncate(1000).suffix("...")))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn max_width_with_emoji() {
+ let data = &["🤠", "😳🥵🥶😱😨", "🚴🏻‍♀️🚴🏻🚴🏻‍♂️🚵🏻‍♀️🚵🏻🚵🏻‍♂️"];
+
+ let table = Matrix::iter(data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Width::truncate(6).suffix("...")))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| &str |"
+ "|--------|"
+ "| 🤠 |"
+ "| 😳�... |"
+ "| 🚴�... |"
+ )
+ );
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn color_chars_are_stripped() {
+ let data = &[
+ "asd".red().to_string(),
+ "zxc".blue().to_string(),
+ "asdasd".on_black().green().to_string(),
+ ];
+
+ let table = Matrix::iter(data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Width::truncate(4).suffix("...")))
+ .to_string();
+
+ assert_eq!(
+ ansi_str::AnsiStr::ansi_strip(&table),
+ static_table!(
+ "| S... |"
+ "|------|"
+ "| asd |"
+ "| zxc |"
+ "| a... |"
+ )
+ );
+
+ assert_eq!(
+ table,
+ "| S... |\n|------|\n| \u{1b}[31masd\u{1b}[39m |\n| \u{1b}[34mzxc\u{1b}[39m |\n| \u{1b}[32;40ma\u{1b}[39m\u{1b}[49m... |",
+ );
+}
+
+#[test]
+fn min_width() {
+ let mut table = Matrix::table(3, 3);
+ table
+ .with(Style::markdown())
+ .with(Modify::new(Rows::single(0)).with(MinWidth::new(12)));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|--------------|--------------|--------------|--------------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ ),
+ );
+
+ table.with(Modify::new(Segment::all()).with(TrimStrategy::None));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|--------------|--------------|--------------|--------------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ ),
+ );
+}
+
+#[test]
+fn min_width_with_filler() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Rows::single(0)).with(MinWidth::new(12).fill_with('.')))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N........... | column 0.... | column 1.... | column 2.... |"
+ "|--------------|--------------|--------------|--------------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn min_width_one_column() {
+ let mut table = Matrix::table(3, 3);
+ table
+ .with(Style::markdown())
+ .with(Modify::new((0, 0)).with(MinWidth::new(5)));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|-------|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+
+ table.with(Modify::new(Segment::all()).with(TrimStrategy::None));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|-------|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn min_width_on_smaller_content() {
+ assert_eq!(
+ Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Rows::single(0)).with(MinWidth::new(1)))
+ .to_string(),
+ Matrix::new(3, 3).with(Style::markdown()).to_string()
+ );
+}
+
+#[test]
+fn min_with_max_width() {
+ let mut table = Matrix::table(3, 3);
+ table
+ .with(Style::markdown())
+ .with(Modify::new(Rows::single(0)).with(MinWidth::new(3)))
+ .with(Modify::new(Rows::single(0)).with(Width::truncate(3)));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| N | col | col | col |"
+ "|-----|-----|-----|-----|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+
+ table.with(Modify::new(Segment::all()).with(TrimStrategy::None));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| N | col | col | col |"
+ "|-----|-----|-----|-----|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn min_with_max_width_truncate_suffix() {
+ let mut table = Matrix::table(3, 3);
+ table
+ .with(Style::markdown())
+ .with(Modify::new(Rows::single(0)).with(MinWidth::new(3)))
+ .with(Modify::new(Rows::single(0)).with(Width::truncate(3).suffix("...")));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| N | ... | ... | ... |"
+ "|-----|-----|-----|-----|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+
+ table.with(Modify::new(Segment::all()).with(TrimStrategy::None));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| N | ... | ... | ... |"
+ "|-----|-----|-----|-----|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn min_with_max_width_truncate_suffix_limit_replace() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(
+ Modify::new(Rows::single(0)).with(
+ Width::truncate(3)
+ .suffix("...")
+ .suffix_limit(SuffixLimit::Replace('x')),
+ ),
+ )
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | xxx | xxx | xxx |"
+ "|---|-----|-----|-----|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn min_with_max_width_truncate_suffix_limit_cut() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(
+ Modify::new(Rows::single(0)).with(
+ Width::truncate(3)
+ .suffix("qwert")
+ .suffix_limit(SuffixLimit::Cut),
+ ),
+ )
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | qwe | qwe | qwe |"
+ "|---|-----|-----|-----|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn min_with_max_width_truncate_suffix_limit_ignore() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(
+ Modify::new(Rows::single(0)).with(
+ Width::truncate(3)
+ .suffix("qwert")
+ .suffix_limit(SuffixLimit::Ignore),
+ ),
+ )
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | col | col | col |"
+ "|---|-----|-----|-----|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn min_with_max_width_truncate_suffix_try_color() {
+ let data = &[
+ "asd".red().to_string(),
+ "zxc".blue().to_string(),
+ "asdasd".on_black().green().to_string(),
+ ];
+
+ let table = Matrix::iter(data)
+ .with(Style::markdown())
+ .with(Width::truncate(7).suffix("..").suffix_try_color(true))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| S.. |"
+ "|-----|"
+ "| \u{1b}[31masd\u{1b}[39m |"
+ "| \u{1b}[34mzxc\u{1b}[39m |"
+ "| \u{1b}[32;40ma\u{1b}[39m\u{1b}[49m\u{1b}[32m\u{1b}[40m..\u{1b}[39m\u{1b}[49m |"
+ )
+ );
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn min_width_color() {
+ let data = &[
+ "asd".red().to_string(),
+ "zxc".blue().to_string(),
+ "asdasd".on_black().green().to_string(),
+ ];
+
+ let table = Matrix::iter(data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(MinWidth::new(10)))
+ .to_string();
+
+ assert_eq!(
+ ansi_str::AnsiStr::ansi_strip(&table),
+ static_table!(
+ "| String |"
+ "|------------|"
+ "| asd |"
+ "| zxc |"
+ "| asdasd |"
+ )
+ );
+
+ assert_eq!(
+ table,
+ "| String |\n|------------|\n| \u{1b}[31masd\u{1b}[39m |\n| \u{1b}[34mzxc\u{1b}[39m |\n| \u{1b}[32;40masdasd\u{1b}[0m |",
+ );
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn min_width_color_with_smaller_then_width() {
+ let data = &[
+ "asd".red().to_string(),
+ "zxc".blue().to_string(),
+ "asdasd".on_black().green().to_string(),
+ ];
+
+ assert_eq!(
+ Matrix::iter(data)
+ .with(Modify::new(Segment::all()).with(MinWidth::new(1)))
+ .to_string(),
+ Matrix::iter(data).to_string()
+ );
+}
+
+#[test]
+fn total_width_big() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Width::truncate(80))
+ .with(MinWidth::new(80))
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 80);
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|--------------|---------------------|--------------------|--------------------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(TrimStrategy::None))
+ .with(Settings::new(Width::truncate(80), Width::increase(80)))
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 80);
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|--------------|---------------------|--------------------|--------------------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn total_width_big_with_panel() {
+ let table = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(
+ Modify::new(Segment::all())
+ .with(Alignment::center())
+ .with(Padding::zero()),
+ )
+ .with(Style::markdown())
+ .with(Width::truncate(80))
+ .with(MinWidth::new(80))
+ .to_string();
+
+ assert!(is_lines_equal(&table, 80));
+ assert_eq!(
+ table,
+ static_table!(
+ "| Hello World |"
+ "|--------------|---------------------|--------------------|--------------------|"
+ "| N | column 0 | column 1 | column 2 |"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn total_width_big_with_panel_with_wrapping_doesnt_affect_increase() {
+ let table1 = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::wrap(80))
+ .with(MinWidth::new(80))
+ .to_string();
+
+ let table2 = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::truncate(80))
+ .with(MinWidth::new(80))
+ .to_string();
+
+ assert_eq!(table1, table2);
+}
+
+#[test]
+fn total_width_small() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Width::truncate(14))
+ .with(MinWidth::new(14))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | | c |"
+ "|--|--|--|---|"
+ "| | | | 0 |"
+ "| | | | 1 |"
+ "| | | | 2 |"
+ )
+ );
+ assert!(is_lines_equal(&table, 14));
+}
+
+#[test]
+fn total_width_smaller_then_content() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Width::truncate(8))
+ .with(MinWidth::new(8))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | | |"
+ "|--|--|--|--|"
+ "| | | | |"
+ "| | | | |"
+ "| | | | |"
+ )
+ );
+}
+
+#[test]
+fn total_width_small_with_panel() {
+ let table = Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::truncate(20))
+ .with(MinWidth::new(20))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | co | co | col |"
+ "|--|----|----|-----|"
+ "| | 0- | 0- | 0-2 |"
+ "| | 1- | 1- | 1-2 |"
+ "| | 2- | 2- | 2-2 |"
+ )
+ );
+ assert!(is_lines_equal(&table, 20));
+
+ let table = Matrix::iter(Vec::<usize>::new())
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(
+ Modify::new(Segment::all())
+ .with(Alignment::center())
+ .with(Padding::zero()),
+ )
+ .with(Width::truncate(5))
+ .with(MinWidth::new(5))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!("+---+" "|Hel|" "+---+" "|usi|" "+---+")
+ );
+ assert!(is_lines_equal(&table, 5));
+
+ let table = Matrix::table(1, 2)
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::truncate(20))
+ .with(MinWidth::new(20))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| Hello World |"
+ "|--|-------|-------|"
+ "| | colum | colum |"
+ "| | 0-0 | 0-1 |"
+ )
+ );
+ assert!(is_lines_equal(&table, 20));
+
+ let table = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::truncate(20))
+ .with(MinWidth::new(20))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| Hello World |"
+ "|--|----|----|-----|"
+ "| | co | co | col |"
+ "| | 0- | 0- | 0-2 |"
+ "| | 1- | 1- | 1-2 |"
+ "| | 2- | 2- | 2-2 |"
+ )
+ );
+ assert!(is_lines_equal(&table, 20));
+
+ let table = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::truncate(6))
+ .with(MinWidth::new(6))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| Hello Wor |"
+ "|--|--|--|--|"
+ "| | | | |"
+ "| | | | |"
+ "| | | | |"
+ "| | | | |"
+ )
+ );
+ assert!(is_lines_equal(&table, 13));
+
+ let table = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::truncate(14))
+ .with(MinWidth::new(14))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| Hello Worl |"
+ "|--|--|--|---|"
+ "| | | | c |"
+ "| | | | 0 |"
+ "| | | | 1 |"
+ "| | | | 2 |"
+ )
+ );
+ assert!(is_lines_equal(&table, 14));
+
+ let table = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World 123"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::truncate(14))
+ .with(MinWidth::new(14))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| Hello Worl |"
+ "|--|--|--|---|"
+ "| | | | c |"
+ "| | | | 0 |"
+ "| | | | 1 |"
+ "| | | | 2 |"
+ )
+ );
+ assert!(is_lines_equal(&table, 14));
+}
+
+#[cfg(feature = "color")]
+#[test]
+fn total_width_wrapping() {
+ let table = Matrix::new(3, 3)
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::wrap(20))
+ .with(MinWidth::new(20))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | co | co | col |"
+ "| | lu | lu | umn |"
+ "| | mn | mn | 2 |"
+ "| | 0 | 1 | |"
+ "|--|----|----|-----|"
+ "| | 0- | 0- | 0-2 |"
+ "| | 0 | 1 | |"
+ "| | 1- | 1- | 1-2 |"
+ "| | 0 | 1 | |"
+ "| | 2- | 2- | 2-2 |"
+ "| | 0 | 1 | |"
+ )
+ );
+ assert!(is_lines_equal(&table, 20));
+
+ let table = Matrix::new(3, 3)
+ .insert((3, 2), "some loong string")
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::wrap(20).keep_words())
+ .with(MinWidth::new(20))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | column | |"
+ "| | | 1 | |"
+ "|--|--|---------|--|"
+ "| | | 0-1 | |"
+ "| | | 1-1 | |"
+ "| | | some | |"
+ "| | | loong | |"
+ "| | | string | |"
+ )
+ );
+ assert!(is_lines_equal(&table, 20));
+}
+
+#[test]
+fn total_width_small_with_panel_using_wrapping() {
+ let table = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::wrap(20))
+ .with(MinWidth::new(20))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| Hello World |"
+ "|--|----|----|-----|"
+ "| | co | co | col |"
+ "| | lu | lu | umn |"
+ "| | mn | mn | 2 |"
+ "| | 0 | 1 | |"
+ "| | 0- | 0- | 0-2 |"
+ "| | 0 | 1 | |"
+ "| | 1- | 1- | 1-2 |"
+ "| | 0 | 1 | |"
+ "| | 2- | 2- | 2-2 |"
+ "| | 0 | 1 | |"
+ )
+ );
+ assert!(is_lines_equal(&table, 20));
+
+ let table = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::wrap(14))
+ .with(MinWidth::new(14))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| Hello Worl |"
+ "| d |"
+ "|--|--|--|---|"
+ "| | | | c |"
+ "| | | | o |"
+ "| | | | l |"
+ "| | | | u |"
+ "| | | | m |"
+ "| | | | n |"
+ "| | | | |"
+ "| | | | 2 |"
+ "| | | | 0 |"
+ "| | | | - |"
+ "| | | | 2 |"
+ "| | | | 1 |"
+ "| | | | - |"
+ "| | | | 2 |"
+ "| | | | 2 |"
+ "| | | | - |"
+ "| | | | 2 |"
+ )
+ );
+ assert!(is_lines_equal(&table, 14));
+
+ let table = Matrix::new(3, 3)
+ .with(Panel::horizontal(0, "Hello World 123"))
+ .with(Modify::new(Segment::all()).with(Alignment::center()))
+ .with(Style::markdown())
+ .with(Width::wrap(14))
+ .with(MinWidth::new(14))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| Hello Worl |"
+ "| d 123 |"
+ "|--|--|--|---|"
+ "| | | | c |"
+ "| | | | o |"
+ "| | | | l |"
+ "| | | | u |"
+ "| | | | m |"
+ "| | | | n |"
+ "| | | | |"
+ "| | | | 2 |"
+ "| | | | 0 |"
+ "| | | | - |"
+ "| | | | 2 |"
+ "| | | | 1 |"
+ "| | | | - |"
+ "| | | | 2 |"
+ "| | | | 2 |"
+ "| | | | - |"
+ "| | | | 2 |"
+ )
+ );
+ assert!(is_lines_equal(&table, 14));
+}
+
+#[test]
+fn max_width_with_span() {
+ let mut table = Matrix::new(3, 3).insert((1, 1), "a long string").to_table();
+ table
+ .with(Style::psql())
+ .with(Modify::new((1, 1)).with(Span::column(2)))
+ .with(Modify::new((2, 2)).with(Span::column(2)));
+
+ table.with(Width::truncate(40));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ " N | column 0 | column 1 | column 2 "
+ "---+----------+----------+----------"
+ " 0 | a long string | 0-2 "
+ " 1 | 1-0 | 1-1 "
+ " 2 | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ assert!(is_lines_equal(&table.to_string(), 36));
+
+ table.with(Width::truncate(20));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ " | col | col | col "
+ "--+-----+-----+-----"
+ " | a long st | 0-2 "
+ " | 1-0 | 1-1 "
+ " | 2-0 | 2-1 | 2-2 "
+ )
+ );
+ assert!(is_lines_equal(&table.to_string(), 20));
+
+ table.with(Width::truncate(10));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ " | | | "
+ "--+--+--+--"
+ " | a l | "
+ " | | 1-1 "
+ " | | | "
+ )
+ );
+ assert!(is_lines_equal(&table.to_string(), 11));
+}
+
+#[test]
+fn min_width_works_with_right_alignment() {
+ let json = r#"
+ {
+ "some": "random",
+ "json": [
+ { "1": "2" },
+ { "1": "2" },
+ { "1": "2" }
+ ]
+ }
+ "#;
+
+ let mut table = Matrix::iter([json]);
+ table
+ .with(Style::markdown())
+ .with(
+ Modify::new(Segment::all())
+ .with(Alignment::right())
+ .with(TrimStrategy::None),
+ )
+ .with(MinWidth::new(50));
+
+ assert_eq!(string_width_multiline(&table.to_string()), 50);
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| &str |"
+ "|------------------------------------------------|"
+ "| |"
+ "| { |"
+ "| \"some\": \"random\", |"
+ "| \"json\": [ |"
+ "| { \"1\": \"2\" }, |"
+ "| { \"1\": \"2\" }, |"
+ "| { \"1\": \"2\" } |"
+ "| ] |"
+ "| } |"
+ "| |"
+ )
+ );
+
+ table
+ .with(Modify::new(Segment::all()).with(TrimStrategy::Horizontal))
+ .with(MinWidth::new(50));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ r#"| &str |"#
+ r#"|------------------------------------------------|"#
+ r#"| |"#
+ r#"| { |"#
+ r#"| "some": "random", |"#
+ r#"| "json": [ |"#
+ r#"| { "1": "2" }, |"#
+ r#"| { "1": "2" }, |"#
+ r#"| { "1": "2" } |"#
+ r#"| ] |"#
+ r#"| } |"#
+ r#"| |"#
+ )
+ );
+ assert!(is_lines_equal(&table.to_string(), 50));
+
+ table
+ .with(Modify::new(Segment::all()).with(TrimStrategy::Both))
+ .with(MinWidth::new(50));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ r#"| &str |"#
+ r#"|------------------------------------------------|"#
+ r#"| { |"#
+ r#"| "some": "random", |"#
+ r#"| "json": [ |"#
+ r#"| { "1": "2" }, |"#
+ r#"| { "1": "2" }, |"#
+ r#"| { "1": "2" } |"#
+ r#"| ] |"#
+ r#"| } |"#
+ r#"| |"#
+ r#"| |"#
+ )
+ );
+ assert!(is_lines_equal(&table.to_string(), 50));
+
+ let mut table = Matrix::iter([json]);
+ table
+ .with(Style::markdown())
+ .with(
+ Modify::new(Segment::all())
+ .with(Alignment::center())
+ .with(TrimStrategy::None),
+ )
+ .with(MinWidth::new(50));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ "| &str |"
+ "|------------------------------------------------|"
+ "| |"
+ "| { |"
+ "| \"some\": \"random\", |"
+ "| \"json\": [ |"
+ "| { \"1\": \"2\" }, |"
+ "| { \"1\": \"2\" }, |"
+ "| { \"1\": \"2\" } |"
+ "| ] |"
+ "| } |"
+ "| |"
+ )
+ );
+ assert_eq!(string_width_multiline(&table.to_string()), 50);
+
+ table
+ .with(Modify::new(Segment::all()).with(TrimStrategy::Horizontal))
+ .with(MinWidth::new(50));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ r#"| &str |"#
+ r#"|------------------------------------------------|"#
+ r#"| |"#
+ r#"| { |"#
+ r#"| "some": "random", |"#
+ r#"| "json": [ |"#
+ r#"| { "1": "2" }, |"#
+ r#"| { "1": "2" }, |"#
+ r#"| { "1": "2" } |"#
+ r#"| ] |"#
+ r#"| } |"#
+ r#"| |"#
+ )
+ );
+ assert!(is_lines_equal(&table.to_string(), 50));
+
+ table
+ .with(Modify::new(Segment::all()).with(TrimStrategy::Both))
+ .with(MinWidth::new(50));
+
+ assert_eq!(
+ table.to_string(),
+ static_table!(
+ r#"| &str |"#
+ r#"|------------------------------------------------|"#
+ r#"| { |"#
+ r#"| "some": "random", |"#
+ r#"| "json": [ |"#
+ r#"| { "1": "2" }, |"#
+ r#"| { "1": "2" }, |"#
+ r#"| { "1": "2" } |"#
+ r#"| ] |"#
+ r#"| } |"#
+ r#"| |"#
+ r#"| |"#
+ )
+ );
+ assert!(is_lines_equal(&table.to_string(), 50));
+}
+
+#[test]
+fn min_width_with_span_1() {
+ let data = [
+ ["0", "1"],
+ ["a long string which will affect min width logic", ""],
+ ["2", "3"],
+ ];
+
+ let table = Matrix::iter(data)
+ .with(Style::markdown())
+ .with(Modify::new((1, 0)).with(Span::column(2)))
+ .with(MinWidth::new(100))
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 100);
+ assert_eq!(
+ table,
+ static_table!(
+ "| 0 | 1 |"
+ "|------------------------------------------------------------------------|-------------------------|"
+ "| 0 |"
+ "| a long string which will affect min width logic | |"
+ "| 2 | 3 |"
+ )
+ );
+ assert!(is_lines_equal(&table, 100));
+}
+
+#[test]
+fn min_width_with_span_2() {
+ let data = [
+ ["0", "1"],
+ ["a long string which will affect min width logic", ""],
+ ["2", "3"],
+ ];
+
+ let table = Matrix::iter(data)
+ .with(Style::markdown())
+ .with(Modify::new((2, 0)).with(Span::column(2)))
+ .with(MinWidth::new(100))
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 100);
+ assert_eq!(
+ table,
+ static_table!(
+ "| 0 | 1 |"
+ "|-------------------------------------------------|------------------------------------------------|"
+ "| 0 | 1 |"
+ "| a long string which will affect min width logic |"
+ "| 2 | 3 |"
+ )
+ );
+}
+
+#[test]
+fn justify_width_constant_test() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Justify::new(3))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | col | col | col |"
+ "|-----|-----|-----|-----|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn justify_width_constant_different_sizes_test() {
+ let table = Matrix::new(3, 3)
+ .insert((1, 1), "Hello World")
+ .insert((3, 2), "multi\nline string\n")
+ .with(Style::markdown())
+ .with(Justify::new(3))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | col | col | col |"
+ "|-----|-----|-----|-----|"
+ "| 0 | Hel | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | mul | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn justify_width_constant_0_test() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Justify::new(0))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | | |"
+ "|--|--|--|--|"
+ "| | | | |"
+ "| | | | |"
+ "| | | | |"
+ )
+ );
+}
+
+#[test]
+fn justify_width_min_test() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Justify::min())
+ .to_string();
+
+ println!("{table}");
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | c | c | c |"
+ "|---|---|---|---|"
+ "| 0 | 0 | 0 | 0 |"
+ "| 1 | 1 | 1 | 1 |"
+ "| 2 | 2 | 2 | 2 |"
+ )
+ );
+}
+
+#[test]
+fn justify_width_max_test() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Justify::max())
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|----------|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+}
+
+#[test]
+fn max_width_when_cell_has_tabs() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "\tHello\tWorld\t")
+ .with(TabSize::new(4))
+ .with(Style::markdown())
+ .with(Modify::new(Columns::new(..)).with(Width::truncate(1)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | c | c | c |"
+ "|---|---|---|---|"
+ "| 0 | 0 | 0 | 0 |"
+ "| 1 | | 1 | 1 |"
+ "| 2 | 2 | 2 | 2 |"
+ )
+ );
+}
+
+#[test]
+fn max_width_table_when_cell_has_tabs() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "\tHello\tWorld\t")
+ .with(TabSize::new(4))
+ .with(Style::markdown())
+ .with(Width::truncate(15))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | co | | |"
+ "|--|----|--|--|"
+ "| | 0- | | |"
+ "| | | | |"
+ "| | 2- | | |"
+ )
+ );
+}
+
+// WE GOT [["", "column 0", "column 1 ", "column 2 "], ["", "0-0 ", "0-1 ", "0-2 "], ["", "Hello World With Big Line; Here w", "1-1", "1-2"], ["", "2-0 ", "Hello World With Big L", "2-2"]]
+// [2, 10, 11, 12]
+// 40 55 40
+
+// BEFORE ADJ [2, 10, 11, 12]
+
+// WE GOT [["", "column 0", "column 1", "column 2"], ["", "0-0", "0-1", "0-2"], ["", "Hello World With Big Line; Here w", "1-1", "1-2"], ["", "2-0", "Hello World With Big L", "2-2"]]
+// [2, 11, 12, 11]
+// 41 55 40
+
+// adj [2, 10, 10, 10]
+
+#[test]
+fn max_width_truncate_with_big_span() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line; Here we gooooooo")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(3)))
+ .with(Width::truncate(40))
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 40);
+ assert_eq!(
+ table,
+ static_table!(
+ "| | column 0 | column 1 | column 2 |"
+ "|--|-----------|-----------|-----------|"
+ "| | 0-0 | 0-1 | 0-2 |"
+ "| | Hello World With Big Line; Here w |"
+ "| | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line; Here we gooooooo")
+ .insert((3, 2), "Hello World With Big Line; Here")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(3)))
+ .with(Modify::new((3, 2)).with(Span::column(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|-----------|----------------|----------------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | Hello World With Big Line; Here we gooooooo |"
+ "| 2 | 2-0 | Hello World With Big Line; Here |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line; Here we gooooooo")
+ .insert((3, 2), "Hello World With Big Line; Here")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(3)))
+ .with(Modify::new((3, 2)).with(Span::column(2)))
+ .with(Width::truncate(40))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | colum | column 1 | column 2 |"
+ "|--|-------|-------------|-------------|"
+ "| | 0-0 | 0-1 | 0-2 |"
+ "| | Hello World With Big Line; Here w |"
+ "| | 2-0 | Hello World With Big Line |"
+ )
+ );
+ assert_eq!(string_width_multiline(&table), 40);
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line; Here we gooooooo")
+ .insert((3, 2), "Hello World With Big Line; Here")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(2)))
+ .with(Modify::new((3, 2)).with(Span::column(2)))
+ .with(Width::truncate(40))
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 40);
+ assert_eq!(
+ table,
+ static_table!(
+ "| | column 0 | column 1 | c |"
+ "|--|---------------|---------------|---|"
+ "| | 0-0 | 0-1 | 0 |"
+ "| | Hello World With Big Line; He | 1 |"
+ "| | 2-0 | Hello World With |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line; Here w")
+ .insert((3, 2), "Hello World With Big L")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(3)))
+ .with(Modify::new((3, 2)).with(Span::column(2)))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|------------|-----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | Hello World With Big Line; Here w |"
+ "| 2 | 2-0 | Hello World With Big L |"
+ )
+ );
+}
+
+#[test]
+fn max_width_truncate_priority_max() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::truncate(35).priority::<PriorityMax>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 35));
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column | column | column |"
+ "|---|---------|---------|---------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | Hello W | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::truncate(20).priority::<PriorityMax>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 20));
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | co | co | co |"
+ "|---|----|----|----|"
+ "| 0 | 0- | 0- | 0- |"
+ "| 1 | He | 1- | 1- |"
+ "| 2 | 2- | 2- | 2- |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::truncate(0).priority::<PriorityMax>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 13));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | | |"
+ "|--|--|--|--|"
+ "| | | | |"
+ "| | | | |"
+ "| | | | |"
+ )
+ );
+}
+
+#[test]
+fn max_width_truncate_priority_max_with_span() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(2)))
+ .with(Width::truncate(15).priority::<PriorityMax>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 15));
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | c | | |"
+ "|---|---|--|--|"
+ "| 0 | 0 | | |"
+ "| 1 | Hell | |"
+ "| 2 | 2 | | |"
+ )
+ );
+}
+
+#[test]
+fn max_width_wrap_priority_max() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::wrap(35).priority::<PriorityMax>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 35));
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column | column | column |"
+ "| | 0 | 1 | 2 |"
+ "|---|---------|---------|---------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | Hello W | 1-1 | 1-2 |"
+ "| | orld Wi | | |"
+ "| | th Big | | |"
+ "| | Line | | |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::wrap(20).priority::<PriorityMax>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 20));
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | co | co | co |"
+ "| | lu | lu | lu |"
+ "| | mn | mn | mn |"
+ "| | 0 | 1 | 2 |"
+ "|---|----|----|----|"
+ "| 0 | 0- | 0- | 0- |"
+ "| | 0 | 1 | 2 |"
+ "| 1 | He | 1- | 1- |"
+ "| | ll | 1 | 2 |"
+ "| | o | | |"
+ "| | Wo | | |"
+ "| | rl | | |"
+ "| | d | | |"
+ "| | Wi | | |"
+ "| | th | | |"
+ "| | B | | |"
+ "| | ig | | |"
+ "| | L | | |"
+ "| | in | | |"
+ "| | e | | |"
+ "| 2 | 2- | 2- | 2- |"
+ "| | 0 | 1 | 2 |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::wrap(0).priority::<PriorityMax>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 13));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | | |"
+ "|--|--|--|--|"
+ "| | | | |"
+ "| | | | |"
+ "| | | | |"
+ )
+ );
+}
+
+#[test]
+fn max_width_wrap_priority_max_with_span() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(2)))
+ .with(Width::wrap(15).priority::<PriorityMax>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 15));
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | c | | |"
+ "| | o | | |"
+ "| | l | | |"
+ "| | u | | |"
+ "| | m | | |"
+ "| | n | | |"
+ "| | | | |"
+ "| | 0 | | |"
+ "|---|---|--|--|"
+ "| 0 | 0 | | |"
+ "| | - | | |"
+ "| | 0 | | |"
+ "| 1 | Hell | |"
+ "| | o Wo | |"
+ "| | rld | |"
+ "| | With | |"
+ "| | Big | |"
+ "| | Lin | |"
+ "| | e | |"
+ "| 2 | 2 | | |"
+ "| | - | | |"
+ "| | 0 | | |"
+ )
+ );
+}
+
+#[test]
+fn max_width_truncate_priority_min() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::truncate(35).priority::<PriorityMin>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 35));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | column 0 | | |"
+ "|--|------------------------|--|--|"
+ "| | 0-0 | | |"
+ "| | Hello World With Big L | | |"
+ "| | 2-0 | | |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::truncate(20).priority::<PriorityMin>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 20));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | column | | |"
+ "|--|---------|--|--|"
+ "| | 0-0 | | |"
+ "| | Hello W | | |"
+ "| | 2-0 | | |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::truncate(0).priority::<PriorityMin>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 13));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | | |"
+ "|--|--|--|--|"
+ "| | | | |"
+ "| | | | |"
+ "| | | | |"
+ )
+ );
+}
+
+#[test]
+fn max_width_truncate_priority_min_with_span() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(2)))
+ .with(Width::truncate(15).priority::<PriorityMin>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 15));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | co | |"
+ "|--|--|----|--|"
+ "| | | 0- | |"
+ "| | Hello | |"
+ "| | | 2- | |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(2)))
+ .with(Width::truncate(17).priority::<PriorityMin>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 17));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | colu | |"
+ "|--|--|------|--|"
+ "| | | 0-1 | |"
+ "| | Hello W | |"
+ "| | | 2-1 | |"
+ )
+ );
+}
+
+#[test]
+fn max_width_wrap_priority_min() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::wrap(35).priority::<PriorityMin>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 35));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | column 0 | | |"
+ "|--|------------------------|--|--|"
+ "| | 0-0 | | |"
+ "| | Hello World With Big L | | |"
+ "| | ine | | |"
+ "| | 2-0 | | |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::wrap(20).priority::<PriorityMin>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 20));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | column | | |"
+ "| | 0 | | |"
+ "|--|---------|--|--|"
+ "| | 0-0 | | |"
+ "| | Hello W | | |"
+ "| | orld Wi | | |"
+ "| | th Big | | |"
+ "| | Line | | |"
+ "| | 2-0 | | |"
+ )
+ );
+
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Width::wrap(0).priority::<PriorityMin>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 13));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | | |"
+ "|--|--|--|--|"
+ "| | | | |"
+ "| | | | |"
+ "| | | | |"
+ )
+ );
+}
+
+#[test]
+fn max_width_wrap_priority_min_with_span() {
+ let table = Matrix::new(3, 3)
+ .insert((2, 1), "Hello World With Big Line")
+ .with(Style::markdown())
+ .with(Modify::new((2, 1)).with(Span::column(2)))
+ .with(Width::wrap(15).priority::<PriorityMin>())
+ .to_string();
+
+ assert!(is_lines_equal(&table, 15));
+ assert_eq!(
+ table,
+ static_table!(
+ "| | | co | |"
+ "| | | lu | |"
+ "| | | mn | |"
+ "| | | 1 | |"
+ "|--|--|----|--|"
+ "| | | 0- | |"
+ "| | | 1 | |"
+ "| | Hello | |"
+ "| | Worl | |"
+ "| | d Wit | |"
+ "| | h Big | |"
+ "| | Line | |"
+ "| | | 2- | |"
+ "| | | 1 | |"
+ )
+ );
+}
+
+#[test]
+fn min_width_priority_max() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(MinWidth::new(60).priority::<PriorityMax>())
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 60);
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|----------|--------------------------------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ ),
+ );
+}
+
+#[test]
+fn min_width_priority_min() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(MinWidth::new(60).priority::<PriorityMin>())
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 60);
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|--------------|--------------|--------------|-------------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ ),
+ );
+}
+
+#[test]
+fn max_width_tab_0() {
+ let table =
+ Matrix::iter(["\t\tTigre Ecuador\tOMYA Andina\t3824909999\tCalcium carbonate\tColombia\t"])
+ .with(TabSize::new(4))
+ .with(Style::markdown())
+ .with(Width::wrap(60))
+ .to_string();
+
+ assert!(is_lines_equal(&table, 60));
+ assert_eq!(
+ table,
+ static_table!(
+ "| &str |"
+ "|----------------------------------------------------------|"
+ "| Tigre Ecuador OMYA Andina 3824909999 Ca |"
+ "| lcium carbonate Colombia |"
+ )
+ );
+}
+
+#[test]
+fn min_width_is_not_used_after_padding() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(MinWidth::new(60))
+ .with(Modify::new((0, 0)).with(Padding::new(2, 2, 0, 0)))
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 40);
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|-----|----------|----------|----------|"
+ "| 0 | 0-0 | 0-1 | 0-2 |"
+ "| 1 | 1-0 | 1-1 | 1-2 |"
+ "| 2 | 2-0 | 2-1 | 2-2 |"
+ ),
+ );
+}
+
+#[test]
+fn min_width_is_used_after_margin() {
+ let table = Matrix::new(3, 3)
+ .with(Style::markdown())
+ .with(Margin::new(1, 1, 1, 1))
+ .with(Width::increase(60))
+ .to_string();
+
+ assert_eq!(string_width_multiline(&table), 60);
+ assert_eq!(
+ table,
+ static_table!(
+ " "
+ " | N | column 0 | column 1 | column 2 | "
+ " |--------|---------------|---------------|---------------| "
+ " | 0 | 0-0 | 0-1 | 0-2 | "
+ " | 1 | 1-0 | 1-1 | 1-2 | "
+ " | 2 | 2-0 | 2-1 | 2-2 | "
+ " "
+ ),
+ );
+}
+
+#[test]
+fn wrap_keeping_words_0() {
+ let data = vec![["Hello world"]];
+ let table = tabled::Table::new(data)
+ .with(Width::wrap(8).keep_words())
+ .to_string();
+
+ assert_eq!(
+ tabled::grid::util::string::string_width_multiline(&table),
+ 8
+ );
+
+ assert_eq!(
+ table,
+ static_table!(
+ "+------+"
+ "| 0 |"
+ "+------+"
+ "| Hell |"
+ "| o wo |"
+ "| rld |"
+ "+------+"
+ )
+ );
+}
+
+#[test]
+fn cell_truncate_multiline() {
+ let table = Matrix::new(3, 3)
+ .insert((1, 1), "H\nel\nlo World")
+ .insert((3, 2), "multi\nline string\n")
+ .with(Style::markdown())
+ .with(
+ Modify::new(Columns::new(1..2).not(Rows::single(0)))
+ .with(Width::truncate(1).multiline()),
+ )
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|-------------|----------|"
+ "| 0 | H | 0-1 | 0-2 |"
+ "| | e | | |"
+ "| | l | | |"
+ "| 1 | 1 | 1-1 | 1-2 |"
+ "| 2 | 2 | multi | 2-2 |"
+ "| | | line string | |"
+ "| | | | |"
+ )
+ );
+}
+
+#[test]
+fn cell_truncate_multiline_with_suffix() {
+ let table = Matrix::new(3, 3)
+ .insert((1, 1), "H\nel\nlo World")
+ .insert((3, 2), "multi\nline string\n")
+ .with(Style::markdown())
+ .with(
+ Modify::new(Columns::new(1..2).not(Rows::single(0)))
+ .with(Width::truncate(1).multiline().suffix(".")),
+ )
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| N | column 0 | column 1 | column 2 |"
+ "|---|----------|-------------|----------|"
+ "| 0 | . | 0-1 | 0-2 |"
+ "| | . | | |"
+ "| | . | | |"
+ "| 1 | . | 1-1 | 1-2 |"
+ "| 2 | . | multi | 2-2 |"
+ "| | | line string | |"
+ "| | | | |"
+ )
+ );
+}
+
+#[test]
+fn table_truncate_multiline() {
+ let table = Matrix::new(3, 3)
+ .insert((1, 1), "H\nel\nlo World")
+ .insert((3, 2), "multi\nline string\n")
+ .with(Style::markdown())
+ .with(Width::truncate(20).multiline())
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | c | colu | co |"
+ "|--|---|------|----|"
+ "| | H | 0-1 | 0- |"
+ "| | e | | |"
+ "| | l | | |"
+ "| | 1 | 1-1 | 1- |"
+ "| | 2 | mult | 2- |"
+ "| | | line | |"
+ "| | | | |"
+ )
+ );
+}
+
+#[test]
+fn table_truncate_multiline_with_suffix() {
+ let table = Matrix::new(3, 3)
+ .insert((1, 1), "H\nel\nlo World")
+ .insert((3, 2), "multi\nline string\n")
+ .with(Style::markdown())
+ .with(Width::truncate(20).suffix(".").multiline())
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| | . | col. | c. |"
+ "|--|---|------|----|"
+ "| | . | 0-1 | 0. |"
+ "| | . | | |"
+ "| | . | | |"
+ "| | . | 1-1 | 1. |"
+ "| | . | mul. | 2. |"
+ "| | | lin. | |"
+ "| | | . | |"
+ )
+ );
+}
+
+#[cfg(feature = "derive")]
+mod derived {
+ use super::*;
+
+ use tabled::Tabled;
+
+ #[test]
+ fn wrapping_as_total_multiline() {
+ #[derive(Tabled)]
+ struct D<'a>(
+ #[tabled(rename = "version")] &'a str,
+ #[tabled(rename = "published_date")] &'a str,
+ #[tabled(rename = "is_active")] &'a str,
+ #[tabled(rename = "major_feature")] &'a str,
+ );
+
+ let data = vec![
+ D("0.2.1", "2021-06-23", "true", "#[header(inline)] attribute"),
+ D("0.2.0", "2021-06-19", "false", "API changes"),
+ D("0.1.4", "2021-06-07", "false", "display_with attribute"),
+ ];
+
+ let table = Matrix::iter(&data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Width::wrap(57))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| ver | published_d | is_act | major_feature |"
+ "| sio | ate | ive | |"
+ "| n | | | |"
+ "|-----|-------------|--------|--------------------------|"
+ "| 0.2 | 2021-06-23 | true | #[header(inline)] attrib |"
+ "| .1 | | | ute |"
+ "| 0.2 | 2021-06-19 | false | API changes |"
+ "| .0 | | | |"
+ "| 0.1 | 2021-06-07 | false | display_with attribute |"
+ "| .4 | | | |"
+ )
+ );
+ assert!(is_lines_equal(&table, 57));
+
+ let table = Matrix::iter(&data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Width::wrap(57).keep_words())
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| ver | published_d | is_act | major_feature |"
+ "| sio | ate | ive | |"
+ "| n | | | |"
+ "|-----|-------------|--------|--------------------------|"
+ "| 0.2 | 2021-06-23 | true | #[header(inline)] |"
+ "| .1 | | | attribute |"
+ "| 0.2 | 2021-06-19 | false | API changes |"
+ "| .0 | | | |"
+ "| 0.1 | 2021-06-07 | false | display_with attribute |"
+ "| .4 | | | |"
+ )
+ );
+ assert!(is_lines_equal(&table, 57));
+ }
+
+ #[cfg(feature = "color")]
+ #[test]
+ fn wrapping_as_total_multiline_color() {
+ #[derive(Tabled)]
+ struct D(
+ #[tabled(rename = "version")] String,
+ #[tabled(rename = "published_date")] String,
+ #[tabled(rename = "is_active")] String,
+ #[tabled(rename = "major_feature")] String,
+ );
+
+ let data = vec![
+ D(
+ "0.2.1".red().to_string(),
+ "2021-06-23".red().on_truecolor(8, 10, 30).to_string(),
+ "true".to_string(),
+ "#[header(inline)] attribute"
+ .blue()
+ .on_color(AnsiColors::Green)
+ .to_string(),
+ ),
+ D(
+ "0.2.0".red().to_string(),
+ "2021-06-19".green().on_truecolor(8, 100, 30).to_string(),
+ "false".to_string(),
+ "API changes".yellow().to_string(),
+ ),
+ D(
+ "0.1.4".white().to_string(),
+ "2021-06-07".red().on_truecolor(8, 10, 30).to_string(),
+ "false".to_string(),
+ "display_with attribute"
+ .red()
+ .on_color(AnsiColors::Black)
+ .to_string(),
+ ),
+ ];
+
+ let table = Matrix::iter(&data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Width::wrap(57))
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| ver | published_d | is_act | major_feature |"
+ "| sio | ate | ive | |"
+ "| n | | | |"
+ "|-----|-------------|--------|--------------------------|"
+ "| \u{1b}[31m0.2\u{1b}[39m | \u{1b}[48;2;8;10;30m\u{1b}[31m2021-06-23\u{1b}[39m\u{1b}[49m | true | \u{1b}[34m\u{1b}[42m#[header(inline)] attrib\u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[31m.1\u{1b}[39m | | | \u{1b}[34m\u{1b}[42mute\u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[31m0.2\u{1b}[39m | \u{1b}[48;2;8;100;30m\u{1b}[32m2021-06-19\u{1b}[39m\u{1b}[49m | false | \u{1b}[33mAPI changes\u{1b}[39m |"
+ "| \u{1b}[31m.0\u{1b}[39m | | | |"
+ "| \u{1b}[37m0.1\u{1b}[39m | \u{1b}[48;2;8;10;30m\u{1b}[31m2021-06-07\u{1b}[39m\u{1b}[49m | false | \u{1b}[31;40mdisplay_with attribute\u{1b}[0m |"
+ "| \u{1b}[37m.4\u{1b}[39m | | | |"
+ )
+ );
+ assert_eq!(string_width_multiline(&table), 57);
+
+ let table = Matrix::iter(&data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Width::wrap(57).keep_words())
+ .to_string();
+
+ assert_eq!(
+ table,
+ static_table!(
+ "| ver | published_d | is_act | major_feature |"
+ "| sio | ate | ive | |"
+ "| n | | | |"
+ "|-----|-------------|--------|--------------------------|"
+ "| \u{1b}[31m0.2\u{1b}[39m | \u{1b}[48;2;8;10;30m\u{1b}[31m2021-06-23\u{1b}[39m\u{1b}[49m | true | \u{1b}[34m\u{1b}[42m#[header(inline)] \u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[31m.1\u{1b}[39m | | | \u{1b}[34m\u{1b}[42mattribute\u{1b}[39m\u{1b}[49m |"
+ "| \u{1b}[31m0.2\u{1b}[39m | \u{1b}[48;2;8;100;30m\u{1b}[32m2021-06-19\u{1b}[39m\u{1b}[49m | false | \u{1b}[33mAPI changes\u{1b}[39m |"
+ "| \u{1b}[31m.0\u{1b}[39m | | | |"
+ "| \u{1b}[37m0.1\u{1b}[39m | \u{1b}[48;2;8;10;30m\u{1b}[31m2021-06-07\u{1b}[39m\u{1b}[49m | false | \u{1b}[31;40mdisplay_with attribute\u{1b}[0m |"
+ "| \u{1b}[37m.4\u{1b}[39m | | | |"
+ )
+ );
+ assert_eq!(string_width_multiline(&table), 57);
+ }
+
+ #[cfg(feature = "color")]
+ #[test]
+ fn truncating_as_total_multiline_color() {
+ #[derive(Tabled)]
+ struct D(
+ #[tabled(rename = "version")] String,
+ #[tabled(rename = "published_date")] String,
+ #[tabled(rename = "is_active")] String,
+ #[tabled(rename = "major_feature")] String,
+ );
+
+ let data = vec![
+ D(
+ "0.2.1".red().to_string(),
+ "2021-06-23".red().on_truecolor(8, 10, 30).to_string(),
+ "true".to_string(),
+ "#[header(inline)] attribute"
+ .blue()
+ .on_color(AnsiColors::Green)
+ .to_string(),
+ ),
+ D(
+ "0.2.0".red().to_string(),
+ "2021-06-19".green().on_truecolor(8, 100, 30).to_string(),
+ "false".to_string(),
+ "API changes".yellow().to_string(),
+ ),
+ D(
+ "0.1.4".white().to_string(),
+ "2021-06-07".red().on_truecolor(8, 10, 30).to_string(),
+ "false".to_string(),
+ "display_with attribute"
+ .red()
+ .on_color(AnsiColors::Black)
+ .to_string(),
+ ),
+ ];
+
+ let table = Matrix::iter(data)
+ .with(Style::markdown())
+ .with(Modify::new(Segment::all()).with(Alignment::left()))
+ .with(Width::truncate(57))
+ .to_string();
+
+ assert_eq!(
+ ansi_str::AnsiStr::ansi_strip(&table),
+ static_table!(
+ "| ver | published_d | is_act | major_feature |"
+ "|-----|-------------|--------|--------------------------|"
+ "| 0.2 | 2021-06-23 | true | #[header(inline)] attrib |"
+ "| 0.2 | 2021-06-19 | false | API changes |"
+ "| 0.1 | 2021-06-07 | false | display_with attribute |"
+ )
+ );
+
+ assert_eq!(
+ table,
+ "| ver | published_d | is_act | major_feature |\n|-----|-------------|--------|--------------------------|\n| \u{1b}[31m0.2\u{1b}[39m | \u{1b}[48;2;8;10;30m\u{1b}[31m2021-06-23\u{1b}[39m\u{1b}[49m | true | \u{1b}[34;42m#[header(inline)] attrib\u{1b}[39m\u{1b}[49m |\n| \u{1b}[31m0.2\u{1b}[39m | \u{1b}[48;2;8;100;30m\u{1b}[32m2021-06-19\u{1b}[39m\u{1b}[49m | false | \u{1b}[33mAPI changes\u{1b}[39m |\n| \u{1b}[37m0.1\u{1b}[39m | \u{1b}[48;2;8;10;30m\u{1b}[31m2021-06-07\u{1b}[39m\u{1b}[49m | false | \u{1b}[31;40mdisplay_with attribute\u{1b}[0m |"
+ );
+ assert_eq!(string_width_multiline(&table), 57);
+ }
+
+ #[cfg(feature = "color")]
+ fn format_osc8_hyperlink(url: &str, text: &str) -> String {
+ format!(
+ "{osc}8;;{url}{st}{text}{osc}8;;{st}",
+ url = url,
+ text = text,
+ osc = "\x1b]",
+ st = "\x1b\\"
+ )
+ }
+
+ #[cfg(feature = "color")]
+ #[test]
+ fn hyperlinks() {
+ #[derive(Tabled)]
+ struct Distribution {
+ name: String,
+ is_hyperlink: bool,
+ }
+
+ let table = |text: &str| {
+ let data = [Distribution {
+ name: text.to_owned(),
+ is_hyperlink: true,
+ }];
+ tabled::Table::new(data)
+ .with(
+ Modify::new(Segment::all())
+ .with(Width::wrap(5).keep_words())
+ .with(Alignment::left()),
+ )
+ .to_string()
+ };
+
+ let text = format_osc8_hyperlink("https://www.debian.org/", "Debian");
+ assert_eq!(
+ table(&text),
+ "+-------+-------+\n\
+ | name | is_hy |\n\
+ | | perli |\n\
+ | | nk |\n\
+ +-------+-------+\n\
+ | \u{1b}]8;;https://www.debian.org/\u{1b}\\Debia\u{1b}]8;;\u{1b}\\ | true |\n\
+ | \u{1b}]8;;https://www.debian.org/\u{1b}\\n\u{1b}]8;;\u{1b}\\ | |\n\
+ +-------+-------+"
+ );
+
+ // if there's more text than a link it will be ignored
+ let text = format!(
+ "{} :link",
+ format_osc8_hyperlink("https://www.debian.org/", "Debian"),
+ );
+ assert_eq!(
+ table(&text),
+ "+-------+-------+\n\
+ | name | is_hy |\n\
+ | | perli |\n\
+ | | nk |\n\
+ +-------+-------+\n\
+ | Debia | true |\n\
+ | n | |\n\
+ | :link | |\n\
+ +-------+-------+"
+ );
+
+ let text = format!(
+ "asd {} 2 links in a string {}",
+ format_osc8_hyperlink("https://www.debian.org/", "Debian"),
+ format_osc8_hyperlink("https://www.wikipedia.org/", "Debian"),
+ );
+ assert_eq!(
+ table(&text),
+ static_table!(
+ "+-------+-------+"
+ "| name | is_hy |"
+ "| | perli |"
+ "| | nk |"
+ "+-------+-------+"
+ "| asd D | true |"
+ "| ebian | |"
+ "| 2 | |"
+ "| links | |"
+ "| in a | |"
+ "| stri | |"
+ "| ng De | |"
+ "| bian | |"
+ "+-------+-------+"
+ )
+ );
+ }
+
+ #[cfg(feature = "color")]
+ #[test]
+ fn hyperlinks_with_color() {
+ use owo_colors::OwoColorize;
+
+ #[derive(Tabled)]
+ struct Distribution {
+ name: String,
+ is_hyperlink: bool,
+ }
+
+ let table = |text: &str| {
+ let data = [Distribution {
+ name: text.to_owned(),
+ is_hyperlink: true,
+ }];
+ tabled::Table::new(data)
+ .with(
+ Modify::new(Segment::all())
+ .with(Width::wrap(6).keep_words())
+ .with(Alignment::left()),
+ )
+ .to_string()
+ };
+
+ let text = format_osc8_hyperlink(
+ "https://www.debian.org/",
+ "Debian".red().to_string().as_str(),
+ );
+ assert_eq!(
+ table(&text),
+ static_table!(
+ "+--------+--------+"
+ "| name | is_hyp |"
+ "| | erlink |"
+ "+--------+--------+"
+ "| \u{1b}]8;;https://www.debian.org/\u{1b}\\\u{1b}[31mDebian\u{1b}[39m\u{1b}]8;;\u{1b}\\ | true |"
+ "+--------+--------+"
+ )
+ );
+
+ // if there's more text than a link it will be ignored
+ let text = format!(
+ "{} :link",
+ format_osc8_hyperlink("https://www.debian.org/", "Debian"),
+ );
+ assert_eq!(
+ table(&text),
+ static_table!(
+ "+--------+--------+"
+ "| name | is_hyp |"
+ "| | erlink |"
+ "+--------+--------+"
+ "| Debian | true |"
+ "| :link | |"
+ "+--------+--------+"
+ )
+ );
+
+ let text = format!(
+ "asd {} 2 links in a string {}",
+ format_osc8_hyperlink("https://www.debian.org/", "Debian"),
+ format_osc8_hyperlink("https://www.wikipedia.org/", "Debian"),
+ );
+ assert_eq!(
+ table(&text),
+ static_table!(
+ "+--------+--------+"
+ "| name | is_hyp |"
+ "| | erlink |"
+ "+--------+--------+"
+ "| asd | true |"
+ "| Debian | |"
+ "| 2 | |"
+ "| links | |"
+ "| in a | |"
+ "| string | |"
+ "| | |"
+ "| Debian | |"
+ "+--------+--------+"
+ )
+ );
+ }
+}