From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/tabled/tests/settings/merge_test.rs | 196 +++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 vendor/tabled/tests/settings/merge_test.rs (limited to 'vendor/tabled/tests/settings/merge_test.rs') 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 |" + "+---+---+---+" +); -- cgit v1.2.3