[F] Fixed printf errors

This commit is contained in:
seleznevae
2018-05-12 12:45:42 +03:00
parent fa09fb16c8
commit 0440ebb931
6 changed files with 192 additions and 11 deletions

View File

@@ -700,4 +700,44 @@ void test_table_write(void)
}
#endif
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_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14);
assert_true(n == 4);
n = ft_printf(table, "%c", 'c');
assert_true(n == 1);
n = ft_printf(table, "%s", "234");
assert_true(n == 1);
n = ft_printf(table, "%s", "string|with separator");
assert_true(n == 1);
n = ft_printf(table, "3");
assert_true(n == 1);
ft_ln(table);
n = ft_printf_ln(table, "%s|%f|%d|%c", "234", 3.14, 3, 'c');
assert_true(n == 4);
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 | string|with separator | 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);
}
}