[A] Added more tests

This commit is contained in:
seleznevae 2018-05-12 13:00:38 +03:00
parent 0440ebb931
commit bc567c0014

View File

@ -740,4 +740,46 @@ void test_table_write(void)
ft_destroy_table(table); ft_destroy_table(table);
} }
#ifdef FT_HAVE_WCHAR
SCENARIO("Test printf functions with strings with separators inside them") {
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);
int n = ft_wprintf_ln(table, L"%d|%c|%ls|%f", 3, 'c', L"234", 3.14);
assert_true(n == 4);
n = ft_wprintf(table, L"%c", 'c');
assert_true(n == 1);
n = ft_wprintf(table, L"%ls", L"234");
assert_true(n == 1);
n = ft_wprintf(table, L"%ls", L"string|with separator");
assert_true(n == 1);
n = ft_wprintf(table, L"3");
assert_true(n == 1);
ft_ln(table);
n = ft_wprintf_ln(table, L"%ls|%f|%d|%c", L"234", 3.14, 3, 'c');
assert_true(n == 4);
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 | string|with separator | 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);
}
#endif
} }