[A] Added more cpp tests.
This commit is contained in:
@@ -1,42 +1,12 @@
|
||||
#include "tests.h"
|
||||
#include "fort.hpp"
|
||||
|
||||
#define assert_string_equal(str1, str2) assert_str_equal(str1.c_str(), str2.c_str())
|
||||
|
||||
bool set_test_props_for_table(fort::Table *table)
|
||||
{
|
||||
assert_true(table->set_cell_bottom_padding(FT_ANY_ROW, FT_ANY_COLUMN, 1));
|
||||
assert_true(table->set_cell_top_padding(FT_ANY_ROW, FT_ANY_COLUMN, 1));
|
||||
assert_true(table->set_cell_left_padding(FT_ANY_ROW, FT_ANY_COLUMN, 1));
|
||||
assert_true(table->set_cell_right_padding(FT_ANY_ROW, FT_ANY_COLUMN, 1));
|
||||
assert_true(table->set_cell_empty_str_height(FT_ANY_ROW, FT_ANY_COLUMN, 1));
|
||||
|
||||
struct ft_border_style brdr_style;
|
||||
brdr_style.border_chs.top_border_ch = "-";
|
||||
brdr_style.border_chs.separator_ch = "-";
|
||||
brdr_style.border_chs.bottom_border_ch = "-";
|
||||
brdr_style.border_chs.side_border_ch = "|";
|
||||
brdr_style.border_chs.out_intersect_ch = "+";
|
||||
brdr_style.border_chs.in_intersect_ch = "+";
|
||||
|
||||
brdr_style.header_border_chs.top_border_ch = "-";
|
||||
brdr_style.header_border_chs.separator_ch = "-";
|
||||
brdr_style.header_border_chs.bottom_border_ch = "-";
|
||||
brdr_style.header_border_chs.side_border_ch = "|";
|
||||
brdr_style.header_border_chs.out_intersect_ch = "+";
|
||||
brdr_style.header_border_chs.in_intersect_ch = "+";
|
||||
|
||||
brdr_style.hor_separator_char = "=";
|
||||
table->set_border_style(&brdr_style);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void test_cpp_table_basic(void)
|
||||
{
|
||||
WHEN("All columns are equal and not empty.") {
|
||||
fort::Table table;
|
||||
assert_true(set_test_props_for_table(&table));
|
||||
fort::table table;
|
||||
assert_true(set_cpp_test_props_for_table(&table));
|
||||
|
||||
table << fort::header
|
||||
<< "3" << "c" << "234" << "3.140000" << fort::endr
|
||||
@@ -62,20 +32,20 @@ void test_cpp_table_basic(void)
|
||||
}
|
||||
|
||||
WHEN("Checking basic constructors and assignmets.") {
|
||||
fort::Table table;
|
||||
assert_true(set_test_props_for_table(&table));
|
||||
fort::table table;
|
||||
assert_true(set_cpp_test_props_for_table(&table));
|
||||
|
||||
table << fort::header
|
||||
<< "3" << "c" << "234" << "3.140000" << fort::endr
|
||||
<< "3" << "c" << "234" << "3.140000" << fort::endr
|
||||
<< "3" << "c" << "234" << "3.140000" << fort::endr;
|
||||
|
||||
fort::Table table2(std::move(table));
|
||||
fort::Table table3;
|
||||
fort::table table2(std::move(table));
|
||||
fort::table table3;
|
||||
table3 = std::move(table2);
|
||||
|
||||
fort::Table table4(table3);
|
||||
fort::Table table5;
|
||||
fort::table table4(table3);
|
||||
fort::table table5;
|
||||
table5 = table4;
|
||||
|
||||
std::string table_str = table5.to_string();
|
||||
@@ -97,8 +67,8 @@ void test_cpp_table_basic(void)
|
||||
}
|
||||
|
||||
WHEN("All columns are not equal and not empty") {
|
||||
fort::Table table;
|
||||
assert_true(set_test_props_for_table(&table));
|
||||
fort::table table;
|
||||
assert_true(set_cpp_test_props_for_table(&table));
|
||||
|
||||
table << fort::header
|
||||
<< "3" << "c" << "234" << "3.140000" << fort::endr
|
||||
@@ -124,8 +94,8 @@ void test_cpp_table_basic(void)
|
||||
}
|
||||
|
||||
WHEN("All columns are not equal and some cells are empty") {
|
||||
fort::Table table;
|
||||
assert_true(set_test_props_for_table(&table));
|
||||
fort::table table;
|
||||
assert_true(set_cpp_test_props_for_table(&table));
|
||||
|
||||
table << fort::header
|
||||
<< "" << "" << "234" << "3.140000" << fort::endr
|
||||
@@ -151,8 +121,8 @@ void test_cpp_table_basic(void)
|
||||
}
|
||||
|
||||
WHEN("All cells are empty") {
|
||||
fort::Table table;
|
||||
assert_true(set_test_props_for_table(&table));
|
||||
fort::table table;
|
||||
assert_true(set_cpp_test_props_for_table(&table));
|
||||
|
||||
table << fort::header
|
||||
<< "" << "" << "" << "" << fort::endr
|
||||
@@ -182,8 +152,8 @@ void test_cpp_table_basic(void)
|
||||
void test_cpp_table_write(void)
|
||||
{
|
||||
SCENARIO("Test write functions") {
|
||||
fort::Table table;
|
||||
assert_true(set_test_props_for_table(&table));
|
||||
fort::table table;
|
||||
assert_true(set_cpp_test_props_for_table(&table));
|
||||
table << fort::header;
|
||||
assert_true(table.write("3"));
|
||||
assert_true(table.write("c"));
|
||||
@@ -224,8 +194,8 @@ void test_cpp_table_write(void)
|
||||
}
|
||||
|
||||
SCENARIO("Test n write functions") {
|
||||
fort::Table table;
|
||||
assert_true(set_test_props_for_table(&table));
|
||||
fort::table table;
|
||||
assert_true(set_cpp_test_props_for_table(&table));
|
||||
table << fort::header;
|
||||
assert_true(table.write("3", "c", "234", "3.140000"));
|
||||
table << fort::endr;
|
||||
@@ -256,8 +226,8 @@ void test_cpp_table_write(void)
|
||||
}
|
||||
|
||||
SCENARIO("Test row_write functions") {
|
||||
fort::Table table;
|
||||
assert_true(set_test_props_for_table(&table));
|
||||
fort::table table;
|
||||
assert_true(set_cpp_test_props_for_table(&table));
|
||||
|
||||
table << fort::header;
|
||||
const char *row_0[4] = {"3", "c", "234", "3.140000"};
|
||||
|
524
tests/bb_tests_cpp/test_table_properties.cpp
Normal file
524
tests/bb_tests_cpp/test_table_properties.cpp
Normal file
@@ -0,0 +1,524 @@
|
||||
#include "tests.h"
|
||||
#include "fort.hpp"
|
||||
|
||||
|
||||
void test_cpp_table_tbl_properties(void)
|
||||
{
|
||||
fort::table table;
|
||||
WHEN("Test setting entire table properties") {
|
||||
set_test_properties_as_default();
|
||||
|
||||
table = create_cpp_test_int_table(false);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
|
||||
/* Now set table properties */
|
||||
table.set_top_margin(3);
|
||||
table.set_bottom_margin(4);
|
||||
table.set_left_margin(1);
|
||||
table.set_right_margin(2);
|
||||
|
||||
table_str = table.to_string();
|
||||
table_str_etalon =
|
||||
" \n"
|
||||
" \n"
|
||||
" \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" | | | | | \n"
|
||||
" | 3 | 4 | 55 | 67 | \n"
|
||||
" | | | | | \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" | | | | | \n"
|
||||
" | 3 | 4 | 55 | 67 | \n"
|
||||
" | | | | | \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" | | | | | \n"
|
||||
" | 3 | 4 | 55 | 67 | \n"
|
||||
" | | | | | \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" \n"
|
||||
" \n"
|
||||
" \n"
|
||||
" \n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
}
|
||||
|
||||
void test_cpp_table_cell_properties(void)
|
||||
{
|
||||
|
||||
WHEN("Setting property for one cell") {
|
||||
set_test_properties_as_default();
|
||||
|
||||
fort::table table = create_cpp_test_int_table(false);
|
||||
table[1][1].set_cell_top_padding(2);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | | 55 | 67 |\n"
|
||||
"| | 4 | | |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Setting property for the row") {
|
||||
set_test_properties_as_default();
|
||||
|
||||
fort::table table = create_cpp_test_int_table(false);
|
||||
table[1].set_cell_top_padding(2);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Setting property for the column") {
|
||||
set_test_properties_as_default();
|
||||
|
||||
fort::table table = create_cpp_test_int_table(false);
|
||||
table.column(1).set_cell_top_padding(2);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | | 55 | 67 |\n"
|
||||
"| | 4 | | |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | | 55 | 67 |\n"
|
||||
"| | 4 | | |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | | 55 | 67 |\n"
|
||||
"| | 4 | | |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Setting property for all cells in the table") {
|
||||
set_test_properties_as_default();
|
||||
|
||||
fort::table table = create_cpp_test_int_table(false);
|
||||
table.set_cell_top_padding(2);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("All paddings = 1") {
|
||||
// NOT IMPLEMENTED !!!!!!!!!!!!!!
|
||||
}
|
||||
|
||||
WHEN("Top and bottom padding = 0") {
|
||||
// NOT IMPLEMENTED !!!!!!!!!!!!!!
|
||||
}
|
||||
|
||||
WHEN("Left and right padding = 0") {
|
||||
// NOT IMPLEMENTED !!!!!!!!!!!!!!
|
||||
}
|
||||
|
||||
WHEN("All paddings = 0") {
|
||||
// NOT IMPLEMENTED !!!!!!!!!!!!!!
|
||||
}
|
||||
|
||||
WHEN("Empty string has 0 heigt") {
|
||||
// NOT IMPLEMENTED !!!!!!!!!!!!!!
|
||||
}
|
||||
|
||||
WHEN("Setting properties for a particular table") {
|
||||
set_test_properties_as_default();
|
||||
fort::table table = create_cpp_test_int_table(false);
|
||||
table.set_cell_bottom_padding(0);
|
||||
table.set_cell_top_padding(0);
|
||||
table.set_cell_left_padding(0);
|
||||
table.set_cell_right_padding(0);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
|
||||
table.set_cell_bottom_padding(1);
|
||||
table.set_cell_top_padding(1);
|
||||
table.set_cell_left_padding(0);
|
||||
table.set_cell_right_padding(0);
|
||||
table.set_cell_empty_str_height(0);
|
||||
|
||||
table_str = table.to_string();
|
||||
table_str_etalon =
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Set table width and column alignment") {
|
||||
set_test_properties_as_default();
|
||||
fort::table table = create_cpp_test_int_table(false);
|
||||
|
||||
table.column(1).set_cell_min_width(7);
|
||||
table.column(1).set_cell_text_align(fort::text_align::left);
|
||||
table.column(2).set_cell_min_width(8);
|
||||
table.column(2).set_cell_text_align(fort::text_align::center);
|
||||
|
||||
table[2][3].set_cell_min_width(6);
|
||||
table[2][3].set_cell_text_align(fort::text_align::left);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+---+-------+--------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+-------+--------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+-------+--------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+-------+--------+------+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Set table width and column alignment as default") {
|
||||
// NOT IMPLEMENTED !!!!!!!!!!!!!!
|
||||
|
||||
}
|
||||
|
||||
WHEN("Multiline cell") {
|
||||
|
||||
set_test_properties_as_default();
|
||||
fort::table table;
|
||||
table[0].set_cell_row_type(fort::row_type::header);
|
||||
|
||||
table << 4 << 'c' << "234" << 3.14 << fort::endr;
|
||||
assert_true(table.write_ln("5", "c", "234\n12", "3.140000"));
|
||||
table << 3 << 'c' << "234" << 3.14 << fort::endr;
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 4 | c | 234 | 3.14 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 5 | c | 234 | 3.140000 |\n"
|
||||
"| | | 12 | |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.14 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Cells with spans") {
|
||||
set_test_properties_as_default();
|
||||
fort::table table;
|
||||
|
||||
table[0][0].set_cell_span(5);
|
||||
table[1][1].set_cell_span(3);
|
||||
|
||||
table[0].set_cell_row_type(fort::row_type::header);
|
||||
table[1].set_cell_row_type(fort::row_type::header);
|
||||
|
||||
assert_true(table.write_ln("111", "2222", "33333", "444444", "55555555"));
|
||||
assert_true(table.write_ln("2222", "33333", "444444", "55555555", "111"));
|
||||
|
||||
assert_true(table.write_ln("33333", "444444", "55555555", "111", "2222"));
|
||||
assert_true(table.write_ln("2222", "33333", "444444", "55555555", "111"));
|
||||
assert_true(table.write_ln("2222", "33333", "444444", "55555555", "111"));
|
||||
|
||||
table[4][3].set_cell_span(2);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+---------------------------------------------+\n"
|
||||
"| |\n"
|
||||
"| 111 |\n"
|
||||
"| |\n"
|
||||
"+-------+------------------------------+------+\n"
|
||||
"| | | |\n"
|
||||
"| 2222 | 33333 | 111 |\n"
|
||||
"| | | |\n"
|
||||
"+-------+--------+----------+----------+------+\n"
|
||||
"| | | | | |\n"
|
||||
"| 33333 | 444444 | 55555555 | 111 | 2222 |\n"
|
||||
"| | | | | |\n"
|
||||
"+-------+--------+----------+----------+------+\n"
|
||||
"| | | | | |\n"
|
||||
"| 2222 | 33333 | 444444 | 55555555 | 111 |\n"
|
||||
"| | | | | |\n"
|
||||
"+-------+--------+----------+----------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 2222 | 33333 | 444444 | 55555555 |\n"
|
||||
"| | | | |\n"
|
||||
"+-------+--------+----------+-----------------+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Cells with spans in common and header cells") {
|
||||
set_test_properties_as_default();
|
||||
fort::table table;
|
||||
|
||||
table.set_border_style(FT_DOUBLE2_STYLE);
|
||||
|
||||
table[0][0].set_cell_span(2);
|
||||
table[0][2].set_cell_span(3);
|
||||
table[1][1].set_cell_span(3);
|
||||
table[4][3].set_cell_span(2);
|
||||
|
||||
assert_true(table.write_ln("111", "2222", "33333", "444444", "55555555"));
|
||||
assert_true(table.write_ln("2222", "33333", "444444", "55555555", "111"));
|
||||
|
||||
assert_true(table.write_ln("33333", "444444", "55555555", "111", "2222"));
|
||||
assert_true(table.write_ln("2222", "33333", "444444", "55555555", "111"));
|
||||
assert_true(table.write_ln("2222", "33333", "444444", "55555555", "111"));
|
||||
|
||||
table[0].set_cell_row_type(fort::row_type::header);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"╔════════════════╤════════════════════════════╗\n"
|
||||
"║ │ ║\n"
|
||||
"║ 111 │ 33333 ║\n"
|
||||
"║ │ ║\n"
|
||||
"╠═══════╤════════╧═════════════════════╤══════╣\n"
|
||||
"║ │ │ ║\n"
|
||||
"║ 2222 │ 33333 │ 111 ║\n"
|
||||
"║ │ │ ║\n"
|
||||
"╟───────┼────────┬──────────┬──────────┼──────╢\n"
|
||||
"║ │ │ │ │ ║\n"
|
||||
"║ 33333 │ 444444 │ 55555555 │ 111 │ 2222 ║\n"
|
||||
"║ │ │ │ │ ║\n"
|
||||
"╟───────┼────────┼──────────┼──────────┼──────╢\n"
|
||||
"║ │ │ │ │ ║\n"
|
||||
"║ 2222 │ 33333 │ 444444 │ 55555555 │ 111 ║\n"
|
||||
"║ │ │ │ │ ║\n"
|
||||
"╟───────┼────────┼──────────┼──────────┴──────╢\n"
|
||||
"║ │ │ │ ║\n"
|
||||
"║ 2222 │ 33333 │ 444444 │ 55555555 ║\n"
|
||||
"║ │ │ │ ║\n"
|
||||
"╚═══════╧════════╧══════════╧═════════════════╝\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_cpp_table_text_styles(void)
|
||||
{
|
||||
set_test_properties_as_default();
|
||||
|
||||
WHEN("Simple table with one cell and foreground content color") {
|
||||
fort::table table;
|
||||
|
||||
table[0][0].set_cell_content_fg_color(fort::color::yellow);
|
||||
table << 42;
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+----+\n"
|
||||
"|\033[33m\033[39m |\n"
|
||||
"| \033[33m42\033[39m |\n"
|
||||
"|\033[33m\033[39m |\n"
|
||||
"+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Simple table with one cell and background content color") {
|
||||
fort::table table;
|
||||
|
||||
table[0][0].set_cell_content_bg_color(fort::color::yellow);
|
||||
table << 42;
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+----+\n"
|
||||
"|\033[43m\033[49m |\n"
|
||||
"| \033[43m42\033[49m |\n"
|
||||
"|\033[43m\033[49m |\n"
|
||||
"+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Simple table with one cell and background cell color") {
|
||||
fort::table table;
|
||||
|
||||
table[0][0].set_cell_cell_bg_color(fort::color::yellow);
|
||||
table << 42;
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+----+\n"
|
||||
"|\033[43m \033[49m|\n"
|
||||
"|\033[43m 42 \033[49m|\n"
|
||||
"|\033[43m \033[49m|\n"
|
||||
"+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Simple table with one cell and content style") {
|
||||
fort::table table;
|
||||
|
||||
table[0][0].set_cell_content_text_style(fort::text_style::underlined);
|
||||
table << 42;
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+----+\n"
|
||||
"|\033[4m\033[24m |\n"
|
||||
"| \033[4m42\033[24m |\n"
|
||||
"|\033[4m\033[24m |\n"
|
||||
"+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Simple table with one cell and multiple content style") {
|
||||
fort::table table;
|
||||
|
||||
table[0][0].set_cell_content_text_style(fort::text_style::underlined);
|
||||
table[0][0].set_cell_content_text_style(fort::text_style::bold);
|
||||
table << 42;
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+----+\n"
|
||||
"|\033[1m\033[4m\033[21m\033[24m |\n"
|
||||
"| \033[1m\033[4m42\033[21m\033[24m |\n"
|
||||
"|\033[1m\033[4m\033[21m\033[24m |\n"
|
||||
"+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Simple table with one cell and cell style") {
|
||||
fort::table table;
|
||||
|
||||
table[0][0].set_cell_cell_text_style(fort::text_style::underlined);
|
||||
table << 42;
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+----+\n"
|
||||
"|\033[4m \033[24m|\n"
|
||||
"|\033[4m 42 \033[24m|\n"
|
||||
"|\033[4m \033[24m|\n"
|
||||
"+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Simple table with one cell and multiple cell style") {
|
||||
fort::table table;
|
||||
|
||||
table[0][0].set_cell_cell_text_style(fort::text_style::underlined);
|
||||
table[0][0].set_cell_cell_text_style(fort::text_style::bold);
|
||||
table << 42;
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+----+\n"
|
||||
"|\033[1m\033[4m \033[21m\033[24m|\n"
|
||||
"|\033[1m\033[4m 42 \033[21m\033[24m|\n"
|
||||
"|\033[1m\033[4m \033[21m\033[24m|\n"
|
||||
"+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
WHEN("Simple table with one cell background color, content foreground color and style.") {
|
||||
fort::table table;
|
||||
|
||||
table[0][0].set_cell_content_fg_color(fort::color::yellow);
|
||||
table[0][0].set_cell_cell_bg_color(fort::color::red);
|
||||
table[0][0].set_cell_content_text_style(fort::text_style::underlined);
|
||||
table << 42;
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+----+\n"
|
||||
"|\033[41m\033[4m\033[33m\033[24m\033[39m \033[49m|\n"
|
||||
"|\033[41m \033[4m\033[33m42\033[24m\033[39m \033[49m|\n"
|
||||
"|\033[41m\033[4m\033[33m\033[24m\033[39m \033[49m|\n"
|
||||
"+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user