[A] Added more tests for write functions
This commit is contained in:
parent
71c2a4d081
commit
8bb0eaec66
@ -291,6 +291,151 @@ void test_table_write(void)
|
||||
{
|
||||
FTABLE *table = NULL;
|
||||
|
||||
SCENARIO("Test write functions") {
|
||||
table = ft_create_table();
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||
assert_true(ft_write(table, "3") == FT_SUCCESS);
|
||||
assert_true(ft_write(table, "c") == FT_SUCCESS);
|
||||
assert_true(ft_write(table, "234") == FT_SUCCESS);
|
||||
assert_true(ft_write(table, "3.140000") == FT_SUCCESS);
|
||||
ft_ln(table);
|
||||
assert_true(ft_write(table, "c") == FT_SUCCESS);
|
||||
assert_true(ft_write(table, "234") == FT_SUCCESS);
|
||||
assert_true(ft_write(table, "3.140000") == FT_SUCCESS);
|
||||
assert_true(ft_write_ln(table, "3") == FT_SUCCESS);
|
||||
|
||||
assert_true(ft_write(table, "234") == FT_SUCCESS);
|
||||
assert_true(ft_write(table, "3.140000") == FT_SUCCESS);
|
||||
assert_true(ft_write(table, "3") == FT_SUCCESS);
|
||||
assert_true(ft_write_ln(table, "c") == FT_SUCCESS);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | 3 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | 3 | c |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
SCENARIO("Test wwrite functions(wide strings)") {
|
||||
table = ft_create_table();
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||
assert_true(ft_wwrite(table, L"3") == FT_SUCCESS);
|
||||
assert_true(ft_wwrite(table, L"c") == FT_SUCCESS);
|
||||
assert_true(ft_wwrite(table, L"234") == FT_SUCCESS);
|
||||
assert_true(ft_wwrite(table, L"3.140000") == FT_SUCCESS);
|
||||
ft_ln(table);
|
||||
assert_true(ft_wwrite(table, L"c") == FT_SUCCESS);
|
||||
assert_true(ft_wwrite(table, L"234") == FT_SUCCESS);
|
||||
assert_true(ft_wwrite(table, L"3.140000") == FT_SUCCESS);
|
||||
assert_true(ft_wwrite_ln(table, L"3") == FT_SUCCESS);
|
||||
|
||||
assert_true(ft_wwrite(table, L"234") == FT_SUCCESS);
|
||||
assert_true(ft_wwrite(table, L"3.140000") == FT_SUCCESS);
|
||||
assert_true(ft_wwrite(table, L"3") == FT_SUCCESS);
|
||||
assert_true(ft_wwrite_ln(table, L"c") == FT_SUCCESS);
|
||||
|
||||
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 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| c | 234 | 3.140000 | 3 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 234 | 3.140000 | 3 | c |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
SCENARIO("Test nwrite functions") {
|
||||
table = ft_create_table();
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||
assert_true(ft_nwrite(table, 4, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||
ft_ln(table);
|
||||
assert_true(ft_nwrite_ln(table, 4, "c", "234", "3.140000", "3") == FT_SUCCESS);
|
||||
assert_true(ft_nwrite_ln(table, 4, "234", "3.140000", "3", "c") == FT_SUCCESS);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | 3 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | 3 | c |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
SCENARIO("Test nwwrite functions(wide strings)") {
|
||||
table = ft_create_table();
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||
assert_true(ft_nwwrite(table, 4, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||
ft_ln(table);
|
||||
assert_true(ft_nwwrite_ln(table, 4, L"c", L"234", L"3.140000", L"3") == FT_SUCCESS);
|
||||
assert_true(ft_nwwrite_ln(table, 4, L"234", L"3.140000", L"3", L"c") == FT_SUCCESS);
|
||||
|
||||
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 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| c | 234 | 3.140000 | 3 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 234 | 3.140000 | 3 | c |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
|
||||
SCENARIO("Test row_write functions") {
|
||||
table = ft_create_table();
|
||||
assert_true(table != NULL);
|
||||
@ -301,7 +446,8 @@ void test_table_write(void)
|
||||
const char *row_1[4] = {"c", "234", "3.140000", "3"};
|
||||
const char *row_2[4] = {"234", "3.140000", "3", "c"};
|
||||
assert_true(ft_row_write_ln(table, 4, row_0) == FT_SUCCESS);
|
||||
assert_true(ft_row_write_ln(table, 4, row_1) == FT_SUCCESS);
|
||||
assert_true(ft_row_write(table, 4, row_1) == FT_SUCCESS);
|
||||
ft_ln(table);
|
||||
assert_true(ft_row_write_ln(table, 4, row_2) == FT_SUCCESS);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
@ -334,7 +480,8 @@ void test_table_write(void)
|
||||
const wchar_t *row_1[4] = {L"c", L"234", L"3.140000", L"3"};
|
||||
const wchar_t *row_2[4] = {L"234", L"3.140000", L"3", L"c"};
|
||||
assert_true(ft_row_wwrite_ln(table, 4, row_0) == FT_SUCCESS);
|
||||
assert_true(ft_row_wwrite_ln(table, 4, row_1) == FT_SUCCESS);
|
||||
assert_true(ft_row_wwrite(table, 4, row_1) == FT_SUCCESS);
|
||||
ft_ln(table);
|
||||
assert_true(ft_row_wwrite_ln(table, 4, row_2) == FT_SUCCESS);
|
||||
|
||||
const wchar_t *table_str = ft_to_wstring(table);
|
||||
@ -366,8 +513,9 @@ void test_table_write(void)
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
||||
int n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14);
|
||||
assert_true(n == 4);
|
||||
n = ft_printf_ln(table, "%c|%s|%f|%d", 'c', "234", 3.14, 3);
|
||||
n = ft_printf(table, "%c|%s|%f|%d", 'c', "234", 3.14, 3);
|
||||
assert_true(n == 4);
|
||||
ft_ln(table);
|
||||
n = ft_printf_ln(table, "%s|%f|%d|%c", "234", 3.14, 3, 'c');
|
||||
assert_true(n == 4);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user