[C] Changed main header file

This commit is contained in:
seleznevae 2018-03-14 22:18:59 +03:00
parent df072fc364
commit 2f4708e71a
4 changed files with 122 additions and 114 deletions

View File

@ -7,10 +7,10 @@
static FTABLE *create_basic_table()
{
FTABLE *table = ft_create_table();
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
FT_NWRITE_LN(table, "Rank", "Title", "Year", "Rating");
FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
@ -33,10 +33,10 @@ int main()
table = ft_create_table();
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
FT_NWWRITE_LN(table, L"Rank", L"Title", L"Year", L"Rating");
FT_NWWRITE_LN(table, L"1", L"Побег из Шоушенка", L"1994", L"9.5");
@ -59,10 +59,10 @@ int main()
/*-------------------------------------------------------------*/
table = ft_create_table();
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_printf_ln(table, "%d|%s|%5.2f km/s", 1, "Mercury", 47.362);
ft_printf_ln(table, "%d|%s|%5.2f km/s", 1, "Mercury", 47.362);
@ -76,10 +76,10 @@ int main()
/*-------------------------------------------------------------*/
table = ft_create_table();
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_printf_ln(table, "Rank|Title|Year|Rating");
FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
@ -95,10 +95,10 @@ int main()
/*-------------------------------------------------------------*/
table = ft_create_table();
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_printf_ln(table, "Commodity|Farm price|Avg. spread");
const char *row1[] = {"Potatoes", "$1.60", "200.94%"};
@ -113,10 +113,10 @@ int main()
/*-------------------------------------------------------------*/
table = ft_create_table();
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_printf_ln(table, "No.|Name|Avg. Mark");
const char *ctab[2][3] = {
{"1", "Joe Public", "3.14"},
@ -133,10 +133,10 @@ int main()
table = ft_create_table();
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
ft_set_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_printf_ln(table, "No.|Name|Avg. Mark");
const char **tab[2] = {
row1,
@ -151,27 +151,27 @@ int main()
/*---------------- Different styles --------------------*/
ft_set_default_borders(FT_BASIC_STYLE);
ft_set_default_border_style(FT_BASIC_STYLE);
table = create_basic_table();
printf("Table:\n%s\n", ft_to_string(table));
ft_destroy_table(table);
ft_set_default_borders(FT_SIMPLE_STYLE);
ft_set_default_border_style(FT_SIMPLE_STYLE);
table = create_basic_table();
printf("Table:\n%s\n", ft_to_string(table));
ft_destroy_table(table);
ft_set_default_borders(FT_PLAIN_STYLE);
ft_set_default_border_style(FT_PLAIN_STYLE);
table = create_basic_table();
printf("Table:\n%s\n", ft_to_string(table));
ft_destroy_table(table);
ft_set_default_borders(FT_DOT_STYLE);
ft_set_default_border_style(FT_DOT_STYLE);
table = create_basic_table();
printf("Table:\n%s\n", ft_to_string(table));
ft_destroy_table(table);
ft_set_default_borders(FT_EMPTY_STYLE);
ft_set_default_border_style(FT_EMPTY_STYLE);
table = create_basic_table();
printf("Table:\n%s\n", ft_to_string(table));
ft_destroy_table(table);

View File

@ -77,7 +77,6 @@ SOFTWARE.
#define FT_INLINE __inline
#endif /* if defined(__cplusplus) */
/* #define FT_RESTRICT*/
/*
@ -240,17 +239,7 @@ FT_EXTERN int ft_nwrite(FTABLE *FT_RESTRICT table, size_t n, const char* FT_REST
FT_EXTERN int ft_nwrite_ln(FTABLE *FT_RESTRICT table, size_t n, const char* FT_RESTRICT cell_content, ...);
#ifdef FT_HAVE_WCHAR
FT_EXTERN int ft_wwrite(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content);
FT_EXTERN int ft_wwrite_ln(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content);
#define FT_NWWRITE(table, ...)\
(0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite(table, PP_NARG(__VA_ARGS__), __VA_ARGS__))
#define FT_NWWRITE_LN(table, ...)\
(0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite_ln(table, PP_NARG(__VA_ARGS__), __VA_ARGS__))
FT_EXTERN int ft_nwwrite(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...);
FT_EXTERN int ft_nwwrite_ln(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...);
#endif
@ -276,9 +265,6 @@ FT_EXTERN int ft_add_separator(FTABLE *FT_RESTRICT table);
FT_EXTERN const char* ft_to_string(const FTABLE *FT_RESTRICT table);
FT_EXTERN const wchar_t* ft_to_wstring(const FTABLE *FT_RESTRICT table);
/*FT_EXTERN ssize_t ft_n_to_string(const FTABLE *FT_RESTRICT table, char *FT_RESTRICT dst, size_t dst_len);*/
@ -307,11 +293,33 @@ extern struct ft_border_style * FT_DOT_STYLE;
extern struct ft_border_style * FT_EMPTY_STYLE;
FT_EXTERN int ft_set_default_borders(struct ft_border_style *style);
FT_EXTERN int ft_set_table_borders(FTABLE * FT_RESTRICT table, struct ft_border_style *style);
FT_EXTERN int ft_set_default_border_style(struct ft_border_style *style);
FT_EXTERN int ft_set_border_style(FTABLE * FT_RESTRICT table, struct ft_border_style *style);
FT_EXTERN int ft_set_default_option(uint32_t option, int value);
FT_EXTERN int ft_set_option(FTABLE * FT_RESTRICT table, unsigned row, unsigned col, uint32_t option, int value);
#ifdef FT_HAVE_WCHAR
FT_EXTERN int ft_wwrite(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content);
FT_EXTERN int ft_wwrite_ln(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content);
#define FT_NWWRITE(table, ...)\
(0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite(table, PP_NARG(__VA_ARGS__), __VA_ARGS__))
#define FT_NWWRITE_LN(table, ...)\
(0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite_ln(table, PP_NARG(__VA_ARGS__), __VA_ARGS__))
FT_EXTERN int ft_nwwrite(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...);
FT_EXTERN int ft_nwwrite_ln(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...);
FT_EXTERN const wchar_t* ft_to_wstring(const FTABLE *FT_RESTRICT table);
#endif
FT_EXTERN int ft_set_default_cell_option(uint32_t option, int value);
FT_EXTERN int ft_set_cell_option(FTABLE * FT_RESTRICT table, unsigned row, unsigned col, uint32_t option, int value);
FT_END_DECLS

View File

@ -744,13 +744,13 @@ static void set_border_options_for_options(fort_table_options_t *options, struct
}
int ft_set_default_borders(struct ft_border_style *style)
int ft_set_default_border_style(struct ft_border_style *style)
{
set_border_options_for_options(&g_table_options, style);
return F_SUCCESS;
}
int ft_set_table_borders(FTABLE *table, struct ft_border_style *style)
int ft_set_border_style(FTABLE *table, struct ft_border_style *style)
{
assert(table);
if (table->options == NULL) {
@ -764,7 +764,7 @@ int ft_set_table_borders(FTABLE *table, struct ft_border_style *style)
int ft_set_cell_option(FTABLE *table, unsigned row, unsigned col, uint32_t option, int value)
int ft_set_option(FTABLE *table, unsigned row, unsigned col, uint32_t option, int value)
{
assert(table);
@ -782,7 +782,7 @@ int ft_set_cell_option(FTABLE *table, unsigned row, unsigned col, uint32_t optio
return set_cell_option(table->options->cell_options, row, col, option, value);
}
int ft_set_default_cell_option(uint32_t option, int value)
int ft_set_default_option(uint32_t option, int value)
{
return set_default_cell_option(option, value);
}

View File

@ -14,11 +14,11 @@ int set_test_options_for_table(FTABLE *table)
{
assert(table);
int status = F_SUCCESS;
status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_BOTTOM_PADDING, 1);
status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_TOP_PADDING, 1);
status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_LEFT_PADDING, 1);
status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_RIGHT_PADDING, 1);
status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_EMPTY_STR_HEIGHT, 1);
status |= ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_BOTTOM_PADDING, 1);
status |= ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_TOP_PADDING, 1);
status |= ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_LEFT_PADDING, 1);
status |= ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_RIGHT_PADDING, 1);
status |= ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_EMPTY_STR_HEIGHT, 1);
assert_true( status == F_SUCCESS );
@ -39,21 +39,21 @@ int set_test_options_for_table(FTABLE *table)
brdr_style.header_border_chs.in_intersect_ch = '+';
brdr_style.hor_separator_char = '=';
return ft_set_table_borders(table, &brdr_style);
return ft_set_border_style(table, &brdr_style);
}
int set_test_options_as_default()
{
int status = F_SUCCESS;
status |= ft_set_default_cell_option(FT_OPT_MIN_WIDTH, 0);
status |= ft_set_default_cell_option(FT_OPT_TEXT_ALIGN, RightAligned);
status |= ft_set_default_option(FT_OPT_MIN_WIDTH, 0);
status |= ft_set_default_option(FT_OPT_TEXT_ALIGN, RightAligned);
status |= ft_set_default_cell_option(FT_OPT_BOTTOM_PADDING, 1);
status |= ft_set_default_cell_option(FT_OPT_TOP_PADDING, 1);
status |= ft_set_default_cell_option(FT_OPT_LEFT_PADDING, 1);
status |= ft_set_default_cell_option(FT_OPT_RIGHT_PADDING, 1);
status |= ft_set_default_cell_option(FT_OPT_EMPTY_STR_HEIGHT, 1);
status |= ft_set_default_option(FT_OPT_BOTTOM_PADDING, 1);
status |= ft_set_default_option(FT_OPT_TOP_PADDING, 1);
status |= ft_set_default_option(FT_OPT_LEFT_PADDING, 1);
status |= ft_set_default_option(FT_OPT_RIGHT_PADDING, 1);
status |= ft_set_default_option(FT_OPT_EMPTY_STR_HEIGHT, 1);
assert_true( status == F_SUCCESS );
@ -75,7 +75,7 @@ int set_test_options_as_default()
brdr_style.hor_separator_char = '=';
return ft_set_default_borders(&brdr_style);
return ft_set_default_border_style(&brdr_style);
}
void test_table_sizes(void **state)
@ -182,7 +182,7 @@ void test_table_basic(void **state)
// ft_set_table_options(table, &test_table_opts);
assert_true( set_test_options_for_table(table) == F_SUCCESS);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
int n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14);
assert_true( n == 4 );
@ -222,7 +222,7 @@ void test_table_basic(void **state)
// ft_set_table_options(table, &test_table_opts);
assert_true( set_test_options_for_table(table) == F_SUCCESS);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
int n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14);
assert_true( n == 4 );
@ -260,7 +260,7 @@ void test_table_basic(void **state)
// ft_set_table_options(table, &test_table_opts);
assert_true( set_test_options_for_table(table) == F_SUCCESS);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
int n = ft_printf_ln(table, "||%s|%f", "234", 3.14);
assert_true( n == 4 );
@ -298,7 +298,7 @@ void test_table_basic(void **state)
// ft_set_table_options(table, &test_table_opts);
assert_true( set_test_options_for_table(table) == F_SUCCESS);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
int n = ft_printf_ln(table, "|||");
assert_true( n == 4 );
@ -347,7 +347,7 @@ FTABLE *create_test_int_table(int set_test_opts)
assert_true (table != NULL);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
assert_true( n == 4 );
@ -377,10 +377,10 @@ void test_table_options(void **state)
WHEN("All paddings = 1") {
set_test_options_as_default();
ft_set_default_cell_option(FT_OPT_BOTTOM_PADDING, 1);
ft_set_default_cell_option(FT_OPT_TOP_PADDING, 1);
ft_set_default_cell_option(FT_OPT_LEFT_PADDING, 1);
ft_set_default_cell_option(FT_OPT_RIGHT_PADDING, 1);
ft_set_default_option(FT_OPT_BOTTOM_PADDING, 1);
ft_set_default_option(FT_OPT_TOP_PADDING, 1);
ft_set_default_option(FT_OPT_LEFT_PADDING, 1);
ft_set_default_option(FT_OPT_RIGHT_PADDING, 1);
table = create_test_int_table(0);
@ -411,7 +411,7 @@ void test_table_options(void **state)
table = create_test_int_table(1);
ft_add_separator(table);
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
assert_true( n == 4 );
@ -445,10 +445,10 @@ void test_table_options(void **state)
WHEN("Top and bottom padding = 0") {
ft_set_default_cell_option(FT_OPT_BOTTOM_PADDING, 0);
ft_set_default_cell_option(FT_OPT_TOP_PADDING, 0);
ft_set_default_cell_option(FT_OPT_LEFT_PADDING, 1);
ft_set_default_cell_option(FT_OPT_RIGHT_PADDING, 1);
ft_set_default_option(FT_OPT_BOTTOM_PADDING, 0);
ft_set_default_option(FT_OPT_TOP_PADDING, 0);
ft_set_default_option(FT_OPT_LEFT_PADDING, 1);
ft_set_default_option(FT_OPT_RIGHT_PADDING, 1);
table = create_test_int_table(0);
@ -471,10 +471,10 @@ void test_table_options(void **state)
WHEN("Left and right padding = 0") {
ft_set_default_cell_option(FT_OPT_BOTTOM_PADDING, 1);
ft_set_default_cell_option(FT_OPT_TOP_PADDING, 1);
ft_set_default_cell_option(FT_OPT_LEFT_PADDING, 0);
ft_set_default_cell_option(FT_OPT_RIGHT_PADDING, 0);
ft_set_default_option(FT_OPT_BOTTOM_PADDING, 1);
ft_set_default_option(FT_OPT_TOP_PADDING, 1);
ft_set_default_option(FT_OPT_LEFT_PADDING, 0);
ft_set_default_option(FT_OPT_RIGHT_PADDING, 0);
table = create_test_int_table(0);
@ -503,10 +503,10 @@ void test_table_options(void **state)
WHEN("All paddings = 0") {
ft_set_default_cell_option(FT_OPT_BOTTOM_PADDING, 0);
ft_set_default_cell_option(FT_OPT_TOP_PADDING, 0);
ft_set_default_cell_option(FT_OPT_LEFT_PADDING, 0);
ft_set_default_cell_option(FT_OPT_RIGHT_PADDING, 0);
ft_set_default_option(FT_OPT_BOTTOM_PADDING, 0);
ft_set_default_option(FT_OPT_TOP_PADDING, 0);
ft_set_default_option(FT_OPT_LEFT_PADDING, 0);
ft_set_default_option(FT_OPT_RIGHT_PADDING, 0);
table = create_test_int_table(0);
@ -529,11 +529,11 @@ void test_table_options(void **state)
WHEN("Empty string has 0 heigt") {
ft_set_default_cell_option(FT_OPT_BOTTOM_PADDING, 1);
ft_set_default_cell_option(FT_OPT_TOP_PADDING, 1);
ft_set_default_cell_option(FT_OPT_LEFT_PADDING, 1);
ft_set_default_cell_option(FT_OPT_RIGHT_PADDING, 1);
ft_set_default_cell_option(FT_OPT_EMPTY_STR_HEIGHT, 0);
ft_set_default_option(FT_OPT_BOTTOM_PADDING, 1);
ft_set_default_option(FT_OPT_TOP_PADDING, 1);
ft_set_default_option(FT_OPT_LEFT_PADDING, 1);
ft_set_default_option(FT_OPT_RIGHT_PADDING, 1);
ft_set_default_option(FT_OPT_EMPTY_STR_HEIGHT, 0);
table = create_test_int_table(0);
int n = ft_printf_ln(table, "|||");
@ -581,7 +581,7 @@ void test_table_options(void **state)
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 = '#';
ft_set_default_borders(&brdr_style);
ft_set_default_border_style(&brdr_style);
@ -624,13 +624,13 @@ void test_table_options(void **state)
brdr_style.header_border_chs.out_intersect_ch = '+';
brdr_style.header_border_chs.in_intersect_ch = '#';
ft_set_default_borders(&brdr_style);
ft_set_default_border_style(&brdr_style);
ft_set_default_cell_option(FT_OPT_BOTTOM_PADDING, 0);
ft_set_default_cell_option(FT_OPT_TOP_PADDING, 0);
ft_set_default_cell_option(FT_OPT_LEFT_PADDING, 1);
ft_set_default_cell_option(FT_OPT_RIGHT_PADDING, 1);
ft_set_default_cell_option(FT_OPT_EMPTY_STR_HEIGHT, 0);
ft_set_default_option(FT_OPT_BOTTOM_PADDING, 0);
ft_set_default_option(FT_OPT_TOP_PADDING, 0);
ft_set_default_option(FT_OPT_LEFT_PADDING, 1);
ft_set_default_option(FT_OPT_RIGHT_PADDING, 1);
ft_set_default_option(FT_OPT_EMPTY_STR_HEIGHT, 0);
table = create_test_int_table(0);
@ -655,10 +655,10 @@ void test_table_options(void **state)
table = create_test_int_table(0);
set_test_options_for_table(table);
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_BOTTOM_PADDING, 0);
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_TOP_PADDING, 0);
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_LEFT_PADDING, 0);
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_RIGHT_PADDING, 0);
ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_BOTTOM_PADDING, 0);
ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_TOP_PADDING, 0);
ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_LEFT_PADDING, 0);
ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_RIGHT_PADDING, 0);
const char *table_str = ft_to_string(table);
assert_true( table_str != NULL );
@ -675,11 +675,11 @@ void test_table_options(void **state)
assert_true( strcmp(table_str, table_str_etalon) == 0);
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_BOTTOM_PADDING, 1);
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_TOP_PADDING, 1);
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_LEFT_PADDING, 0);
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_RIGHT_PADDING, 0);
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_EMPTY_STR_HEIGHT, 0);
ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_BOTTOM_PADDING, 1);
ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_TOP_PADDING, 1);
ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_LEFT_PADDING, 0);
ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_RIGHT_PADDING, 0);
ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_EMPTY_STR_HEIGHT, 0);
table_str = ft_to_string(table);
assert_true( table_str != NULL );
@ -712,13 +712,13 @@ void test_table_options(void **state)
table = create_test_int_table(0);
int status = F_SUCCESS;
status |= ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_MIN_WIDTH, 7);
status |= ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
status |= ft_set_cell_option(table, FT_ANY_ROW, 2, FT_OPT_MIN_WIDTH, 8);
status |= ft_set_cell_option(table, FT_ANY_ROW, 2, FT_OPT_TEXT_ALIGN, CenterAligned);
status |= ft_set_option(table, FT_ANY_ROW, 1, FT_OPT_MIN_WIDTH, 7);
status |= ft_set_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
status |= ft_set_option(table, FT_ANY_ROW, 2, FT_OPT_MIN_WIDTH, 8);
status |= ft_set_option(table, FT_ANY_ROW, 2, FT_OPT_TEXT_ALIGN, CenterAligned);
status |= ft_set_cell_option(table, 2, 3, FT_OPT_MIN_WIDTH, 6);
status |= ft_set_cell_option(table, 2, 3, FT_OPT_TEXT_ALIGN, LeftAligned);
status |= ft_set_option(table, 2, 3, FT_OPT_MIN_WIDTH, 6);
status |= ft_set_option(table, 2, 3, FT_OPT_TEXT_ALIGN, LeftAligned);
assert_true( status == F_SUCCESS);
@ -750,8 +750,8 @@ void test_table_options(void **state)
set_test_options_as_default();
int status = F_SUCCESS;
status |= ft_set_default_cell_option(FT_OPT_MIN_WIDTH, 5);
status |= ft_set_default_cell_option(FT_OPT_TEXT_ALIGN, CenterAligned);
status |= ft_set_default_option(FT_OPT_MIN_WIDTH, 5);
status |= ft_set_default_option(FT_OPT_TEXT_ALIGN, CenterAligned);
assert_true( status == F_SUCCESS);
table = create_test_int_table(0);
@ -783,7 +783,7 @@ void test_table_options(void **state)
table = ft_create_table();
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
ft_set_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
int n = ft_printf_ln(table, "%d|%c|%s|%f", 4, 'c', "234", 3.14);
assert_true( n == 4 );