[A] Added wprintf

This commit is contained in:
seleznevae
2018-04-24 21:36:07 +03:00
parent f8e8793565
commit efa4921b3e
9 changed files with 341 additions and 31 deletions

View File

@@ -658,8 +658,45 @@ void test_table_write(void)
ft_destroy_table(table);
}
#ifdef FT_HAVE_WCHAR
SCENARIO("Test printf functions(wide strings)") {
/* todo: need to implement */
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|%s|%f", 3, 'c', "234", 3.14);
assert_true(n == 4);
n = ft_wprintf(table, L"%c|%s|%f|%d", 'c', "235", 3.15, 5);
assert_true(n == 4);
ft_ln(table);
n = ft_wprintf_ln(table, L"%s|%f|%d|%c", "234", 3.14, 3, 'c');
assert_true(n == 4);
/* Replace old values */
ft_set_cur_cell(table, 1, 1);
n = ft_wprintf_ln(table, L"%s|%f|%d", "234", 3.14, 3);
assert_true(n == 3);
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);
}
#endif
}