[F] Fixed printf errors
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user