[A] Added border tests
This commit is contained in:
parent
a87ad88c29
commit
1c86313069
12
lib/fort.c
12
lib/fort.c
@ -2071,11 +2071,12 @@ int ft_table_wwrite_ln(ft_table_t *table, size_t rows, size_t cols, const wchar_
|
|||||||
const char *ft_to_string(const ft_table_t *table)
|
const char *ft_to_string(const ft_table_t *table)
|
||||||
{
|
{
|
||||||
typedef char char_type;
|
typedef char char_type;
|
||||||
const char_type *empty_string = "";
|
// const char_type *empty_string = "";
|
||||||
const enum str_buf_type buf_type = CharBuf;
|
const enum str_buf_type buf_type = CharBuf;
|
||||||
const char *space_char = " ";
|
const char *space_char = " ";
|
||||||
const char *new_line_char = "\n";
|
const char *new_line_char = "\n";
|
||||||
#define cur_F_STRDUP F_STRDUP
|
#define cur_F_STRDUP F_STRDUP
|
||||||
|
#define EMPTY_STRING ""
|
||||||
int (*snprintf_row_)(const fort_row_t *, char *, size_t, size_t *, size_t, size_t, const context_t *) = snprintf_row;
|
int (*snprintf_row_)(const fort_row_t *, char *, size_t, size_t *, size_t, size_t, const context_t *) = snprintf_row;
|
||||||
int (*print_row_separator_)(char *, size_t,
|
int (*print_row_separator_)(char *, size_t,
|
||||||
const size_t *, size_t,
|
const size_t *, size_t,
|
||||||
@ -2118,7 +2119,7 @@ const char *ft_to_string(const ft_table_t *table)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
return cur_F_STRDUP(empty_string);
|
return EMPTY_STRING;
|
||||||
|
|
||||||
int written = 0;
|
int written = 0;
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
@ -2166,6 +2167,7 @@ clear:
|
|||||||
// F_FREE(buffer);
|
// F_FREE(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
#undef cur_F_STRDUP
|
#undef cur_F_STRDUP
|
||||||
|
#undef EMPTY_STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2174,11 +2176,12 @@ clear:
|
|||||||
const wchar_t *ft_to_wstring(const ft_table_t *table)
|
const wchar_t *ft_to_wstring(const ft_table_t *table)
|
||||||
{
|
{
|
||||||
typedef wchar_t char_type;
|
typedef wchar_t char_type;
|
||||||
const char_type *empty_string = L"";
|
// const char_type *empty_string = L"";
|
||||||
const enum str_buf_type buf_type = WCharBuf;
|
const enum str_buf_type buf_type = WCharBuf;
|
||||||
const char *space_char = " ";
|
const char *space_char = " ";
|
||||||
const char *new_line_char = "\n";
|
const char *new_line_char = "\n";
|
||||||
#define cur_F_STRDUP F_WCSDUP
|
#define cur_F_STRDUP F_WCSDUP
|
||||||
|
#define EMPTY_STRING L""
|
||||||
int (*snprintf_row_)(const fort_row_t *, wchar_t *, size_t, size_t *, size_t, size_t, const context_t *) = wsnprintf_row;
|
int (*snprintf_row_)(const fort_row_t *, wchar_t *, size_t, size_t *, size_t, size_t, const context_t *) = wsnprintf_row;
|
||||||
int (*print_row_separator_)(wchar_t *, size_t,
|
int (*print_row_separator_)(wchar_t *, size_t,
|
||||||
const size_t *, size_t,
|
const size_t *, size_t,
|
||||||
@ -2221,7 +2224,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table)
|
|||||||
status = table_rows_and_cols_geometry(table, &col_width_arr, &cols, &row_height_arr, &rows);
|
status = table_rows_and_cols_geometry(table, &col_width_arr, &cols, &row_height_arr, &rows);
|
||||||
|
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
return cur_F_STRDUP(empty_string);
|
return EMPTY_STRING;
|
||||||
|
|
||||||
if (FT_IS_ERROR(status))
|
if (FT_IS_ERROR(status))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2271,6 +2274,7 @@ clear:
|
|||||||
// F_FREE(buffer);
|
// F_FREE(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
#undef cur_F_STRDUP
|
#undef cur_F_STRDUP
|
||||||
|
#undef EMPTY_STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -535,11 +535,12 @@ int ft_table_wwrite_ln(ft_table_t *table, size_t rows, size_t cols, const wchar_
|
|||||||
const char *ft_to_string(const ft_table_t *table)
|
const char *ft_to_string(const ft_table_t *table)
|
||||||
{
|
{
|
||||||
typedef char char_type;
|
typedef char char_type;
|
||||||
const char_type *empty_string = "";
|
// const char_type *empty_string = "";
|
||||||
const enum str_buf_type buf_type = CharBuf;
|
const enum str_buf_type buf_type = CharBuf;
|
||||||
const char *space_char = " ";
|
const char *space_char = " ";
|
||||||
const char *new_line_char = "\n";
|
const char *new_line_char = "\n";
|
||||||
#define cur_F_STRDUP F_STRDUP
|
#define cur_F_STRDUP F_STRDUP
|
||||||
|
#define EMPTY_STRING ""
|
||||||
int (*snprintf_row_)(const fort_row_t *, char *, size_t, size_t *, size_t, size_t, const context_t *) = snprintf_row;
|
int (*snprintf_row_)(const fort_row_t *, char *, size_t, size_t *, size_t, size_t, const context_t *) = snprintf_row;
|
||||||
int (*print_row_separator_)(char *, size_t,
|
int (*print_row_separator_)(char *, size_t,
|
||||||
const size_t *, size_t,
|
const size_t *, size_t,
|
||||||
@ -582,7 +583,7 @@ const char *ft_to_string(const ft_table_t *table)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
return cur_F_STRDUP(empty_string);
|
return EMPTY_STRING;
|
||||||
|
|
||||||
int written = 0;
|
int written = 0;
|
||||||
int tmp = 0;
|
int tmp = 0;
|
||||||
@ -630,6 +631,7 @@ clear:
|
|||||||
// F_FREE(buffer);
|
// F_FREE(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
#undef cur_F_STRDUP
|
#undef cur_F_STRDUP
|
||||||
|
#undef EMPTY_STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -638,11 +640,12 @@ clear:
|
|||||||
const wchar_t *ft_to_wstring(const ft_table_t *table)
|
const wchar_t *ft_to_wstring(const ft_table_t *table)
|
||||||
{
|
{
|
||||||
typedef wchar_t char_type;
|
typedef wchar_t char_type;
|
||||||
const char_type *empty_string = L"";
|
// const char_type *empty_string = L"";
|
||||||
const enum str_buf_type buf_type = WCharBuf;
|
const enum str_buf_type buf_type = WCharBuf;
|
||||||
const char *space_char = " ";
|
const char *space_char = " ";
|
||||||
const char *new_line_char = "\n";
|
const char *new_line_char = "\n";
|
||||||
#define cur_F_STRDUP F_WCSDUP
|
#define cur_F_STRDUP F_WCSDUP
|
||||||
|
#define EMPTY_STRING L""
|
||||||
int (*snprintf_row_)(const fort_row_t *, wchar_t *, size_t, size_t *, size_t, size_t, const context_t *) = wsnprintf_row;
|
int (*snprintf_row_)(const fort_row_t *, wchar_t *, size_t, size_t *, size_t, size_t, const context_t *) = wsnprintf_row;
|
||||||
int (*print_row_separator_)(wchar_t *, size_t,
|
int (*print_row_separator_)(wchar_t *, size_t,
|
||||||
const size_t *, size_t,
|
const size_t *, size_t,
|
||||||
@ -685,7 +688,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table)
|
|||||||
status = table_rows_and_cols_geometry(table, &col_width_arr, &cols, &row_height_arr, &rows);
|
status = table_rows_and_cols_geometry(table, &col_width_arr, &cols, &row_height_arr, &rows);
|
||||||
|
|
||||||
if (rows == 0)
|
if (rows == 0)
|
||||||
return cur_F_STRDUP(empty_string);
|
return EMPTY_STRING;
|
||||||
|
|
||||||
if (FT_IS_ERROR(status))
|
if (FT_IS_ERROR(status))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -735,6 +738,7 @@ clear:
|
|||||||
// F_FREE(buffer);
|
// F_FREE(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
#undef cur_F_STRDUP
|
#undef cur_F_STRDUP
|
||||||
|
#undef EMPTY_STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -129,3 +129,285 @@ void test_table_border_style(void)
|
|||||||
ft_destroy_table(table);
|
ft_destroy_table(table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ft_table_t *create_basic_table(void)
|
||||||
|
{
|
||||||
|
ft_table_t *table = ft_create_table();
|
||||||
|
ft_set_cell_option(table, FT_ANY_ROW, 0, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER);
|
||||||
|
ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT);
|
||||||
|
|
||||||
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||||
|
ft_write_ln(table, "Rank", "Title", "Year", "Rating");
|
||||||
|
|
||||||
|
ft_write_ln(table, "1", "The Shawshank Redemption", "1994", "9.5");
|
||||||
|
ft_write_ln(table, "2", "12 Angry Men", "1957", "8.8");
|
||||||
|
ft_write_ln(table, "3", "It's a Wonderful Life", "1946", "8.6");
|
||||||
|
ft_add_separator(table);
|
||||||
|
ft_write_ln(table, "4", "2001: A Space Odyssey", "1968", "8.5");
|
||||||
|
ft_write_ln(table, "5", "Blade Runner", "1982", "8.1");
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_table_builtin_border_styles(void)
|
||||||
|
{
|
||||||
|
ft_table_t *table = NULL;
|
||||||
|
const char *table_str = NULL;
|
||||||
|
const char *table_str_etalon = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_BASIC_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
"+------+--------------------------+------+--------+\n"
|
||||||
|
"| Rank | Title | Year | Rating |\n"
|
||||||
|
"+------+--------------------------+------+--------+\n"
|
||||||
|
"| 1 | The Shawshank Redemption | 1994 | 9.5 |\n"
|
||||||
|
"| 2 | 12 Angry Men | 1957 | 8.8 |\n"
|
||||||
|
"| 3 | It's a Wonderful Life | 1946 | 8.6 |\n"
|
||||||
|
"+------+--------------------------+------+--------+\n"
|
||||||
|
"| 4 | 2001: A Space Odyssey | 1968 | 8.5 |\n"
|
||||||
|
"| 5 | Blade Runner | 1982 | 8.1 |\n"
|
||||||
|
"+------+--------------------------+------+--------+\n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_SIMPLE_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
" \n"
|
||||||
|
" Rank Title Year Rating \n"
|
||||||
|
" ------ -------------------------- ------ -------- \n"
|
||||||
|
" 1 The Shawshank Redemption 1994 9.5 \n"
|
||||||
|
" 2 12 Angry Men 1957 8.8 \n"
|
||||||
|
" 3 It's a Wonderful Life 1946 8.6 \n"
|
||||||
|
" ------ -------------------------- ------ -------- \n"
|
||||||
|
" 4 2001: A Space Odyssey 1968 8.5 \n"
|
||||||
|
" 5 Blade Runner 1982 8.1 \n"
|
||||||
|
" \n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_PLAIN_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
" ------------------------------------------------- \n"
|
||||||
|
" Rank Title Year Rating \n"
|
||||||
|
" ------------------------------------------------- \n"
|
||||||
|
" 1 The Shawshank Redemption 1994 9.5 \n"
|
||||||
|
" 2 12 Angry Men 1957 8.8 \n"
|
||||||
|
" 3 It's a Wonderful Life 1946 8.6 \n"
|
||||||
|
" ------------------------------------------------- \n"
|
||||||
|
" 4 2001: A Space Odyssey 1968 8.5 \n"
|
||||||
|
" 5 Blade Runner 1982 8.1 \n"
|
||||||
|
" \n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_DOT_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
"...................................................\n"
|
||||||
|
": Rank : Title : Year : Rating :\n"
|
||||||
|
":......:..........................:......:........:\n"
|
||||||
|
": 1 : The Shawshank Redemption : 1994 : 9.5 :\n"
|
||||||
|
": 2 : 12 Angry Men : 1957 : 8.8 :\n"
|
||||||
|
": 3 : It's a Wonderful Life : 1946 : 8.6 :\n"
|
||||||
|
":......:..........................:......:........:\n"
|
||||||
|
": 4 : 2001: A Space Odyssey : 1968 : 8.5 :\n"
|
||||||
|
": 5 : Blade Runner : 1982 : 8.1 :\n"
|
||||||
|
":......:..........................:......:........:\n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_EMPTY_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
" \n"
|
||||||
|
" Rank Title Year Rating \n"
|
||||||
|
" 1 The Shawshank Redemption 1994 9.5 \n"
|
||||||
|
" 2 12 Angry Men 1957 8.8 \n"
|
||||||
|
" 3 It's a Wonderful Life 1946 8.6 \n"
|
||||||
|
" \n"
|
||||||
|
" 4 2001: A Space Odyssey 1968 8.5 \n"
|
||||||
|
" 5 Blade Runner 1982 8.1 \n"
|
||||||
|
" \n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_SOLID_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
"┌──────┬──────────────────────────┬──────┬────────┐\n"
|
||||||
|
"│ Rank │ Title │ Year │ Rating │\n"
|
||||||
|
"├──────┼──────────────────────────┼──────┼────────┤\n"
|
||||||
|
"│ 1 │ The Shawshank Redemption │ 1994 │ 9.5 │\n"
|
||||||
|
"│ 2 │ 12 Angry Men │ 1957 │ 8.8 │\n"
|
||||||
|
"│ 3 │ It's a Wonderful Life │ 1946 │ 8.6 │\n"
|
||||||
|
"├──────┼──────────────────────────┼──────┼────────┤\n"
|
||||||
|
"│ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 │\n"
|
||||||
|
"│ 5 │ Blade Runner │ 1982 │ 8.1 │\n"
|
||||||
|
"└──────┴──────────────────────────┴──────┴────────╯\n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_SOLID_ROUND_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
"╭──────┬──────────────────────────┬──────┬────────╮\n"
|
||||||
|
"│ Rank │ Title │ Year │ Rating │\n"
|
||||||
|
"├──────┼──────────────────────────┼──────┼────────┤\n"
|
||||||
|
"│ 1 │ The Shawshank Redemption │ 1994 │ 9.5 │\n"
|
||||||
|
"│ 2 │ 12 Angry Men │ 1957 │ 8.8 │\n"
|
||||||
|
"│ 3 │ It's a Wonderful Life │ 1946 │ 8.6 │\n"
|
||||||
|
"├──────┼──────────────────────────┼──────┼────────┤\n"
|
||||||
|
"│ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 │\n"
|
||||||
|
"│ 5 │ Blade Runner │ 1982 │ 8.1 │\n"
|
||||||
|
"╰──────┴──────────────────────────┴──────┴────────╯\n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_DOUBLE_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
"╔══════╦══════════════════════════╦══════╦════════╗\n"
|
||||||
|
"║ Rank ║ Title ║ Year ║ Rating ║\n"
|
||||||
|
"╠══════╬══════════════════════════╬══════╬════════╣\n"
|
||||||
|
"║ 1 ║ The Shawshank Redemption ║ 1994 ║ 9.5 ║\n"
|
||||||
|
"║ 2 ║ 12 Angry Men ║ 1957 ║ 8.8 ║\n"
|
||||||
|
"║ 3 ║ It's a Wonderful Life ║ 1946 ║ 8.6 ║\n"
|
||||||
|
"╠══════╬══════════════════════════╬══════╬════════╣\n"
|
||||||
|
"║ 4 ║ 2001: A Space Odyssey ║ 1968 ║ 8.5 ║\n"
|
||||||
|
"║ 5 ║ Blade Runner ║ 1982 ║ 8.1 ║\n"
|
||||||
|
"╚══════╩══════════════════════════╩══════╩════════╝\n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_DOUBLE2_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
"╔══════╤══════════════════════════╤══════╤════════╗\n"
|
||||||
|
"║ Rank │ Title │ Year │ Rating ║\n"
|
||||||
|
"╠══════╪══════════════════════════╪══════╪════════╣\n"
|
||||||
|
"║ 1 │ The Shawshank Redemption │ 1994 │ 9.5 ║\n"
|
||||||
|
"╟──────┼──────────────────────────┼──────┼────────╢\n"
|
||||||
|
"║ 2 │ 12 Angry Men │ 1957 │ 8.8 ║\n"
|
||||||
|
"╟──────┼──────────────────────────┼──────┼────────╢\n"
|
||||||
|
"║ 3 │ It's a Wonderful Life │ 1946 │ 8.6 ║\n"
|
||||||
|
"╠══════╪══════════════════════════╪══════╪════════╣\n"
|
||||||
|
"║ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 ║\n"
|
||||||
|
"╟──────┼──────────────────────────┼──────┼────────╢\n"
|
||||||
|
"║ 5 │ Blade Runner │ 1982 │ 8.1 ║\n"
|
||||||
|
"╚══════╧══════════════════════════╧══════╧════════╝\n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_BOLD_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
"┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━┓\n"
|
||||||
|
"┃ Rank ┃ Title ┃ Year ┃ Rating ┃\n"
|
||||||
|
"┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━┫\n"
|
||||||
|
"┃ 1 ┃ The Shawshank Redemption ┃ 1994 ┃ 9.5 ┃\n"
|
||||||
|
"┃ 2 ┃ 12 Angry Men ┃ 1957 ┃ 8.8 ┃\n"
|
||||||
|
"┃ 3 ┃ It's a Wonderful Life ┃ 1946 ┃ 8.6 ┃\n"
|
||||||
|
"┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━┫\n"
|
||||||
|
"┃ 4 ┃ 2001: A Space Odyssey ┃ 1968 ┃ 8.5 ┃\n"
|
||||||
|
"┃ 5 ┃ Blade Runner ┃ 1982 ┃ 8.1 ┃\n"
|
||||||
|
"┗━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━┻━━━━━━━━┛\n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_BOLD2_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
"┏━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━┓\n"
|
||||||
|
"┃ Rank │ Title │ Year │ Rating ┃\n"
|
||||||
|
"┣━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━┿━━━━━━━━┫\n"
|
||||||
|
"┃ 1 │ The Shawshank Redemption │ 1994 │ 9.5 ┃\n"
|
||||||
|
"┠──────┼──────────────────────────┼──────┼────────┨\n"
|
||||||
|
"┃ 2 │ 12 Angry Men │ 1957 │ 8.8 ┃\n"
|
||||||
|
"┠──────┼──────────────────────────┼──────┼────────┨\n"
|
||||||
|
"┃ 3 │ It's a Wonderful Life │ 1946 │ 8.6 ┃\n"
|
||||||
|
"┣━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━┿━━━━━━━━┫\n"
|
||||||
|
"┃ 4 │ 2001: A Space Odyssey │ 1968 │ 8.5 ┃\n"
|
||||||
|
"┠──────┼──────────────────────────┼──────┼────────┨\n"
|
||||||
|
"┃ 5 │ Blade Runner │ 1982 │ 8.1 ┃\n"
|
||||||
|
"┗━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━┛\n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
|
||||||
|
/* *************************************************************** */
|
||||||
|
|
||||||
|
ft_set_default_border_style(FT_FRAME_STYLE);
|
||||||
|
table = create_basic_table();
|
||||||
|
table_str = ft_to_string(table);
|
||||||
|
assert_true(table_str != NULL);
|
||||||
|
|
||||||
|
table_str_etalon =
|
||||||
|
"▛▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▜\n"
|
||||||
|
"▌ Rank ┃ Title ┃ Year ┃ Rating ▐\n"
|
||||||
|
"▌━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━▐\n"
|
||||||
|
"▌ 1 ┃ The Shawshank Redemption ┃ 1994 ┃ 9.5 ▐\n"
|
||||||
|
"▌ 2 ┃ 12 Angry Men ┃ 1957 ┃ 8.8 ▐\n"
|
||||||
|
"▌ 3 ┃ It's a Wonderful Life ┃ 1946 ┃ 8.6 ▐\n"
|
||||||
|
"▌━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━━━━▐\n"
|
||||||
|
"▌ 4 ┃ 2001: A Space Odyssey ┃ 1968 ┃ 8.5 ▐\n"
|
||||||
|
"▌ 5 ┃ Blade Runner ┃ 1982 ┃ 8.1 ▐\n"
|
||||||
|
"▙▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▟\n";
|
||||||
|
assert_str_equal(table_str, table_str_etalon);
|
||||||
|
ft_destroy_table(table);
|
||||||
|
}
|
||||||
|
@ -34,6 +34,7 @@ struct test_case bb_test_suit [] = {
|
|||||||
#endif
|
#endif
|
||||||
{"test_table_write", test_table_write},
|
{"test_table_write", test_table_write},
|
||||||
{"test_table_border_style", test_table_border_style},
|
{"test_table_border_style", test_table_border_style},
|
||||||
|
{"test_table_builtin_border_styles", test_table_builtin_border_styles},
|
||||||
{"test_table_cell_options", test_table_cell_options},
|
{"test_table_cell_options", test_table_cell_options},
|
||||||
{"test_table_tbl_options", test_table_tbl_options},
|
{"test_table_tbl_options", test_table_tbl_options},
|
||||||
{"test_memory_errors", test_memory_errors},
|
{"test_memory_errors", test_memory_errors},
|
||||||
|
@ -30,6 +30,7 @@ void test_wcs_table_boundaries(void);
|
|||||||
#endif
|
#endif
|
||||||
void test_table_write(void);
|
void test_table_write(void);
|
||||||
void test_table_border_style(void);
|
void test_table_border_style(void);
|
||||||
|
void test_table_builtin_border_styles(void);
|
||||||
void test_table_cell_options(void);
|
void test_table_cell_options(void);
|
||||||
void test_table_tbl_options(void);
|
void test_table_tbl_options(void);
|
||||||
void test_memory_errors(void);
|
void test_memory_errors(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user