summaryrefslogtreecommitdiffstats
path: root/vendor/papergrid/tests/grid
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/papergrid/tests/grid')
-rw-r--r--vendor/papergrid/tests/grid/column_span.rs431
-rw-r--r--vendor/papergrid/tests/grid/format_configuration.rs953
-rw-r--r--vendor/papergrid/tests/grid/mod.rs6
-rw-r--r--vendor/papergrid/tests/grid/render.rs251
-rw-r--r--vendor/papergrid/tests/grid/row_span.rs1062
-rw-r--r--vendor/papergrid/tests/grid/settings.rs265
-rw-r--r--vendor/papergrid/tests/grid/styling.rs334
7 files changed, 3302 insertions, 0 deletions
diff --git a/vendor/papergrid/tests/grid/column_span.rs b/vendor/papergrid/tests/grid/column_span.rs
new file mode 100644
index 000000000..3ea8f8546
--- /dev/null
+++ b/vendor/papergrid/tests/grid/column_span.rs
@@ -0,0 +1,431 @@
+#![cfg(feature = "std")]
+
+use papergrid::config::{AlignmentHorizontal, Borders, Entity, Indent, Sides};
+
+use crate::util::grid;
+use testing_table::test_table;
+
+test_table!(
+ row_span,
+ grid(2, 2)
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_alignment_horizontal(Entity::Cell(0, 0), AlignmentHorizontal::Center);
+ })
+ .build(),
+ "+---+---+"
+ "| 0-0 |"
+ "+---+---+"
+ "|1-0|1-1|"
+ "+---+---+"
+);
+
+test_table!(
+ miltiline_span,
+ grid(2, 2)
+ .change_cell((0, 0), "0-0\n0-1")
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_alignment_horizontal(Entity::Cell(0, 0), AlignmentHorizontal::Center);
+ })
+ .build(),
+ "+---+---+"
+ "| 0-0 |"
+ "| 0-1 |"
+ "+---+---+"
+ "|1-0|1-1|"
+ "+---+---+"
+);
+
+test_table!(
+ row_span_multilane,
+ grid(4, 3)
+ .data([
+ ["first line", "", "e.g."],
+ ["0", "1", "2"],
+ ["0", "1", "2"],
+ ["full last line", "", ""],
+ ])
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((3, 0), 3);
+ })
+ .build(),
+ "+-----+----+----+"
+ "|first line|e.g.|"
+ "+-----+----+----+"
+ "|0 |1 |2 |"
+ "+-----+----+----+"
+ "|0 |1 |2 |"
+ "+-----+----+----+"
+ "|full last line |"
+ "+-----+----+----+"
+);
+
+test_table!(
+ row_span_with_horizontal_ident,
+ grid(3, 2)
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_padding(
+ Entity::Cell(1, 0),
+ Sides::new(
+ Indent::spaced(4),
+ Indent::spaced(4),
+ Indent::zero(),
+ Indent::zero(),
+ ),
+ );
+ })
+ .build(),
+ "+-----------+---+"
+ "|0-0 |"
+ "+-----------+---+"
+ "| 1-0 |1-1|"
+ "+-----------+---+"
+ "|2-0 |2-1|"
+ "+-----------+---+"
+);
+
+test_table!(
+ _row_span_3x3_with_horizontal_ident,
+ grid(3, 3)
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 3);
+ cfg.set_column_span((1, 0), 2);
+ cfg.set_column_span((2, 0), 2);
+ })
+ .build(),
+ "+-+-+---+"
+ "|0-0 |"
+ "+-+-+---+"
+ "|1-0|1-2|"
+ "+-+-+---+"
+ "|2-0|2-2|"
+ "+-+-+---+"
+);
+
+test_table!(
+ _3x3_with_2_colided_row_span_0,
+ grid(3, 3)
+ .change_cell((0, 0), "0-0xxxxxxx")
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 1), 2);
+ })
+ .build(),
+ "+-----+----+---+"
+ "|0-0xxxxxxx|0-2|"
+ "+-----+----+---+"
+ "|1-0 |1-1 |"
+ "+-----+----+---+"
+ "|2-0 |2-1 |2-2|"
+ "+-----+----+---+"
+);
+
+test_table!(
+ _3x3_with_2_colided_row_span_1,
+ grid(3, 3)
+ .change_cell((1, 1), "1-1xxxxxxx")
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 1), 2);
+ })
+ .build(),
+ "+---+-----+----+"
+ "|0-0 |0-2 |"
+ "+---+-----+----+"
+ "|1-0|1-1xxxxxxx|"
+ "+---+-----+----+"
+ "|2-0|2-1 |2-2 |"
+ "+---+-----+----+"
+);
+
+test_table!(
+ _3x3_with_2_colided_row_span_2,
+ grid(3, 3)
+ .change_cell((1, 1), "1-1xxxxxxx")
+ .change_cell((2, 0), "2-0xxxxxxxxxxxxx")
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 1), 2);
+ })
+ .build(),
+ "+----------------+-----+----+"
+ "|0-0 |0-2 |"
+ "+----------------+-----+----+"
+ "|1-0 |1-1xxxxxxx|"
+ "+----------------+-----+----+"
+ "|2-0xxxxxxxxxxxxx|2-1 |2-2 |"
+ "+----------------+-----+----+"
+);
+
+test_table!(
+ _3x3_with_2_colided_row_span_3,
+ grid(3, 3)
+ .change_cell((2, 1), "2-1xxxxxxxxxxxxx")
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 1), 2);
+ })
+ .build(),
+ "+---+----------------+---+"
+ "|0-0 |0-2|"
+ "+---+----------------+---+"
+ "|1-0|1-1 |"
+ "+---+----------------+---+"
+ "|2-0|2-1xxxxxxxxxxxxx|2-2|"
+ "+---+----------------+---+"
+);
+
+test_table!(
+ _3x3_with_2_colided_row_span_4,
+ grid(3, 3)
+ .change_cell((0, 2), "0-2xxxxxxxxxxxxx")
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 1), 2);
+ })
+ .build(),
+ "+---+---+----------------+"
+ "|0-0 |0-2xxxxxxxxxxxxx|"
+ "+---+---+----------------+"
+ "|1-0|1-1 |"
+ "+---+---+----------------+"
+ "|2-0|2-1|2-2 |"
+ "+---+---+----------------+"
+);
+
+test_table!(
+ spaned_column_in_first_cell_3x3,
+ grid(3, 3)
+ .change_cell((0, 0), "0-0xxxxxxx")
+ .config(|cfg| cfg.set_column_span((0, 0), 2))
+ .build(),
+ "+-----+----+---+"
+ "|0-0xxxxxxx|0-2|"
+ "+-----+----+---+"
+ "|1-0 |1-1 |1-2|"
+ "+-----+----+---+"
+ "|2-0 |2-1 |2-2|"
+ "+-----+----+---+"
+);
+
+test_table!(
+ row_span_with_different_length,
+ grid(3, 2)
+ .data([["first row", ""], ["0", "1"], ["a longer second row", ""]])
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((2, 0), 2);
+ })
+ .build(),
+ "+---------+---------+"
+ "|first row |"
+ "+---------+---------+"
+ "|0 |1 |"
+ "+---------+---------+"
+ "|a longer second row|"
+ "+---------+---------+"
+);
+
+test_table!(
+ row_span_with_odd_length,
+ grid(2, 2)
+ .data([["3 ", ""], ["2", "4"]])
+ .config(|cfg| cfg.set_column_span((0, 0), 2))
+ .build(),
+ "+--+-+"
+ "|3 |"
+ "+--+-+"
+ "|2 |4|"
+ "+--+-+"
+);
+
+test_table!(
+ only_row_spaned,
+ grid(3, 2)
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 0), 2);
+ cfg.set_column_span((2, 0), 2);
+ })
+ .build(),
+ "+-+-+"
+ "|0-0|"
+ "+-+-+"
+ "|1-0|"
+ "+-+-+"
+ "|2-0|"
+ "+-+-+"
+);
+
+test_table!(
+ grid_2x2_span_test,
+ grid(2, 2)
+ .data([["123", ""], ["asd", "asd"]])
+ .config(|cfg| cfg.set_column_span((0, 0), 2))
+ .build(),
+ "+---+---+"
+ "|123 |"
+ "+---+---+"
+ "|asd|asd|"
+ "+---+---+"
+);
+
+test_table!(
+ grid_2x2_span_2_test_0,
+ grid(2, 2)
+ .data([["1234", ""], ["asdw", ""]])
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 0), 2);
+ })
+ .build(),
+ "+--+-+"
+ "|1234|"
+ "+--+-+"
+ "|asdw|"
+ "+--+-+"
+);
+
+test_table!(
+ grid_2x2_span_2_test_1,
+ grid(2, 2)
+ .data([["1", ""], ["a", ""]])
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 0), 2);
+ })
+ .build(),
+ "+++"
+ "|1|"
+ "+++"
+ "|a|"
+ "+++"
+);
+
+test_table!(
+ row_span_with_no_split_style,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders::default());
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_alignment_horizontal(Entity::Cell(0, 0), AlignmentHorizontal::Center);
+ })
+ .build(),
+ " 0-0 "
+ "1-01-1"
+);
+
+test_table!(
+ _2x3_zero_span_between_cells_0,
+ grid(2, 3)
+ .config(|cfg| cfg.set_column_span((0, 0), 2))
+ .build(),
+ "+---+---+---+"
+ "|0-0 |0-2|"
+ "+---+---+---+"
+ "|1-0|1-1|1-2|"
+ "+---+---+---+"
+);
+
+test_table!(
+ _2x3_zero_span_between_cells_1,
+ grid(2, 3)
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 0), 2);
+ })
+ .build(),
+ "+-+-+---+"
+ "|0-0|0-2|"
+ "+-+-+---+"
+ "|1-0|1-2|"
+ "+-+-+---+"
+);
+
+test_table!(
+ _2x3_zero_span_at_the_end_0,
+ grid(2, 3)
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 3);
+ })
+ .build(),
+ "+---+---+---+"
+ "|0-0 |"
+ "+---+---+---+"
+ "|1-0|1-1|1-2|"
+ "+---+---+---+"
+);
+
+test_table!(
+ _2x3_zero_span_at_the_end_1,
+ grid(2, 3)
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 3);
+ cfg.set_column_span((1, 0), 3);
+ })
+ .build(),
+ "+-+++"
+ "|0-0|"
+ "+-+++"
+ "|1-0|"
+ "+-+++"
+);
+
+test_table!(
+ zero_span_grid,
+ grid(2, 2)
+ .data([["123", ""], ["asd", "asd"]])
+ .config(|cfg| {
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 0), 2);
+ })
+ .build(),
+ "+-+-+"
+ "|123|"
+ "+-+-+"
+ "|asd|"
+ "+-+-+"
+);
+
+test_table!(
+ zero_span_grid_1,
+ grid(2, 2)
+ .data([["123", ""], ["asd", "asd"]])
+ .config(|cfg| {
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ })
+ .build(),
+ "+---++"
+ "+123++"
+ "+---++"
+);
+
+test_table!(
+ zero_span_grid_2,
+ grid(2, 2)
+ .data([["123", "axc"], ["asd", "asd"]])
+ .config(|cfg| {
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ })
+ .build(),
+ "+---+---+"
+ "+123+axc+"
+ "+---+---+"
+);
+
+test_table!(
+ zero_span_is_not_handled,
+ grid(2, 2)
+ .config(|cfg| { cfg.set_column_span((0, 1), 0); })
+ .build(),
+ "+---+---+"
+ "|0-0|0-1|"
+ "+---+---+"
+ "|1-0|1-1|"
+ "+---+---+"
+);
diff --git a/vendor/papergrid/tests/grid/format_configuration.rs b/vendor/papergrid/tests/grid/format_configuration.rs
new file mode 100644
index 000000000..1abfaa34a
--- /dev/null
+++ b/vendor/papergrid/tests/grid/format_configuration.rs
@@ -0,0 +1,953 @@
+#![cfg(feature = "std")]
+
+use papergrid::config::{spanned::Formatting, AlignmentHorizontal, AlignmentVertical, Entity};
+
+use crate::util::grid;
+use testing_table::static_table;
+
+#[test]
+fn formatting_test() {
+ let tests = [
+ (
+ AlignmentHorizontal::Left,
+ AlignmentVertical::Top,
+ Formatting::new(false, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "|A long string| |"
+ "| | |"
+ "| | |"
+ "| |A |"
+ "| | string|"
+ "| |with |"
+ "| | new |"
+ "| |line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "|1-0 |1-1 |"
+ "+-------------+----------+"
+ "|A one more |... |"
+ "| string | |"
+ "|with | |"
+ "| new | |"
+ "|line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Left,
+ AlignmentVertical::Top,
+ Formatting::new(true, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "|A long string| |"
+ "| | |"
+ "| | |"
+ "| |A |"
+ "| |string |"
+ "| |with |"
+ "| |new |"
+ "| |line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "|1-0 |1-1 |"
+ "+-------------+----------+"
+ "|A one more |... |"
+ "|string | |"
+ "|with | |"
+ "|new | |"
+ "|line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Left,
+ AlignmentVertical::Top,
+ Formatting::new(true, true, true),
+ static_table!(
+ "+-------------+----------+"
+ "|A long string|A |"
+ "| |string |"
+ "| |with |"
+ "| |new |"
+ "| |line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "|1-0 |1-1 |"
+ "+-------------+----------+"
+ "|A one more |... |"
+ "|string | |"
+ "|with | |"
+ "|new | |"
+ "|line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ //
+ (
+ AlignmentHorizontal::Center,
+ AlignmentVertical::Top,
+ Formatting::new(false, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "|A long string| |"
+ "| | |"
+ "| | |"
+ "| | A |"
+ "| | string|"
+ "| | with |"
+ "| | new |"
+ "| | line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0 | 1-1 |"
+ "+-------------+----------+"
+ "| A one more | ... |"
+ "| string | |"
+ "| with | |"
+ "| new | |"
+ "| line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Center,
+ AlignmentVertical::Top,
+ Formatting::new(true, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "|A long string| |"
+ "| | |"
+ "| | |"
+ "| | A |"
+ "| | string |"
+ "| | with |"
+ "| | new |"
+ "| | line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0 | 1-1 |"
+ "+-------------+----------+"
+ "| A one more | ... |"
+ "| string | |"
+ "| with | |"
+ "| new | |"
+ "| line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Center,
+ AlignmentVertical::Top,
+ Formatting::new(true, true, true),
+ static_table!(
+ "+-------------+----------+"
+ "|A long string| A |"
+ "| | string |"
+ "| | with |"
+ "| | new |"
+ "| | line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0 | 1-1 |"
+ "+-------------+----------+"
+ "| A one more | ... |"
+ "| string | |"
+ "| with | |"
+ "| new | |"
+ "| line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ //
+ (
+ AlignmentHorizontal::Right,
+ AlignmentVertical::Top,
+ Formatting::new(false, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "|A long string| |"
+ "| | |"
+ "| | |"
+ "| | A|"
+ "| | string|"
+ "| | with|"
+ "| | new|"
+ "| | line|"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0| 1-1|"
+ "+-------------+----------+"
+ "| A one more| ...|"
+ "| string| |"
+ "| with| |"
+ "| new| |"
+ "| line| |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Right,
+ AlignmentVertical::Top,
+ Formatting::new(true, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "|A long string| |"
+ "| | |"
+ "| | |"
+ "| | A|"
+ "| | string|"
+ "| | with|"
+ "| | new|"
+ "| | line|"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0| 1-1|"
+ "+-------------+----------+"
+ "| A one more| ...|"
+ "| string| |"
+ "| with| |"
+ "| new| |"
+ "| line| |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Right,
+ AlignmentVertical::Top,
+ Formatting::new(true, true, true),
+ static_table!(
+ "+-------------+----------+"
+ "|A long string| A|"
+ "| | string|"
+ "| | with|"
+ "| | new|"
+ "| | line|"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0| 1-1|"
+ "+-------------+----------+"
+ "| A one more| ...|"
+ "| string| |"
+ "| with| |"
+ "| new| |"
+ "| line| |"
+ "+-------------+----------+"
+ ),
+ ),
+ // asd
+ (
+ AlignmentHorizontal::Left,
+ AlignmentVertical::Center,
+ Formatting::new(false, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| |A |"
+ "| | string|"
+ "|A long string|with |"
+ "| | new |"
+ "| |line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "|1-0 |1-1 |"
+ "+-------------+----------+"
+ "|A one more | |"
+ "| string | |"
+ "|with |... |"
+ "| new | |"
+ "|line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Left,
+ AlignmentVertical::Center,
+ Formatting::new(true, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| |A |"
+ "| |string |"
+ "|A long string|with |"
+ "| |new |"
+ "| |line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "|1-0 |1-1 |"
+ "+-------------+----------+"
+ "|A one more | |"
+ "|string | |"
+ "|with |... |"
+ "|new | |"
+ "|line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Left,
+ AlignmentVertical::Center,
+ Formatting::new(true, true, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| |A |"
+ "| |string |"
+ "|A long string|with |"
+ "| |new |"
+ "| |line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "|1-0 |1-1 |"
+ "+-------------+----------+"
+ "|A one more | |"
+ "|string | |"
+ "|with |... |"
+ "|new | |"
+ "|line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ //
+ (
+ AlignmentHorizontal::Center,
+ AlignmentVertical::Center,
+ Formatting::new(false, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A |"
+ "| | string|"
+ "|A long string| with |"
+ "| | new |"
+ "| | line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0 | 1-1 |"
+ "+-------------+----------+"
+ "| A one more | |"
+ "| string | |"
+ "| with | ... |"
+ "| new | |"
+ "| line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Center,
+ AlignmentVertical::Center,
+ Formatting::new(true, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A |"
+ "| | string |"
+ "|A long string| with |"
+ "| | new |"
+ "| | line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0 | 1-1 |"
+ "+-------------+----------+"
+ "| A one more | |"
+ "| string | |"
+ "| with | ... |"
+ "| new | |"
+ "| line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Center,
+ AlignmentVertical::Center,
+ Formatting::new(true, true, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A |"
+ "| | string |"
+ "|A long string| with |"
+ "| | new |"
+ "| | line |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0 | 1-1 |"
+ "+-------------+----------+"
+ "| A one more | |"
+ "| string | |"
+ "| with | ... |"
+ "| new | |"
+ "| line | |"
+ "+-------------+----------+"
+ ),
+ ),
+ //
+ (
+ AlignmentHorizontal::Right,
+ AlignmentVertical::Center,
+ Formatting::new(false, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A|"
+ "| | string|"
+ "|A long string| with|"
+ "| | new|"
+ "| | line|"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0| 1-1|"
+ "+-------------+----------+"
+ "| A one more| |"
+ "| string| |"
+ "| with| ...|"
+ "| new| |"
+ "| line| |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Right,
+ AlignmentVertical::Center,
+ Formatting::new(true, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A|"
+ "| | string|"
+ "|A long string| with|"
+ "| | new|"
+ "| | line|"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0| 1-1|"
+ "+-------------+----------+"
+ "| A one more| |"
+ "| string| |"
+ "| with| ...|"
+ "| new| |"
+ "| line| |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Right,
+ AlignmentVertical::Center,
+ Formatting::new(true, true, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A|"
+ "| | string|"
+ "|A long string| with|"
+ "| | new|"
+ "| | line|"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+-------------+----------+"
+ "| 1-0| 1-1|"
+ "+-------------+----------+"
+ "| A one more| |"
+ "| string| |"
+ "| with| ...|"
+ "| new| |"
+ "| line| |"
+ "+-------------+----------+"
+ ),
+ ),
+ //
+ // asd
+ (
+ AlignmentHorizontal::Left,
+ AlignmentVertical::Bottom,
+ Formatting::new(false, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| |A |"
+ "| | string|"
+ "| |with |"
+ "| | new |"
+ "| |line |"
+ "| | |"
+ "| | |"
+ "|A long string| |"
+ "+-------------+----------+"
+ "|1-0 |1-1 |"
+ "+-------------+----------+"
+ "|A one more | |"
+ "| string | |"
+ "|with | |"
+ "| new | |"
+ "|line |... |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Left,
+ AlignmentVertical::Bottom,
+ Formatting::new(true, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| |A |"
+ "| |string |"
+ "| |with |"
+ "| |new |"
+ "| |line |"
+ "| | |"
+ "| | |"
+ "|A long string| |"
+ "+-------------+----------+"
+ "|1-0 |1-1 |"
+ "+-------------+----------+"
+ "|A one more | |"
+ "|string | |"
+ "|with | |"
+ "|new | |"
+ "|line |... |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Left,
+ AlignmentVertical::Bottom,
+ Formatting::new(true, true, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| |A |"
+ "| |string |"
+ "| |with |"
+ "| |new |"
+ "|A long string|line |"
+ "+-------------+----------+"
+ "|1-0 |1-1 |"
+ "+-------------+----------+"
+ "|A one more | |"
+ "|string | |"
+ "|with | |"
+ "|new | |"
+ "|line |... |"
+ "+-------------+----------+"
+ ),
+ ),
+ //
+ (
+ AlignmentHorizontal::Center,
+ AlignmentVertical::Bottom,
+ Formatting::new(false, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A |"
+ "| | string|"
+ "| | with |"
+ "| | new |"
+ "| | line |"
+ "| | |"
+ "| | |"
+ "|A long string| |"
+ "+-------------+----------+"
+ "| 1-0 | 1-1 |"
+ "+-------------+----------+"
+ "| A one more | |"
+ "| string | |"
+ "| with | |"
+ "| new | |"
+ "| line | ... |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Center,
+ AlignmentVertical::Bottom,
+ Formatting::new(true, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A |"
+ "| | string |"
+ "| | with |"
+ "| | new |"
+ "| | line |"
+ "| | |"
+ "| | |"
+ "|A long string| |"
+ "+-------------+----------+"
+ "| 1-0 | 1-1 |"
+ "+-------------+----------+"
+ "| A one more | |"
+ "| string | |"
+ "| with | |"
+ "| new | |"
+ "| line | ... |"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Center,
+ AlignmentVertical::Bottom,
+ Formatting::new(true, true, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A |"
+ "| | string |"
+ "| | with |"
+ "| | new |"
+ "|A long string| line |"
+ "+-------------+----------+"
+ "| 1-0 | 1-1 |"
+ "+-------------+----------+"
+ "| A one more | |"
+ "| string | |"
+ "| with | |"
+ "| new | |"
+ "| line | ... |"
+ "+-------------+----------+"
+ ),
+ ),
+ //
+ (
+ AlignmentHorizontal::Right,
+ AlignmentVertical::Bottom,
+ Formatting::new(false, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A|"
+ "| | string|"
+ "| | with|"
+ "| | new|"
+ "| | line|"
+ "| | |"
+ "| | |"
+ "|A long string| |"
+ "+-------------+----------+"
+ "| 1-0| 1-1|"
+ "+-------------+----------+"
+ "| A one more| |"
+ "| string| |"
+ "| with| |"
+ "| new| |"
+ "| line| ...|"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Right,
+ AlignmentVertical::Bottom,
+ Formatting::new(true, false, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A|"
+ "| | string|"
+ "| | with|"
+ "| | new|"
+ "| | line|"
+ "| | |"
+ "| | |"
+ "|A long string| |"
+ "+-------------+----------+"
+ "| 1-0| 1-1|"
+ "+-------------+----------+"
+ "| A one more| |"
+ "| string| |"
+ "| with| |"
+ "| new| |"
+ "| line| ...|"
+ "+-------------+----------+"
+ ),
+ ),
+ (
+ AlignmentHorizontal::Right,
+ AlignmentVertical::Bottom,
+ Formatting::new(true, true, true),
+ static_table!(
+ "+-------------+----------+"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | |"
+ "| | A|"
+ "| | string|"
+ "| | with|"
+ "| | new|"
+ "|A long string| line|"
+ "+-------------+----------+"
+ "| 1-0| 1-1|"
+ "+-------------+----------+"
+ "| A one more| |"
+ "| string| |"
+ "| with| |"
+ "| new| |"
+ "| line| ...|"
+ "+-------------+----------+"
+ ),
+ ),
+ ];
+
+ let grid = grid(3, 2)
+ .change_cell((0, 0), "A long string")
+ .change_cell((0, 1), "\n\n\nA\n string\nwith\n new\nline\n\n\n")
+ .change_cell((2, 0), "A one more\n string\nwith\n new\nline")
+ .change_cell((2, 1), "...");
+
+ for (i, test) in tests.iter().enumerate() {
+ let table = grid
+ .clone()
+ .config(|cfg| {
+ cfg.set_alignment_horizontal(Entity::Global, test.0);
+ cfg.set_alignment_vertical(Entity::Global, test.1);
+ cfg.set_formatting(Entity::Global, test.2);
+ })
+ .clone()
+ .build();
+
+ let expected = test.3;
+ assert_eq!(table, expected, "test case #{i:?} failed");
+ }
+}
+
+#[test]
+fn formatting_empty_test() {
+ for (rows, cols) in [(0, 0), (0, 4), (4, 0)] {
+ let formatting = Formatting::new(true, true, true);
+ assert_eq!(
+ grid(rows, cols)
+ .config(|cfg| cfg.set_formatting(Entity::Global, formatting))
+ .build(),
+ ""
+ );
+ }
+}
+
+#[test]
+fn formatting_1x1_test() {
+ let json = r#"
+{
+ "id": "0001",
+ "batters": {
+ "batter": [
+ { "id": "1002", "type": "Chocolate" },
+ ]
+ },
+ "topping": [
+ { "id": "5003", "type": "Chocolate" },
+ { "id": "5004", "type": "Maple" }
+ ]
+}"#;
+
+ let grid = grid(1, 1).data([[json]]);
+
+ assert_eq!(
+ grid.clone()
+ .config(
+ |cfg| cfg.set_alignment_horizontal(Entity::Cell(0, 0), AlignmentHorizontal::Left)
+ )
+ .build(),
+ static_table!(
+ r#"+--------------------------------------------------+"#
+ r#"| |"#
+ r#"|{ |"#
+ r#"| "id": "0001", |"#
+ r#"| "batters": { |"#
+ r#"| "batter": [ |"#
+ r#"| { "id": "1002", "type": "Chocolate" },|"#
+ r#"| ] |"#
+ r#"| }, |"#
+ r#"| "topping": [ |"#
+ r#"| { "id": "5003", "type": "Chocolate" }, |"#
+ r#"| { "id": "5004", "type": "Maple" } |"#
+ r#"| ] |"#
+ r#"|} |"#
+ r#"+--------------------------------------------------+"#
+ ),
+ );
+
+ assert_eq!(
+ grid.clone()
+ .config(|cfg| cfg.set_formatting(Entity::Global, Formatting::new(false, false, true)))
+ .build(),
+ static_table!(
+ r#"+--------------------------------------------------+"#
+ r#"| |"#
+ r#"|{ |"#
+ r#"| "id": "0001", |"#
+ r#"| "batters": { |"#
+ r#"| "batter": [ |"#
+ r#"| { "id": "1002", "type": "Chocolate" },|"#
+ r#"| ] |"#
+ r#"| }, |"#
+ r#"| "topping": [ |"#
+ r#"| { "id": "5003", "type": "Chocolate" }, |"#
+ r#"| { "id": "5004", "type": "Maple" } |"#
+ r#"| ] |"#
+ r#"|} |"#
+ r#"+--------------------------------------------------+"#
+ ),
+ );
+
+ assert_eq!(
+ grid.clone()
+ .config(|cfg| cfg.set_formatting(Entity::Global, Formatting::new(true, false, true)))
+ .build(),
+ static_table!(
+ r#"+--------------------------------------------------+"#
+ r#"| |"#
+ r#"|{ |"#
+ r#"|"id": "0001", |"#
+ r#"|"batters": { |"#
+ r#"|"batter": [ |"#
+ r#"|{ "id": "1002", "type": "Chocolate" }, |"#
+ r#"|] |"#
+ r#"|}, |"#
+ r#"|"topping": [ |"#
+ r#"|{ "id": "5003", "type": "Chocolate" }, |"#
+ r#"|{ "id": "5004", "type": "Maple" } |"#
+ r#"|] |"#
+ r#"|} |"#
+ r#"+--------------------------------------------------+"#
+ ),
+ );
+
+ assert_eq!(
+ grid.config(|cfg| cfg.set_formatting(Entity::Global, Formatting::new(true, true, true)))
+ .build(),
+ static_table!(
+ r#"+--------------------------------------------------+"#
+ r#"|{ |"#
+ r#"|"id": "0001", |"#
+ r#"|"batters": { |"#
+ r#"|"batter": [ |"#
+ r#"|{ "id": "1002", "type": "Chocolate" }, |"#
+ r#"|] |"#
+ r#"|}, |"#
+ r#"|"topping": [ |"#
+ r#"|{ "id": "5003", "type": "Chocolate" }, |"#
+ r#"|{ "id": "5004", "type": "Maple" } |"#
+ r#"|] |"#
+ r#"|} |"#
+ r#"| |"#
+ r#"+--------------------------------------------------+"#
+ ),
+ );
+}
+
+#[test]
+fn tabs_arent_handled() {
+ let json = "{
+\t\t \"id\": \"1\",
+\t\t \"name\": \"Hello World\",
+\t\t \"list\": [
+\t\t\t\t [1, 2, 3],
+\t\t\t\t [4, 5, 6],
+\t\t ]
+}";
+
+ let grid = grid(1, 1).data([[json]]);
+
+ assert_eq!(
+ grid.build(),
+ static_table!(
+ "+-----------------------+"
+ "|{ |"
+ "|\t\t \"id\": \"1\", |"
+ "|\t\t \"name\": \"Hello World\",|"
+ "|\t\t \"list\": [ |"
+ "|\t\t\t\t [1, 2, 3], |"
+ "|\t\t\t\t [4, 5, 6], |"
+ "|\t\t ] |"
+ "|} |"
+ "+-----------------------+"
+ ),
+ );
+}
diff --git a/vendor/papergrid/tests/grid/mod.rs b/vendor/papergrid/tests/grid/mod.rs
new file mode 100644
index 000000000..e639d6728
--- /dev/null
+++ b/vendor/papergrid/tests/grid/mod.rs
@@ -0,0 +1,6 @@
+mod column_span;
+mod format_configuration;
+mod render;
+mod row_span;
+mod settings;
+mod styling;
diff --git a/vendor/papergrid/tests/grid/render.rs b/vendor/papergrid/tests/grid/render.rs
new file mode 100644
index 000000000..6c140c9ad
--- /dev/null
+++ b/vendor/papergrid/tests/grid/render.rs
@@ -0,0 +1,251 @@
+// Copyright (c) 2021 Maxim Zhiburt
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+
+#![cfg(feature = "std")]
+
+use std::vec;
+
+use papergrid::{
+ colors::NoColors,
+ config::spanned::SpannedConfig,
+ config::{AlignmentHorizontal, AlignmentVertical, Borders, Entity},
+ grid::iterable::Grid,
+ records::IterRecords,
+};
+
+use crate::util::{grid, ConstantDimension, DEFAULT_BORDERS};
+use testing_table::test_table;
+
+test_table!(render_0x0, grid(0, 0).build(), "");
+
+test_table!(
+ render_1x1,
+ grid(1, 1).change_cell((0, 0), "one line").build(),
+ "+--------+"
+ "|one line|"
+ "+--------+"
+);
+
+test_table!(
+ render_1x1_empty,
+ grid(1, 1).change_cell((0, 0), "").build(),
+ "++"
+ "||"
+ "++"
+);
+
+test_table!(
+ render_1x1_empty_with_height_0,
+ {
+ let data = vec![vec![""]];
+ let data = IterRecords::new(data, 1, Some(1));
+
+ let dims = ConstantDimension(vec![0], vec![0]);
+
+ let mut cfg = SpannedConfig::default();
+ cfg.set_borders(DEFAULT_BORDERS);
+
+ let grid = Grid::new(&data, &dims, &cfg, NoColors);
+ grid.to_string()
+ },
+ "++"
+ "++"
+);
+
+test_table!(
+ render_1x1_empty_with_height_with_width,
+ {
+ let data = vec![vec![String::from("")]];
+ let data = IterRecords::new(&data, 1, Some(1));
+
+ let dims = ConstantDimension(vec![10], vec![0]);
+ let mut cfg = SpannedConfig::default();
+ cfg.set_borders(Borders {
+ top_left: Some('┌'),
+ top_right: Some('┐'),
+ bottom_left: Some('└'),
+ bottom_right: Some('┘'),
+ top: Some('─'),
+ bottom: Some('─'),
+ ..Default::default()
+ });
+
+ let grid = Grid::new(data, &dims, &cfg, NoColors);
+ grid.to_string()
+ },
+ "┌──────────┐"
+ "└──────────┘"
+);
+
+test_table!(
+ render_2x2,
+ grid(2, 2).build(),
+ "+---+---+"
+ "|0-0|0-1|"
+ "+---+---+"
+ "|1-0|1-1|"
+ "+---+---+"
+);
+
+test_table!(
+ render_3x2,
+ grid(3, 2).build(),
+ "+---+---+"
+ "|0-0|0-1|"
+ "+---+---+"
+ "|1-0|1-1|"
+ "+---+---+"
+ "|2-0|2-1|"
+ "+---+---+"
+);
+
+test_table!(
+ render_1x2,
+ grid(1, 2).data([["hello", "world"]]).build(),
+ "+-----+-----+"
+ "|hello|world|"
+ "+-----+-----+"
+);
+
+test_table!(
+ render_multilane,
+ grid(2, 2)
+ .data([
+ ["left\ncell", "right one"],
+ ["the second column got the beginning here", "and here\nwe\nsee\na\nlong\nstring"],
+ ])
+ .build(),
+ "+----------------------------------------+---------+"
+ "|left |right one|"
+ "|cell | |"
+ "+----------------------------------------+---------+"
+ "|the second column got the beginning here|and here |"
+ "| |we |"
+ "| |see |"
+ "| |a |"
+ "| |long |"
+ "| |string |"
+ "+----------------------------------------+---------+"
+);
+
+test_table!(
+ render_multilane_alignment,
+ grid(2, 2)
+ .config(|cfg|{
+ cfg.set_alignment_horizontal(Entity::Cell(0, 0), AlignmentHorizontal::Center);
+ cfg.set_alignment_horizontal(Entity::Cell(1, 1), AlignmentHorizontal::Right);
+ })
+ .data([
+ ["left\ncell", "right one"],
+ ["the second column got the beginning here", "and here\nwe\nsee\na\nlong\nstring"],
+ ])
+ .build(),
+ "+----------------------------------------+---------+"
+ "| left |right one|"
+ "| cell | |"
+ "+----------------------------------------+---------+"
+ "|the second column got the beginning here| and here|"
+ "| | we |"
+ "| | see |"
+ "| | a |"
+ "| | long |"
+ "| | string |"
+ "+----------------------------------------+---------+"
+);
+
+test_table!(
+ render_multilane_vertical_alignment,
+ grid(2, 2)
+ .data([
+ ["left\ncell", "right one"],
+ ["the second column got the beginning here", "and here\nwe\nsee\na\nlong\nstring"],
+ ])
+ .config(|cfg|{
+ cfg.set_alignment_horizontal(Entity::Cell(0, 0), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Entity::Cell(1, 0), AlignmentVertical::Center);
+ cfg.set_alignment_horizontal(Entity::Cell(1, 1), AlignmentHorizontal::Right);
+ })
+ .build(),
+ "+----------------------------------------+---------+"
+ "| left |right one|"
+ "| cell | |"
+ "+----------------------------------------+---------+"
+ "| | and here|"
+ "| | we |"
+ "|the second column got the beginning here| see |"
+ "| | a |"
+ "| | long |"
+ "| | string |"
+ "+----------------------------------------+---------+"
+);
+
+test_table!(
+ render_empty_cell,
+ grid(2, 2).change_cell((0, 1), "").build(),
+ "+---+---+"
+ "|0-0| |"
+ "+---+---+"
+ "|1-0|1-1|"
+ "+---+---+"
+);
+
+test_table!(
+ hieroglyph_multiline_handling,
+ grid(1, 2).data([["哈哈", "哈\n哈"]]).build(),
+ "+----+--+"
+ "|哈哈|哈|"
+ "| |哈|"
+ "+----+--+"
+);
+
+test_table!(
+ hieroglyph_handling_2,
+ grid(2, 1).data([["জী._ডি._ব্লক_সল্টলেক_দূর্গা_পুজো_২০১৮.jpg"], ["Hello"]]).build(),
+ "+------------------------------------+"
+ "|জী._ডি._ব্লক_সল্টলেক_দূর্গা_পুজো_২০১৮.jpg|"
+ "+------------------------------------+"
+ "|Hello |"
+ "+------------------------------------+"
+);
+
+test_table!(
+ doesnt_render_return_carige_0,
+ grid(2, 2).change_cell((0, 1), "123\r\r\r567").build(),
+ "+---+------+"
+ "|0-0|123\r\r\r567|"
+ "+---+------+"
+ "|1-0|1-1 |"
+ "+---+------+"
+);
+
+test_table!(
+ doesnt_render_return_carige_1,
+ grid(2, 2).change_cell((1, 1), "12345678").change_cell((0, 1), "123\r\r\r567").build(),
+ "+---+--------+"
+ "|0-0|123\r\r\r567 |"
+ "+---+--------+"
+ "|1-0|12345678|"
+ "+---+--------+"
+);
+
+// #[test]
+// #[ignore = "I am not sure what is the right behaiviour here"]
+// fn hieroglyph_handling() {
+// let grid = util::grid_from([["哈哈", "哈"]]);
+
+// assert_eq!(
+// grid,
+// "+----+--+\n\
+// |哈哈 |哈 |\n\
+// +----+--+",
+// )
+// }
diff --git a/vendor/papergrid/tests/grid/row_span.rs b/vendor/papergrid/tests/grid/row_span.rs
new file mode 100644
index 000000000..054ee2af3
--- /dev/null
+++ b/vendor/papergrid/tests/grid/row_span.rs
@@ -0,0 +1,1062 @@
+#![cfg(feature = "std")]
+
+use papergrid::config::{
+ AlignmentHorizontal, AlignmentVertical, Borders,
+ Entity::{self, *},
+ Indent, Sides,
+};
+
+use crate::util::grid;
+use testing_table::test_table;
+
+test_table!(
+ _2x2_vertical_alignment_center,
+ grid(2, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_alignment_vertical(Cell(0, 0), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+"
+ "| |0-1|"
+ "+0-0+---+"
+ "| |1-1|"
+ "+---+---+"
+);
+
+test_table!(
+ _2x2_vertical_alignment_bottom,
+ grid(2, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_alignment_vertical(Cell(0, 0), AlignmentVertical::Bottom);
+ })
+ .build(),
+ "+---+---+"
+ "| |0-1|"
+ "+ +---+"
+ "|0-0|1-1|"
+ "+---+---+"
+);
+
+test_table!(
+ _2x2_multiline,
+ grid(2, 2)
+ .change_cell((0, 0), "0-0\n0-1xxx")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_alignment_vertical(Cell(0, 0), AlignmentVertical::Center);
+ })
+ .build(),
+ "+------+---+"
+ "|0-0 |0-1|"
+ "+0-1xxx+---+"
+ "| |1-1|"
+ "+------+---+"
+);
+
+test_table!(
+ _2x2_multiline_vertical_alignment_bottom,
+ grid(2, 2)
+ .change_cell((0, 0), "0-0\n0-1xxx")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_alignment_vertical(Cell(0, 0), AlignmentVertical::Bottom);
+ })
+ .build(),
+ "+------+---+"
+ "| |0-1|"
+ "+0-0 +---+"
+ "|0-1xxx|1-1|"
+ "+------+---+"
+);
+
+test_table!(
+ _4x3_multiline_0,
+ grid(4, 3)
+ .data([
+ ["first line", "0-1", "full last line"],
+ ["", "1", ""],
+ ["0", "1", ""],
+ ["3-0", "3-1", ""],
+ ])
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 2), 4);
+ })
+ .build(),
+ "+----------+---+--------------+"
+ "|first line|0-1|full last line|"
+ "+ +---+ +"
+ "| |1 | |"
+ "+----------+---+ +"
+ "|0 |1 | |"
+ "+----------+---+ +"
+ "|3-0 |3-1| |"
+ "+----------+---+--------------+"
+);
+
+test_table!(
+ _3x2_with_horizontal_ident_on_spanned_cell,
+ grid(3, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_padding(Cell(1, 0), Sides::new(Indent::spaced(4), Indent::spaced(4), Indent::default(), Indent::default()));
+ })
+ .build(),
+ "+---+---+"
+ "|0-0|0-1|"
+ "+ +---+"
+ "| |1-1|"
+ "+---+---+"
+ "|2-0|2-1|"
+ "+---+---+"
+);
+
+test_table!(
+ _3x2_with_horizontal_ident,
+ grid(3, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_padding(Cell(0, 0), Sides::new(Indent::spaced(4), Indent::spaced(4), Indent::default(), Indent::default()));
+ })
+ .build(),
+ "+-----------+---+"
+ "| 0-0 |0-1|"
+ "+ +---+"
+ "| |1-1|"
+ "+-----------+---+"
+ "|2-0 |2-1|"
+ "+-----------+---+"
+);
+
+test_table!(
+ _3x2_with_vertical_ident,
+ grid(3, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_padding(Cell(0, 0), Sides::new(Indent::default(), Indent::default(), Indent::spaced(4), Indent::spaced(4)));
+ })
+ .build(),
+ "+---+---+"
+ "| |0-1|"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+0-0+---+"
+ "| |1-1|"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+---+---+"
+ "|2-0|2-1|"
+ "+---+---+"
+);
+
+test_table!(
+ _3x3_render_0,
+ grid(3, 3)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 3);
+ cfg.set_row_span((0, 1), 2);
+ cfg.set_row_span((0, 2), 2);
+ })
+ .build(),
+ "+---+---+---+"
+ "+0-0+0-1+0-2+"
+ "+ +---+---+"
+ "| |2-1|2-2|"
+ "+---+---+---+"
+);
+
+test_table!(
+ _3x3_render_1,
+ grid(3, 3)
+ .change_cell((0, 1), "t\ne\nx\nt")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 3);
+ cfg.set_row_span((0, 1), 2);
+ cfg.set_row_span((0, 2), 2);
+ })
+ .build(),
+ "+---+---+---+"
+ "|0-0|t |0-2|"
+ "| |e | |"
+ "+ +x + +"
+ "| |t | |"
+ "+ +---+---+"
+ "| |2-1|2-2|"
+ "+---+---+---+"
+);
+
+test_table!(
+ _3x3_coliison_0,
+ grid(3, 3)
+ .change_cell((0, 0), "0-0xxxxxxx")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((1, 1), 2);
+ })
+ .build(),
+ "+----------+---+---+"
+ "|0-0xxxxxxx|0-1|0-2|"
+ "+ +---+---+"
+ "| |1-1|1-2|"
+ "+----------+ +---+"
+ "|2-0 | |2-2|"
+ "+----------+---+---+"
+);
+
+test_table!(
+ _3x3_coliison_1,
+ grid(3, 3)
+ .change_cell((1, 1), "1-1xxxxxxx")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((1, 1), 2);
+ })
+ .build(),
+ "+---+----------+---+"
+ "|0-0|0-1 |0-2|"
+ "+ +----------+---+"
+ "| |1-1xxxxxxx|1-2|"
+ "+---+ +---+"
+ "|2-0| |2-2|"
+ "+---+----------+---+"
+);
+
+test_table!(
+ _3x3_coliison_2,
+ grid(3, 3)
+ .change_cell((1, 1), "1-1\nx\nx\nxxxxx")
+ .change_cell((0, 2), "2-0x\nxxx\nxx\nxxxxxxx")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((1, 1), 2);
+ })
+ .build(),
+ "+---+-----+-------+"
+ "|0-0|0-1 |2-0x |"
+ "| | |xxx |"
+ "| | |xx |"
+ "| | |xxxxxxx|"
+ "+ +-----+-------+"
+ "| |1-1 |1-2 |"
+ "| |x | |"
+ "+---+x +-------+"
+ "|2-0|xxxxx|2-2 |"
+ "+---+-----+-------+"
+);
+
+test_table!(
+ _3x3_coliison_3,
+ grid(3, 3)
+ .change_cell((1, 2), "2-1\nxx\nxx\nxx\nxxxxxx\nx")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((1, 1), 2);
+ })
+ .build(),
+ "+---+---+------+"
+ "|0-0|0-1|0-2 |"
+ "+ +---+------+"
+ "| |1-1|2-1 |"
+ "| | |xx |"
+ "| | |xx |"
+ "| | |xx |"
+ "| | |xxxxxx|"
+ "| | |x |"
+ "+---+ +------+"
+ "|2-0| |2-2 |"
+ "+---+---+------+"
+);
+
+test_table!(
+ _3x3_coliison_4,
+ grid(3, 3)
+ .change_cell((2, 1), "0-2\nx\nx\nx\nx\nxxxxxxx\nx\nx")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((1, 2), 2);
+ })
+ .build(),
+ "+---+-------+---+"
+ "|0-0|0-1 |0-2|"
+ "+ +-------+---+"
+ "| |1-1 |1-2|"
+ "+---+-------+ +"
+ "|2-0|0-2 | |"
+ "| |x | |"
+ "| |x | |"
+ "| |x | |"
+ "| |x | |"
+ "| |xxxxxxx| |"
+ "| |x | |"
+ "| |x | |"
+ "+---+-------+---+"
+);
+
+test_table!(
+ _3x3_first_row,
+ grid(3, 3)
+ .change_cell((0, 0), "0-0\nxx\nx\nx\nx\nx\nx")
+ .config(|cfg|{ cfg.set_row_span((0, 0), 2); })
+ .build(),
+ "+---+---+---+"
+ "|0-0|0-1|0-2|"
+ "|xx | | |"
+ "|x | | |"
+ "+x +---+---+"
+ "|x |1-1|1-2|"
+ "|x | | |"
+ "|x | | |"
+ "+---+---+---+"
+ "|2-0|2-1|2-2|"
+ "+---+---+---+"
+);
+
+test_table!(
+ _2x3_with_different_length,
+ grid(2, 3)
+ .change_cell((0, 0), "f\nir\nst\n ro\nw")
+ .change_cell((0, 2), "a\n \nlonger\n \nsecond\n \nrow")
+ .change_cell((1, 0), "0")
+ .change_cell((1, 1), "1")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 2), 2);
+ })
+ .build(),
+ "+---+---+------+"
+ "|f |0-1|a |"
+ "|ir | | |"
+ "|st | |longer|"
+ "+ ro+---+ +"
+ "|w |1 |second|"
+ "| | | |"
+ "| | |row |"
+ "+---+---+------+"
+);
+
+test_table!(
+ _2x2_with_odd_length,
+ grid(2, 2)
+ .change_cell((0, 0), "3\n \n \n ")
+ .change_cell((0, 1), "2")
+ .change_cell((1, 1), "4")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ })
+ .build(),
+ "+-+-+"
+ "|3|2|"
+ "| | |"
+ "+ +-+"
+ "| |4|"
+ "+-+-+"
+);
+
+test_table!(
+ _2x3_only_col_spaned,
+ grid(2, 3)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ cfg.set_row_span((0, 2), 2);
+ })
+ .build(),
+ "+---+---+---+"
+ "+0-0+0-1+0-2+"
+ "+---+---+---+"
+);
+
+test_table!(
+ _2x2_render_0,
+ grid(2, 2)
+ .change_cell((0, 0), "1\n\n\n\n\n\n\n23")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ })
+ .build(),
+ "+--+---+"
+ "|1 |0-1|"
+ "| | |"
+ "| | |"
+ "| | |"
+ "+ +---+"
+ "| |1-1|"
+ "| | |"
+ "|23| |"
+ "+--+---+"
+);
+
+test_table!(
+ _2x2_render_1,
+ grid(2, 2)
+ .data([["12\n3\n4", "a\ns\ndw"], ["asd", "asd"]])
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ })
+ .build(),
+ "+--+--+"
+ "|12|a |"
+ "+3 +s +"
+ "|4 |dw|"
+ "+--+--+"
+);
+
+test_table!(
+ _2x2_render_2,
+ grid(2, 2)
+ .data([["1", "a"], ["asd", "asd"]])
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ })
+ .build(),
+ "+-+-+"
+ "+1+a+"
+ "+-+-+"
+);
+
+test_table!(
+ _2x2_render_3,
+ grid(2, 2)
+ .data([["1as\nd\n", "a"], ["as\ndasdds\na", "asd"]])
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ })
+ .build(),
+ "+---+-+"
+ "|1as|a|"
+ "+d + +"
+ "| | |"
+ "+---+-+"
+);
+
+test_table!(
+ _2x2_render_4,
+ grid(2, 2)
+ .data([["1as\nd\n", "a"], ["as\ndasdds\na", "asd"]])
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ cfg.set_alignment_vertical(Entity::Global, AlignmentVertical::Center)
+ })
+ .build(),
+ "+---+-+"
+ "|1as| |"
+ "+d +a+"
+ "| | |"
+ "+---+-+"
+);
+
+test_table!(
+ _2x2_render_5,
+ grid(2, 2)
+ .data([["1a\ns\nd\n", "a"], ["as\ndasdds\na", "asd"]])
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ cfg.set_alignment_vertical(Entity::Global, AlignmentVertical::Center)
+ })
+ .build(),
+ "+--+-+"
+ "|1a| |"
+ "|s |a|"
+ "+d + +"
+ "| | |"
+ "+--+-+"
+);
+
+test_table!(
+ _2x2_render_6,
+ grid(2, 2)
+ .data([["1a\ns\nd", "a"], ["as\ndasdds\na", "asd"]])
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ cfg.set_alignment_vertical(Entity::Global, AlignmentVertical::Bottom)
+ })
+ .build(),
+ "+--+-+"
+ "|1a| |"
+ "+s + +"
+ "|d |a|"
+ "+--+-+"
+);
+
+test_table!(
+ _2x2_with_no_split_style,
+ grid(2, 2)
+ .change_cell((0, 0), "1\n2\n3")
+ .config(|cfg|{
+ cfg.set_borders(Borders::default());
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_alignment_vertical(Cell(0, 0), AlignmentVertical::Center);
+ })
+ .build(),
+ "10-1"
+ "2 "
+ "31-1"
+);
+
+test_table!(
+ _3x2_with_zero_row_span_0,
+ grid(3, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ })
+ .build(),
+ "+---+---+"
+ "|0-0|0-1|"
+ "+ +---+"
+ "| |1-1|"
+ "+---+---+"
+ "|2-0|2-1|"
+ "+---+---+"
+);
+
+test_table!(
+ _3x2_with_zero_row_span_1,
+ grid(3, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ })
+ .build(),
+ "+---+---+"
+ "+0-0+0-1+"
+ "+---+---+"
+ "|2-0|2-1|"
+ "+---+---+"
+);
+
+test_table!(
+ _3x2_with_zero_row_span_2,
+ grid(3, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 1), 3);
+ })
+ .build(),
+ "+---+---+"
+ "|0-0|0-1|"
+ "+---+ +"
+ "|1-0| |"
+ "+---+ +"
+ "|2-0| |"
+ "+---+---+"
+);
+
+test_table!(
+ _3x2_with_zero_row_span_3,
+ grid(3, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 1), 3);
+ cfg.set_row_span((0, 0), 3);
+ })
+ .build(),
+ "+---+---+"
+ "+0-0+0-1+"
+ "+ + +"
+ "+---+---+"
+);
+
+test_table!(
+ _2x2_with_zero_row_span_4,
+ grid(2, 2)
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 1), 2);
+ })
+ .build(),
+ "+---+---+"
+ "+0-0+0-1+"
+ "+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_0,
+ grid(4, 4)
+ .change_cell((1, 1), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((1, 1), 2);
+ cfg.set_column_span((1, 1), 2);
+ cfg.set_alignment_horizontal(Cell(1, 1), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(1, 1), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "|0-0|0-1|0-2|0-3|"
+ "+---+---+---+---+"
+ "|1-0| 123 |1-3|"
+ "| | 345 | |"
+ "+---+ 555 +---+"
+ "|2-0| 333 |2-3|"
+ "+---+---+---+---+"
+ "|3-0|3-1|3-2|3-3|"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_1,
+ grid(4, 4)
+ .change_cell((0, 0), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_alignment_horizontal(Cell(0, 0), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(0, 0), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "| 123 |0-2|0-3|"
+ "| 345 | | |"
+ "+ 555 +---+---+"
+ "| 333 |1-2|1-3|"
+ "+---+---+---+---+"
+ "|2-0|2-1|2-2|2-3|"
+ "+---+---+---+---+"
+ "|3-0|3-1|3-2|3-3|"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_2,
+ grid(4, 4)
+ .change_cell((2, 0), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((2, 0), 2);
+ cfg.set_column_span((2, 0), 2);
+ cfg.set_alignment_horizontal(Cell(2, 0), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(2, 0), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "|0-0|0-1|0-2|0-3|"
+ "+---+---+---+---+"
+ "|1-0|1-1|1-2|1-3|"
+ "+---+---+---+---+"
+ "| 123 |2-2|2-3|"
+ "| 345 | | |"
+ "+ 555 +---+---+"
+ "| 333 |3-2|3-3|"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_3,
+ grid(4, 4)
+ .change_cell((2, 2), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((2, 2), 2);
+ cfg.set_column_span((2, 2), 2);
+ cfg.set_alignment_horizontal(Cell(2, 2), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(2, 2), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "|0-0|0-1|0-2|0-3|"
+ "+---+---+---+---+"
+ "|1-0|1-1|1-2|1-3|"
+ "+---+---+---+---+"
+ "|2-0|2-1| 123 |"
+ "| | | 345 |"
+ "+---+---+ 555 +"
+ "|3-0|3-1| 333 |"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_4,
+ grid(4, 4)
+ .change_cell((0, 2), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((0, 2), 2);
+ cfg.set_column_span((0, 2), 2);
+ cfg.set_alignment_horizontal(Cell(0, 2), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(0, 2), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "|0-0|0-1| 123 |"
+ "| | | 345 |"
+ "+---+---+ 555 +"
+ "|1-0|1-1| 333 |"
+ "+---+---+---+---+"
+ "|2-0|2-1|2-2|2-3|"
+ "+---+---+---+---+"
+ "|3-0|3-1|3-2|3-3|"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_5,
+ grid(4, 4)
+ .change_cell((0, 1), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((0, 1), 2);
+ cfg.set_column_span((0, 1), 2);
+ cfg.set_alignment_horizontal(Cell(0, 1), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(0, 1), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "|0-0| 123 |0-3|"
+ "| | 345 | |"
+ "+---+ 555 +---+"
+ "|1-0| 333 |1-3|"
+ "+---+---+---+---+"
+ "|2-0|2-1|2-2|2-3|"
+ "+---+---+---+---+"
+ "|3-0|3-1|3-2|3-3|"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_6,
+ grid(4, 4)
+ .change_cell((1, 1), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((1, 1), 3);
+ cfg.set_column_span((1, 1), 3);
+ cfg.set_alignment_horizontal(Cell(1, 1), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(1, 1), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "|0-0|0-1|0-2|0-3|"
+ "+---+---+---+---+"
+ "|1-0| 123 |"
+ "+---+ 345 +"
+ "|2-0| 555 |"
+ "+---+ 333 +"
+ "|3-0| |"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_7,
+ grid(4, 4)
+ .change_cell((0, 0), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((0, 0), 3);
+ cfg.set_column_span((0, 0), 3);
+ cfg.set_alignment_horizontal(Cell(0, 0), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(0, 0), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "| 123 |0-3|"
+ "+ 345 +---+"
+ "| 555 |1-3|"
+ "+ 333 +---+"
+ "| |2-3|"
+ "+---+---+---+---+"
+ "|3-0|3-1|3-2|3-3|"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_8,
+ grid(4, 4)
+ .change_cell((0, 1), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((0, 1), 3);
+ cfg.set_column_span((0, 1), 3);
+ cfg.set_alignment_horizontal(Cell(0, 1), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(0, 1), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "|0-0| 123 |"
+ "+---+ 345 +"
+ "|1-0| 555 |"
+ "+---+ 333 +"
+ "|2-0| |"
+ "+---+---+---+---+"
+ "|3-0|3-1|3-2|3-3|"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_9,
+ grid(4, 4)
+ .change_cell((1, 0), "123\n345\n555\n333")
+ .config(|cfg|{
+ cfg.set_row_span((1, 0), 3);
+ cfg.set_column_span((1, 0), 3);
+ cfg.set_alignment_horizontal(Cell(1, 0), AlignmentHorizontal::Center);
+ cfg.set_alignment_vertical(Cell(1, 0), AlignmentVertical::Center);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "|0-0|0-1|0-2|0-3|"
+ "+---+---+---+---+"
+ "| 123 |1-3|"
+ "+ 345 +---+"
+ "| 555 |2-3|"
+ "+ 333 +---+"
+ "| |3-3|"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_10,
+ grid(4, 4)
+ .change_cell((0, 0), "hello\nworld\n!\n!\n!\n!")
+ .config(|cfg|{
+ cfg.set_column_span((1, 1), 2);
+ cfg.set_column_span((3, 0), 3);
+ cfg.set_row_span((0, 0), 2);
+ cfg.set_row_span((0, 3), 3);
+ })
+ .build(),
+ "+-----+---+---+---+"
+ "|hello|0-1|0-2|0-3|"
+ "|world| | | |"
+ "|! | | | |"
+ "+! +---+---+ +"
+ "|! |1-1 | |"
+ "|! | | |"
+ "+-----+---+---+ +"
+ "|2-0 |2-1|2-2| |"
+ "+-----+---+---+---+"
+ "|3-0 |3-3|"
+ "+-----+---+---+---+"
+);
+
+test_table!(
+ _4x4_with_row_span_and_col_span_11,
+ grid(4, 4)
+ .change_cell((0, 2), "q\nw\ne\nr\nt")
+ .change_cell((0, 3), "q1\nw1\ne1\nr1\nt1")
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_row_span((0, 2), 2);
+ cfg.set_row_span((0, 3), 3);
+ })
+ .build(),
+ "+---+---+---+---+"
+ "|0-0 |q |q1 |"
+ "| |w |w1 |"
+ "+---+---+e +e1 +"
+ "|1-0|1-1|r |r1 |"
+ "| | |t |t1 |"
+ "+---+---+---+ +"
+ "|2-0|2-1|2-2| |"
+ "+---+---+---+---+"
+ "|3-0|3-1|3-2|3-3|"
+ "+---+---+---+---+"
+);
+
+test_table!(
+ _3x5_with_row_span_and_col_span_12,
+ grid(3, 5)
+ .change_cell((0, 3), "q\nw\ne\nr\nt")
+ .change_cell((0, 4), "q1\nw1\ne1\nr1\nt1")
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_row_span((0, 3), 2);
+ cfg.set_row_span((0, 4), 3);
+ })
+ .build(),
+ "+---+---+---+---+--+"
+ "|0-0 |0-2|q |q1|"
+ "| | |w |w1|"
+ "+---+---+---+e +e1+"
+ "|1-0|1-1|1-2|r |r1|"
+ "| | | |t |t1|"
+ "+---+---+---+---+ +"
+ "|2-0|2-1|2-2|2-3| |"
+ "+---+---+---+---+--+"
+);
+
+test_table!(
+ _3x5_with_row_span_and_col_span_13,
+ grid(3, 5)
+ .change_cell((0, 3), "q\nw\ne\nr\nt\n")
+ .change_cell((0, 4), "q1\nw1\ne1\nr1\nt1\n")
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_row_span((0, 3), 2);
+ cfg.set_row_span((0, 4), 3);
+ })
+ .build(),
+ "+---+---+---+---+--+"
+ "|0-0 |0-2|q |q1|"
+ "| | |w |w1|"
+ "| | |e |e1|"
+ "+---+---+---+r +r1+"
+ "|1-0|1-1|1-2|t |t1|"
+ "| | | | | |"
+ "+---+---+---+---+ +"
+ "|2-0|2-1|2-2|2-3| |"
+ "+---+---+---+---+--+"
+);
+
+test_table!(
+ _3x5_with_row_span_and_col_span_14,
+ grid(3, 5)
+ .change_cell((0, 3), "q\nw\ne\nr\nt\n")
+ .change_cell((0, 4), "q1\nw1\ne1\nr1\nt1\n")
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_row_span((0, 3), 2);
+ cfg.set_row_span((0, 4), 3);
+ cfg.set_padding(
+ Cell(0, 0),
+ Sides::new(Indent::new(2, ' '), Indent::new(2, ' '), Indent::new(2, ' '), Indent::new(2, ' '))
+ );
+ cfg.set_padding(
+ Cell(0, 3),
+ Sides::new(Indent::new(2, ' '), Indent::new(2, ' '), Indent::new(2, ' '), Indent::new(2, ' '))
+ );
+ cfg.set_padding(
+ Cell(1, 2),
+ Sides::new(Indent::new(2, ' '), Indent::new(2, ' '), Indent::new(4, ' '), Indent::new(2, ' '))
+ );
+ })
+ .build(),
+ "+---+---+-------+-----+--+"
+ "| |0-2 | |q1|"
+ "| | | |w1|"
+ "| 0-0 | | q |e1|"
+ "| | | w |r1|"
+ "| | | e |t1|"
+ "+---+---+-------+ r + +"
+ "|1-0|1-1| | t | |"
+ "| | | | | |"
+ "| | | | | |"
+ "| | | | | |"
+ "| | | 1-2 | | |"
+ "| | | | | |"
+ "| | | | | |"
+ "+---+---+-------+-----+ +"
+ "|2-0|2-1|2-2 |2-3 | |"
+ "+---+---+-------+-----+--+"
+);
+
+// is this correct?
+test_table!(
+ _3x4_with_row_span_and_col_span_13,
+ grid(3, 5)
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 0), 2);
+ cfg.set_row_span((1, 0), 2);
+ })
+ .build(),
+ "+-+-+---+---+---+"
+ "|0-0|0-2|0-3|0-4|"
+ "+-+-+---+---+---+"
+ "|1-0|1-2|1-3|1-4|"
+ "+ +---+---+---+"
+ "| |2-2|2-3|2-4|"
+ "+-+-+---+---+---+"
+);
+
+test_table!(
+ _5x2_render_0,
+ grid(5, 2)
+ .change_cell((1, 1), "1\n2\n3\n4")
+ .config(|cfg|{
+ cfg.set_row_span((1, 1), 4);
+ })
+ .build(),
+ "+---+---+"
+ "|0-0|0-1|"
+ "+---+---+"
+ "|1-0|1 |"
+ "+---+2 +"
+ "|2-0|3 |"
+ "+---+4 +"
+ "|3-0| |"
+ "+---+ +"
+ "|4-0| |"
+ "+---+---+"
+);
+
+test_table!(
+ _3x4_column_span_0,
+ grid(3, 4)
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 2);
+ cfg.set_column_span((1, 0), 2);
+ cfg.set_column_span((2, 0), 2);
+ })
+ .build(),
+ "+-+-+---+---+"
+ "|0-0|0-2|0-3|"
+ "+-+-+---+---+"
+ "|1-0|1-2|1-3|"
+ "+-+-+---+---+"
+ "|2-0|2-2|2-3|"
+ "+-+-+---+---+"
+);
+
+test_table!(
+ _3x4_column_span_1,
+ grid(3, 4)
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 3);
+ cfg.set_column_span((1, 0), 3);
+ cfg.set_column_span((2, 0), 3);
+ })
+ .build(),
+ "+-+++---+"
+ "|0-0|0-3|"
+ "+-+++---+"
+ "|1-0|1-3|"
+ "+-+++---+"
+ "|2-0|2-3|"
+ "+-+++---+"
+);
+
+test_table!(
+ _3x4_column_span_2,
+ grid(3, 4)
+ .change_cell((0, 0), "")
+ .change_cell((1, 0), "")
+ .change_cell((2, 0), "")
+ .config(|cfg|{
+ cfg.set_column_span((0, 0), 3);
+ cfg.set_column_span((1, 0), 3);
+ cfg.set_column_span((2, 0), 3);
+ })
+ .build(),
+ "++++---+"
+ "| |0-3|"
+ "++++---+"
+ "| |1-3|"
+ "++++---+"
+ "| |2-3|"
+ "++++---+"
+);
+
+// #[test]
+// #[ignore = "todo; create some logic of combining spans? or somehow resolving to not get the following"]
+// fn render_grid_with_row_3() {
+// let mut grid = util::new_grid::<3, 5>();
+
+// grid.set(Entity::Cell(0, 0), Settings::new().span(2));
+// grid.set(Entity::Cell(0, 1), Settings::new().span(2));
+// grid.set(Entity::Cell(0, 2), Settings::new().span(2));
+
+// assert_eq!(
+// grid.to_string(),
+// concat!(
+// "+---+---+---+---+--+\n",
+// "|0-0 |0-2|q |q1|\n",
+// "| | |w |w1|\n",
+// "+---+---+---+e +e1+\n",
+// "|1-0|1-1|1-2|r |r1|\n",
+// "| | | |t |t1|\n",
+// "+---+---+---+---+ +\n",
+// "|2-0|2-1|2-2|2-3| |\n",
+// "+---+---+---+---+--+\n",
+// )
+// );
+// }
diff --git a/vendor/papergrid/tests/grid/settings.rs b/vendor/papergrid/tests/grid/settings.rs
new file mode 100644
index 000000000..7e0446aab
--- /dev/null
+++ b/vendor/papergrid/tests/grid/settings.rs
@@ -0,0 +1,265 @@
+#![cfg(feature = "std")]
+
+use papergrid::color::AnsiColor;
+use papergrid::config::{AlignmentHorizontal, Border, Borders, Entity, Indent, Sides};
+
+use crate::util::grid;
+use testing_table::test_table;
+
+test_table!(
+ override_by_global_alignment_0,
+ grid(2, 2)
+ .data([["xxxxx", "xx"], ["y", "yyyyyyyyyy"]])
+ .config(|cfg| cfg.set_alignment_horizontal(Entity::Cell(0, 1), AlignmentHorizontal::Right))
+ .build(),
+ "+-----+----------+"
+ "|xxxxx| xx|"
+ "+-----+----------+"
+ "|y |yyyyyyyyyy|"
+ "+-----+----------+"
+);
+
+test_table!(
+ override_by_global_alignment_1,
+ grid(2, 2)
+ .data([["xxxxx", "xx"], ["y", "yyyyyyyyyy"]])
+ .config(|cfg| cfg.set_alignment_horizontal(Entity::Global, AlignmentHorizontal::Center))
+ .build(),
+ "+-----+----------+"
+ "|xxxxx| xx |"
+ "+-----+----------+"
+ "| y |yyyyyyyyyy|"
+ "+-----+----------+"
+);
+
+test_table!(
+ remove_border_test,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders::default());
+ cfg.set_border(
+ (0, 0),
+ Border {
+ top: Some('x'),
+ bottom: Some('o'),
+ left: Some('q'),
+ ..Default::default()
+ },
+ );
+
+ cfg.remove_border((0, 0), (2, 2));
+ })
+ .build(),
+ "0-00-1\n1-01-1"
+);
+
+test_table!(
+ entity_row_overrides_column_intersection_0,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders::default());
+ cfg.set_padding(
+ Entity::Column(0),
+ Sides {
+ bottom: Indent::new(3, '$'),
+ ..Default::default()
+ },
+ );
+ })
+ .build(),
+ "0-00-1"
+ "$$$ "
+ "$$$ "
+ "$$$ "
+ "1-01-1"
+ "$$$ "
+ "$$$ "
+ "$$$ "
+);
+
+test_table!(
+ entity_row_overrides_column_intersection_1,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders::default());
+ cfg.set_padding(
+ Entity::Column(0),
+ Sides {
+ bottom: Indent::new(3, '$'),
+ ..Default::default()
+ },
+ );
+ cfg.set_padding(
+ Entity::Row(1),
+ Sides {
+ bottom: Indent::new(2, '#'),
+ ..Default::default()
+ },
+ );
+ })
+ .build(),
+ "0-00-1"
+ "$$$ "
+ "$$$ "
+ "$$$ "
+ "1-01-1"
+ "######"
+ "######"
+);
+
+test_table!(
+ entity_column_overrides_row_intersection_0,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders::default());
+ cfg.set_padding(
+ Entity::Row(0),
+ Sides {
+ bottom: Indent::new(3, '$'),
+ ..Default::default()
+ },
+ );
+ })
+ .build(),
+ "0-00-1\n$$$$$$\n$$$$$$\n$$$$$$\n1-01-1"
+);
+
+test_table!(
+ entity_column_overrides_row_intersection_1,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders::default());
+ cfg.set_padding(
+ Entity::Row(0),
+ Sides::new(
+ Indent::default(),
+ Indent::default(),
+ Indent::default(),
+ Indent::new(3, '$'),
+ ),
+ );
+ cfg.set_padding(
+ Entity::Column(1),
+ Sides::new(
+ Indent::default(),
+ Indent::default(),
+ Indent::default(),
+ Indent::new(2, '#'),
+ ),
+ );
+ })
+ .build(),
+ "0-00-1\n$$$###\n$$$###\n$$$###\n1-01-1\n ###\n ###"
+);
+
+test_table!(
+ test_justification_char_left_alignment,
+ grid(2, 2)
+ .data([["Hello", "World"], ["", "Hello Hello Hello Hello Hello"]])
+ .config(|cfg| cfg.set_justification(Entity::Global, '$'))
+ .build(),
+ "+-----+-----------------------------+"
+ "|Hello|World$$$$$$$$$$$$$$$$$$$$$$$$|"
+ "+-----+-----------------------------+"
+ "|$$$$$|Hello Hello Hello Hello Hello|"
+ "+-----+-----------------------------+"
+);
+
+test_table!(
+ test_justification_char_right_alignment,
+ grid(2, 2)
+ .data([["Hello", "World"], ["", "Hello Hello Hello Hello Hello"]])
+ .config(|cfg| {
+ cfg.set_justification(Entity::Global, '$');
+ cfg.set_alignment_horizontal(Entity::Global, AlignmentHorizontal::Right);
+ })
+ .build(),
+ "+-----+-----------------------------+"
+ "|Hello|$$$$$$$$$$$$$$$$$$$$$$$$World|"
+ "+-----+-----------------------------+"
+ "|$$$$$|Hello Hello Hello Hello Hello|"
+ "+-----+-----------------------------+"
+);
+
+test_table!(
+ test_justification_char_center_alignment,
+ grid(2, 2)
+ .data([["Hello", "World"], ["", "Hello Hello Hello Hello Hello"]])
+ .config(|cfg| {
+ cfg.set_justification(Entity::Global, '$');
+ cfg.set_alignment_horizontal(Entity::Global, AlignmentHorizontal::Center);
+ })
+ .build(),
+ "+-----+-----------------------------+"
+ "|Hello|$$$$$$$$$$$$World$$$$$$$$$$$$|"
+ "+-----+-----------------------------+"
+ "|$$$$$|Hello Hello Hello Hello Hello|"
+ "+-----+-----------------------------+"
+);
+
+test_table!(
+ test_justification_color_left_alignment,
+ grid(2, 2)
+ .data([["Hello", "World"], ["", "Hello Hello Hello Hello Hello"]])
+ .config(|cfg| {
+ cfg.set_justification(Entity::Global, '$');
+ cfg.set_justification_color(Entity::Global, Some(AnsiColor::new("\u{1b}[34m".into(), "\u{1b}[39m".into())));
+ })
+ .build(),
+ "+-----+-----------------------------+"
+ "|Hello|World\u{1b}[34m$$$$$$$$$$$$$$$$$$$$$$$$\u{1b}[39m|"
+ "+-----+-----------------------------+"
+ "|\u{1b}[34m$$$$$\u{1b}[39m|Hello Hello Hello Hello Hello|"
+ "+-----+-----------------------------+"
+);
+
+test_table!(
+ test_justification_color_right_alignment,
+ grid(2, 2)
+ .data([["Hello", "World"], ["", "Hello Hello Hello Hello Hello"]])
+ .config(|cfg| {
+ cfg.set_justification(Entity::Global, '$');
+ cfg.set_justification_color(Entity::Global, Some(AnsiColor::new("\u{1b}[34m".into(), "\u{1b}[39m".into())));
+ cfg.set_alignment_horizontal(Entity::Global, AlignmentHorizontal::Right);
+ })
+ .build(),
+ "+-----+-----------------------------+"
+ "|Hello|\u{1b}[34m$$$$$$$$$$$$$$$$$$$$$$$$\u{1b}[39mWorld|"
+ "+-----+-----------------------------+"
+ "|\u{1b}[34m$$$$$\u{1b}[39m|Hello Hello Hello Hello Hello|"
+ "+-----+-----------------------------+"
+);
+
+test_table!(
+ test_justification_color_center_alignment,
+ grid(2, 2)
+ .data([["Hello", "World"], ["", "Hello Hello Hello Hello Hello"]])
+ .config(|cfg| {
+ cfg.set_justification(Entity::Global, '$');
+ cfg.set_justification_color(Entity::Global, Some(AnsiColor::new("\u{1b}[34m".into(), "\u{1b}[39m".into())));
+ cfg.set_alignment_horizontal(Entity::Global, AlignmentHorizontal::Center);
+ })
+ .build(),
+ "+-----+-----------------------------+"
+ "|Hello|\u{1b}[34m$$$$$$$$$$$$\u{1b}[39mWorld\u{1b}[34m$$$$$$$$$$$$\u{1b}[39m|"
+ "+-----+-----------------------------+"
+ "|\u{1b}[34m$$\u{1b}[39m\u{1b}[34m$$$\u{1b}[39m|Hello Hello Hello Hello Hello|"
+ "+-----+-----------------------------+"
+);
+
+test_table!(
+ test_justification_color_center_alignment_entity,
+ grid(2, 2)
+ .data([["Hello", "World"], ["", "Hello Hello Hello Hello Hello"]])
+ .config(|cfg| {
+ cfg.set_justification(Entity::Cell(0, 0), '$');
+ cfg.set_justification_color(Entity::Column(1), Some(AnsiColor::new("\u{1b}[34m".into(), "\u{1b}[39m".into())));
+ cfg.set_alignment_horizontal(Entity::Row(2), AlignmentHorizontal::Center);
+ })
+ .build(),
+ "+-----+-----------------------------+"
+ "|Hello|World\u{1b}[34m \u{1b}[39m|"
+ "+-----+-----------------------------+"
+ "| |Hello Hello Hello Hello Hello|"
+ "+-----+-----------------------------+"
+);
diff --git a/vendor/papergrid/tests/grid/styling.rs b/vendor/papergrid/tests/grid/styling.rs
new file mode 100644
index 000000000..b1886a8de
--- /dev/null
+++ b/vendor/papergrid/tests/grid/styling.rs
@@ -0,0 +1,334 @@
+#![cfg(feature = "std")]
+
+use papergrid::config::{AlignmentHorizontal, Border, Borders, Entity, Indent, Sides};
+
+use crate::util::grid;
+use testing_table::test_table;
+
+#[cfg(feature = "color")]
+use ::{owo_colors::OwoColorize, papergrid::color::AnsiColor, std::convert::TryFrom};
+
+test_table!(
+ grid_2x2_custom_frame_test,
+ grid(2, 2)
+ .config(|cfg| (0..2).for_each(|r| (0..2).for_each(|c| cfg.set_border((r, c), Border::full('*', '*', '|', '|', '#', '#', '#', '#')))))
+ .build(),
+ "#***#***#"
+ "|0-0|0-1|"
+ "#***#***#"
+ "|1-0|1-1|"
+ "#***#***#"
+);
+
+test_table!(
+ grid_2x2_custom_column_test_0,
+ grid(2, 2)
+ .config(|cfg| (0..2).for_each(|r| cfg.set_border((r, 1), Border::full('*', '*', '|', '|', '#', '#', '#', '#'))))
+ .build(),
+ "+---#***#"
+ "|0-0|0-1|"
+ "+---#***#"
+ "|1-0|1-1|"
+ "+---#***#"
+);
+
+test_table!(
+ grid_2x2_custom_column_test_1,
+ grid(2, 2)
+ .config(|cfg| (0..2).for_each(|r| cfg.set_border((r, 0), Border::full('*', '*', '|', '|', '#', '#', '#', '#'))))
+ .build(),
+ "#***#---+"
+ "|0-0|0-1|"
+ "#***#---+"
+ "|1-0|1-1|"
+ "#***#---+"
+);
+
+test_table!(
+ grid_2x2_custom_row_test_0,
+ grid(2, 2)
+ .config(|cfg| (0..2).for_each(|c| cfg.set_border((0, c), Border::full('*', '*', '|', '|', '#', '#', '#', '#'))))
+ .build(),
+ "#***#***#"
+ "|0-0|0-1|"
+ "#***#***#"
+ "|1-0|1-1|"
+ "+---+---+"
+);
+
+test_table!(
+ grid_2x2_custom_row_test_1,
+ grid(2, 2)
+ .config(|cfg| (0..2).for_each(|c| cfg.set_border((1, c), Border::full('*', '*', '|', '|', '#', '#', '#', '#'))))
+ .build(),
+ "+---+---+"
+ "|0-0|0-1|"
+ "#***#***#"
+ "|1-0|1-1|"
+ "#***#***#"
+);
+
+test_table!(
+ grid_2x2_change_cell_border_test_0,
+ grid(2, 2)
+ .config(|cfg| (0..2).for_each(|_| cfg.set_border((0, 1), Border::full('*', '^', '@', '#', '~', '!', '%', '&'))))
+ .build(),
+ "+---~***!"
+ "|0-0@0-1#"
+ "+---%^^^&"
+ "|1-0|1-1|"
+ "+---+---+"
+);
+
+test_table!(
+ grid_2x2_alignment_test_0,
+ grid(2, 2)
+ .change_cell((0, 0), "asd ")
+ .change_cell((0, 1), "asd ")
+ .config(|cfg| {
+ cfg.set_alignment_horizontal(Entity::Column(0), AlignmentHorizontal::Left);
+ cfg.set_alignment_horizontal(Entity::Column(1), AlignmentHorizontal::Right);
+ })
+ .build(),
+ "+-------+-------+"
+ "|asd |asd |"
+ "+-------+-------+"
+ "|1-0 | 1-1|"
+ "+-------+-------+"
+);
+
+test_table!(
+ grid_2x2_alignment_test_1,
+ grid(2, 2)
+ .data([["asd ", "asd "], ["asd ", "asd "]])
+ .config(|cfg| {
+ cfg.set_alignment_horizontal(Entity::Column(0), AlignmentHorizontal::Left);
+ cfg.set_alignment_horizontal(Entity::Column(1), AlignmentHorizontal::Right);
+ })
+ .build(),
+ "+-------+-------+"
+ "|asd |asd |"
+ "+-------+-------+"
+ "|asd |asd |"
+ "+-------+-------+"
+);
+
+test_table!(
+ grid_2x2_indent_test,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_padding(
+ Entity::Global,
+ Sides::new(
+ Indent::spaced(1),
+ Indent::spaced(1),
+ Indent::spaced(1),
+ Indent::spaced(1),
+ ),
+ );
+ cfg.set_padding(Entity::Column(0), Sides::new(
+ Indent::default(),
+ Indent::default(),
+ Indent::default(),
+ Indent::default(),
+ ));
+ })
+ .build(),
+ "+---+-----+"
+ "|0-0| |"
+ "| | 0-1 |"
+ "| | |"
+ "+---+-----+"
+ "|1-0| |"
+ "| | 1-1 |"
+ "| | |"
+ "+---+-----+"
+);
+
+test_table!(
+ grid_2x2_vertical_resize_test,
+ grid(2, 2).change_cell((1, 1), "asd ").build(),
+ "+---+--------+"
+ "|0-0|0-1 |"
+ "+---+--------+"
+ "|1-0|asd |"
+ "+---+--------+"
+);
+
+test_table!(
+ grid_2x2_without_frame_test_0,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders {
+ vertical: Some(' '),
+ ..Default::default()
+ });
+ })
+ .build(),
+ "0-0 0-1"
+ "1-0 1-1"
+);
+
+test_table!(
+ grid_2x2_without_frame_test_1,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders {
+ vertical: Some(' '),
+ horizontal: Some(' '),
+ intersection: Some(' '),
+ ..Default::default()
+ });
+ })
+ .build(),
+ "0-0 0-1"
+ " "
+ "1-0 1-1"
+);
+
+test_table!(
+ grid_2x2_custom_border_test,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_border(
+ (0, 0),
+ Border {
+ bottom: Some('-'),
+ top: Some('*'),
+ left: Some('$'),
+ left_top_corner: Some(' '),
+ left_bottom_corner: Some('+'),
+ ..Default::default()
+ },
+ );
+ cfg.set_border(
+ (0, 1),
+ Border::full('*', '-', '@', '%', ' ', ' ', '+', '+'),
+ );
+ cfg.set_border(
+ (1, 0),
+ Border {
+ bottom: Some('*'),
+ left: Some('#'),
+ left_top_corner: Some('+'),
+ left_bottom_corner: Some('\u{0020}'),
+ ..Default::default()
+ },
+ );
+ cfg.set_border(
+ (1, 1),
+ Border {
+ bottom: Some('*'),
+ left: Some('^'),
+ left_top_corner: Some('+'),
+ right_top_corner: Some('+'),
+ right: Some('!'),
+ left_bottom_corner: Some(' '),
+ right_bottom_corner: Some(' '),
+ ..Default::default()
+ },
+ );
+ })
+ .build(),
+ " *** *** "
+ "$0-0@0-1%"
+ "+---+---+"
+ "#1-0^1-1!"
+ "\u{0020}*** *** "
+);
+
+test_table!(
+ when_border_is_not_complete_default_char_is_used_test,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders {
+ vertical: Some(' '),
+ ..Default::default()
+ });
+ cfg.set_border(
+ (1, 1),
+ Border {
+ top: Some('*'),
+ ..Default::default()
+ },
+ );
+ })
+ .build(),
+ "0-0 0-1"
+ " ***"
+ "1-0 1-1"
+);
+
+test_table!(
+ when_1_vertical_is_set_second_must_use_default_test,
+ grid(2, 2)
+ .config(|cfg| {
+ cfg.set_borders(Borders::default());
+ cfg.set_border(
+ (1, 0),
+ Border {
+ right: Some('*'),
+ ..Default::default()
+ },
+ );
+ })
+ .build(),
+ "0-0 0-1"
+ "1-0*1-1"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ grid_2x2_ansi_border_test,
+ grid(2, 2)
+ .config(|cfg| {
+ (0..2).for_each(|r| (0..2).for_each(|c| {
+ let top = AnsiColor::try_from(" ".green().on_red().to_string()).unwrap();
+ let bottom = AnsiColor::try_from(" ".on_green().blue().to_string()).unwrap();
+ let left = AnsiColor::try_from(" ".on_red().white().to_string()).unwrap();
+ let right = AnsiColor::try_from(" ".on_red().green().to_string()).unwrap();
+ let tl = AnsiColor::try_from(" ".magenta().to_string()).unwrap();
+ let tr = AnsiColor::try_from(" ".on_blue().to_string()).unwrap();
+ let bl = AnsiColor::try_from(" ".yellow().to_string()).unwrap();
+ let br = AnsiColor::try_from(" ".on_yellow().to_string()).unwrap();
+
+ cfg.set_border((r, c), Border::full('*', '#', '~', '!', '@', '$', '%', '^'));
+ cfg.set_border_color((r, c), Border::full(top, bottom, left, right, tl, tr, bl, br));
+ }))
+ })
+ .build(),
+ "\u{1b}[35m@\u{1b}[39m\u{1b}[32m\u{1b}[41m***\u{1b}[39m\u{1b}[49m\u{1b}[35m@\u{1b}[39m\u{1b}[32m\u{1b}[41m***\u{1b}[39m\u{1b}[49m\u{1b}[44m$\u{1b}[49m"
+ "\u{1b}[37m\u{1b}[41m~\u{1b}[39m\u{1b}[49m0-0\u{1b}[37m\u{1b}[41m~\u{1b}[39m\u{1b}[49m0-1\u{1b}[32m\u{1b}[41m!\u{1b}[39m\u{1b}[49m"
+ "\u{1b}[35m@\u{1b}[39m\u{1b}[32m\u{1b}[41m***\u{1b}[39m\u{1b}[49m\u{1b}[35m@\u{1b}[39m\u{1b}[32m\u{1b}[41m***\u{1b}[39m\u{1b}[49m\u{1b}[44m$\u{1b}[49m"
+ "\u{1b}[37m\u{1b}[41m~\u{1b}[39m\u{1b}[49m1-0\u{1b}[37m\u{1b}[41m~\u{1b}[39m\u{1b}[49m1-1\u{1b}[32m\u{1b}[41m!\u{1b}[39m\u{1b}[49m"
+ "\u{1b}[33m%\u{1b}[39m\u{1b}[34m\u{1b}[42m###\u{1b}[39m\u{1b}[49m\u{1b}[33m%\u{1b}[39m\u{1b}[34m\u{1b}[42m###\u{1b}[39m\u{1b}[49m\u{1b}[43m^\u{1b}[49m"
+);
+
+#[cfg(feature = "color")]
+test_table!(
+ grid_2x2_ansi_global_set_test,
+ grid(2, 2)
+ .config(|cfg| {
+ let color = " ".on_blue().red().bold().to_string();
+ cfg.set_border_color_global(AnsiColor::try_from(color).unwrap());
+ })
+ .build(),
+ "\u{1b}[1m\u{1b}[31m\u{1b}[44m+---+---+\u{1b}[22m\u{1b}[39m\u{1b}[49m"
+ "\u{1b}[1m\u{1b}[31m\u{1b}[44m|\u{1b}[22m\u{1b}[39m\u{1b}[49m0-0\u{1b}[1m\u{1b}[31m\u{1b}[44m|\u{1b}[22m\u{1b}[39m\u{1b}[49m0-1\u{1b}[1m\u{1b}[31m\u{1b}[44m|\u{1b}[22m\u{1b}[39m\u{1b}[49m"
+ "\u{1b}[1m\u{1b}[31m\u{1b}[44m+---+---+\u{1b}[22m\u{1b}[39m\u{1b}[49m"
+ "\u{1b}[1m\u{1b}[31m\u{1b}[44m|\u{1b}[22m\u{1b}[39m\u{1b}[49m1-0\u{1b}[1m\u{1b}[31m\u{1b}[44m|\u{1b}[22m\u{1b}[39m\u{1b}[49m1-1\u{1b}[1m\u{1b}[31m\u{1b}[44m|\u{1b}[22m\u{1b}[39m\u{1b}[49m"
+ "\u{1b}[1m\u{1b}[31m\u{1b}[44m+---+---+\u{1b}[22m\u{1b}[39m\u{1b}[49m"
+);
+
+#[cfg(feature = "color")]
+#[test]
+fn grid_2x2_ansi_border_none_if_string_is_not_1_char_test() {
+ assert!(AnsiColor::try_from("12").is_ok());
+ assert!(AnsiColor::try_from("123").is_ok());
+ assert!(AnsiColor::try_from("").is_err());
+
+ assert!(AnsiColor::try_from("1").is_ok());
+ assert!(AnsiColor::try_from("1".on_red().to_string()).is_ok());
+ assert!(AnsiColor::try_from("1".on_red().blue().to_string()).is_ok());
+ assert!(AnsiColor::try_from("1".truecolor(0, 1, 3).on_truecolor(1, 2, 3).to_string()).is_ok());
+}