2018-03-19 21:07:18 +01:00
|
|
|
#include "tests.h"
|
2018-05-06 13:11:03 +02:00
|
|
|
#include "fort.h"
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_table_border_style(void)
|
|
|
|
{
|
2018-05-05 21:34:45 +02:00
|
|
|
ft_table_t *table = NULL;
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
set_test_options_as_default();
|
|
|
|
|
|
|
|
|
|
|
|
WHEN("Changing cell separators") {
|
|
|
|
|
|
|
|
struct ft_border_style brdr_style;
|
2018-05-02 20:16:41 +02:00
|
|
|
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 = "v";
|
|
|
|
brdr_style.header_border_chs.out_intersect_ch = "+";
|
|
|
|
brdr_style.header_border_chs.in_intersect_ch = "#";
|
|
|
|
|
|
|
|
brdr_style.hor_separator_char = "|";
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_set_default_border_style(&brdr_style);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+***+***+****+****+\n"
|
|
|
|
"v v v v v\n"
|
|
|
|
"v 3 v 4 v 55 v 67 v\n"
|
|
|
|
"v v v v v\n"
|
|
|
|
"+***#***#****#****+\n"
|
|
|
|
"= = = = =\n"
|
|
|
|
"= 3 = 4 = 55 = 67 =\n"
|
|
|
|
"= = = = =\n"
|
|
|
|
"+|||#|||#||||#||||+\n"
|
|
|
|
"= = = = =\n"
|
|
|
|
"= 3 = 4 = 55 = 67 =\n"
|
|
|
|
"= = = = =\n"
|
|
|
|
"+|||+|||+||||+||||+\n";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-05-02 20:16:41 +02:00
|
|
|
brdr_style.border_chs.top_border_ch = "|";
|
|
|
|
brdr_style.border_chs.separator_ch = "\0";
|
|
|
|
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 = "\0";
|
2018-03-19 21:07:18 +01:00
|
|
|
|
2018-05-02 20:16:41 +02:00
|
|
|
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 = "v";
|
|
|
|
brdr_style.header_border_chs.out_intersect_ch = "+";
|
|
|
|
brdr_style.header_border_chs.in_intersect_ch = "#";
|
|
|
|
|
|
|
|
brdr_style.hor_separator_char = "";
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
ft_set_default_border_style(&brdr_style);
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 0);
|
|
|
|
ft_set_default_cell_option(FT_COPT_TOP_PADDING, 0);
|
|
|
|
ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_EMPTY_STR_HEIGHT, 0);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+***+***+****+****+\n"
|
|
|
|
"v 3 v 4 v 55 v 67 v\n"
|
|
|
|
"+***#***#****#****+\n"
|
|
|
|
"= 3 = 4 = 55 = 67 =\n"
|
|
|
|
"= 3 = 4 = 55 = 67 =\n"
|
|
|
|
"+|||+|||+||||+||||+\n";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WHEN("Separator testing") {
|
|
|
|
table = create_test_int_table(1);
|
|
|
|
ft_add_separator(table);
|
|
|
|
|
2018-04-01 12:27:02 +02:00
|
|
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
2018-03-19 21:07:18 +01:00
|
|
|
int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
|
|
|
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(n == 4);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+---+---+----+----+\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"
|
|
|
|
"| 3 | 4 | 55 | 67 |\n"
|
|
|
|
"| | | | |\n"
|
|
|
|
"+---+---+----+----+\n";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
}
|