[A] Added left and right table margins

This commit is contained in:
seleznevae
2018-03-25 11:32:10 +03:00
parent 52c100bdf9
commit 49d36179bd
4 changed files with 168 additions and 27 deletions

View File

@@ -39,35 +39,92 @@ void test_table_tbl_options(void)
/* Now set table options */
ft_set_tbl_option(table, FT_TOPT_TOP_MARGIN, 3);
ft_set_tbl_option(table, FT_TOPT_BOTTOM_MARGIN, 4);
// ft_set_tbl_option(table, FT_TOPT_LEFT_MARGIN, 1);
// ft_set_tbl_option(table, FT_TOPT_RIGHT_MARGIN, 2);
ft_set_tbl_option(table, FT_TOPT_LEFT_MARGIN, 1);
ft_set_tbl_option(table, FT_TOPT_RIGHT_MARGIN, 2);
table_str = ft_to_string(table);
assert_true( table_str != NULL );
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";
" \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_str_equal(table_str, table_str_etalon);
ft_destroy_table(table);
}
WHEN("Test setting entire table options") {
set_test_options_as_default();
table = create_test_int_wtable(0);
const wchar_t *table_str = ft_to_wstring(table);
assert_true( table_str != NULL );
const wchar_t *table_str_etalon =
L"+---+---+----+----+\n"
L"| | | | |\n"
L"| 3 | 4 | 55 | 67 |\n"
L"| | | | |\n"
L"+---+---+----+----+\n"
L"| | | | |\n"
L"| 3 | 4 | 55 | 67 |\n"
L"| | | | |\n"
L"+---+---+----+----+\n"
L"| | | | |\n"
L"| 3 | 4 | 55 | 67 |\n"
L"| | | | |\n"
L"+---+---+----+----+\n";
assert_wcs_equal(table_str, table_str_etalon);
/* Now set table options */
ft_set_tbl_option(table, FT_TOPT_TOP_MARGIN, 3);
ft_set_tbl_option(table, FT_TOPT_BOTTOM_MARGIN, 4);
ft_set_tbl_option(table, FT_TOPT_LEFT_MARGIN, 1);
ft_set_tbl_option(table, FT_TOPT_RIGHT_MARGIN, 2);
table_str = ft_to_wstring(table);
assert_true( table_str != NULL );
table_str_etalon =
L" \n"
L" \n"
L" \n"
L" +---+---+----+----+ \n"
L" | | | | | \n"
L" | 3 | 4 | 55 | 67 | \n"
L" | | | | | \n"
L" +---+---+----+----+ \n"
L" | | | | | \n"
L" | 3 | 4 | 55 | 67 | \n"
L" | | | | | \n"
L" +---+---+----+----+ \n"
L" | | | | | \n"
L" | 3 | 4 | 55 | 67 | \n"
L" | | | | | \n"
L" +---+---+----+----+ \n"
L" \n"
L" \n"
L" \n"
L" \n";
assert_wcs_equal(table_str, table_str_etalon);
ft_destroy_table(table);
}
}

View File

@@ -80,14 +80,13 @@ FTABLE *create_test_int_table(int set_test_opts)
if (set_test_opts) {
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
}
// ft_set_table_options(table, &test_table_opts);
assert_true (table != NULL);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
assert_true( n == 4 );
// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
int n = FT_NWRITE_LN(table, "3", "4", "55", "67");
assert(n == FT_SUCCESS);
assert(ft_write(table, "3") == FT_SUCCESS);
assert(ft_write(table, "4") == FT_SUCCESS);
@@ -101,3 +100,33 @@ FTABLE *create_test_int_table(int set_test_opts)
return table;
}
FTABLE *create_test_int_wtable(int set_test_opts)
{
FTABLE *table = NULL;
table = ft_create_table();
assert_true( table != NULL );
if (set_test_opts) {
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
}
assert_true (table != NULL);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
int n = FT_NWWRITE_LN(table, L"3", L"4", L"55", L"67");
assert(n == FT_SUCCESS);
assert(ft_wwrite(table, L"3") == FT_SUCCESS);
assert(ft_wwrite(table, L"4") == FT_SUCCESS);
assert(ft_wwrite(table, L"55") == FT_SUCCESS);
assert(ft_wwrite_ln(table, L"67") == FT_SUCCESS);
assert(ft_wwrite(table, L"3") == FT_SUCCESS);
assert(ft_wwrite(table, L"4") == FT_SUCCESS);
assert(ft_wwrite(table, L"55") == FT_SUCCESS);
assert(ft_wwrite_ln(table, L"67") == FT_SUCCESS);
return table;
}

View File

@@ -60,6 +60,8 @@ struct test_case
int set_test_options_for_table(FTABLE *table);
int set_test_options_as_default();
FTABLE *create_test_int_table(int set_test_opts);
FTABLE *create_test_int_wtable(int set_test_opts);