[C] Rename ft_delete_range
to ft_erase_range
This commit is contained in:
@@ -1823,23 +1823,23 @@ static struct ft_table *create_test_table()
|
||||
return table;
|
||||
}
|
||||
|
||||
void test_table_cell_deletion(void)
|
||||
void test_table_erase(void)
|
||||
{
|
||||
WHEN("Test invalid arguments") {
|
||||
ft_table_t *table = create_test_table();
|
||||
|
||||
// invalid rows
|
||||
assert_true(ft_delete_range(table, 1, 1, 0, 2) == FT_EINVAL);
|
||||
assert_true(ft_erase_range(table, 1, 1, 0, 2) == FT_EINVAL);
|
||||
|
||||
// invalid colums
|
||||
assert_true(ft_delete_range(table, 1, 1, 2, 0) == FT_EINVAL);
|
||||
assert_true(ft_erase_range(table, 1, 1, 2, 0) == FT_EINVAL);
|
||||
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("Delete one cell") {
|
||||
WHEN("Erase one cell") {
|
||||
ft_table_t *table = create_test_table();
|
||||
assert_true(FT_IS_SUCCESS(ft_delete_range(table, 1, 1, 1, 1)));
|
||||
assert_true(FT_IS_SUCCESS(ft_erase_range(table, 1, 1, 1, 1)));
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true(table_str != NULL);
|
||||
@@ -1853,10 +1853,10 @@ void test_table_cell_deletion(void)
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("Delete one last cell") {
|
||||
WHEN("Erase one last cell") {
|
||||
ft_table_t *table = create_test_table();
|
||||
ft_write_ln(table, "30");
|
||||
assert_true(FT_IS_SUCCESS(ft_delete_range(table, 3, 0, 3, 0)));
|
||||
assert_true(FT_IS_SUCCESS(ft_erase_range(table, 3, 0, 3, 0)));
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true(table_str != NULL);
|
||||
@@ -1870,9 +1870,9 @@ void test_table_cell_deletion(void)
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("Delete row") {
|
||||
WHEN("Erase row") {
|
||||
ft_table_t *table = create_test_table();
|
||||
assert_true(FT_IS_SUCCESS(ft_delete_range(table, 1, 0, 1, 999)));
|
||||
assert_true(FT_IS_SUCCESS(ft_erase_range(table, 1, 0, 1, 999)));
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true(table_str != NULL);
|
||||
@@ -1885,9 +1885,9 @@ void test_table_cell_deletion(void)
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("Delete last row") {
|
||||
WHEN("Erase last row") {
|
||||
ft_table_t *table = create_test_table();
|
||||
assert_true(FT_IS_SUCCESS(ft_delete_range(table, 2, 0, 2, 999)));
|
||||
assert_true(FT_IS_SUCCESS(ft_erase_range(table, 2, 0, 2, 999)));
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true(table_str != NULL);
|
||||
@@ -1900,9 +1900,9 @@ void test_table_cell_deletion(void)
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("Delete column") {
|
||||
WHEN("Erase column") {
|
||||
ft_table_t *table = create_test_table();
|
||||
assert_true(FT_IS_SUCCESS(ft_delete_range(table, 0, 1, 999, 1)));
|
||||
assert_true(FT_IS_SUCCESS(ft_erase_range(table, 0, 1, 999, 1)));
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true(table_str != NULL);
|
||||
@@ -1916,9 +1916,9 @@ void test_table_cell_deletion(void)
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("Delete last column") {
|
||||
WHEN("Erase last column") {
|
||||
ft_table_t *table = create_test_table();
|
||||
assert_true(FT_IS_SUCCESS(ft_delete_range(table, 0, 2, 999, 2)));
|
||||
assert_true(FT_IS_SUCCESS(ft_erase_range(table, 0, 2, 999, 2)));
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true(table_str != NULL);
|
||||
|
@@ -388,3 +388,77 @@ void test_cpp_table_changing_cell(void)
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
}
|
||||
|
||||
static fort::char_table create_test_table()
|
||||
{
|
||||
fort::char_table table;
|
||||
table.write_ln("00", "01", "02");
|
||||
table.write_ln("10", "11", "12");
|
||||
table.write_ln("20", "21", "22");
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
void test_cpp_table_erase(void)
|
||||
{
|
||||
WHEN("Erase row") {
|
||||
fort::char_table table = create_test_table();
|
||||
table[1].erase();
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
"+----+----+----+\n"
|
||||
"| 00 | 01 | 02 |\n"
|
||||
"| 20 | 21 | 22 |\n"
|
||||
"+----+----+----+\n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
|
||||
// WHEN("Erase last row") {
|
||||
// ft_table_t *table = create_test_table();
|
||||
// assert_true(FT_IS_SUCCESS(ft_erase_range(table, 2, 0, 2, 999)));
|
||||
|
||||
// const char *table_str = ft_to_string(table);
|
||||
// assert_true(table_str != NULL);
|
||||
// const char *table_str_etalon =
|
||||
// "+----+----+----+\n"
|
||||
// "| 00 | 01 | 02 |\n"
|
||||
// "| 10 | 11 | 12 |\n"
|
||||
// "+----+----+----+\n";
|
||||
// assert_str_equal(table_str, table_str_etalon);
|
||||
// ft_destroy_table(table);
|
||||
// }
|
||||
|
||||
// WHEN("Erase column") {
|
||||
// ft_table_t *table = create_test_table();
|
||||
// assert_true(FT_IS_SUCCESS(ft_erase_range(table, 0, 1, 999, 1)));
|
||||
|
||||
// const char *table_str = ft_to_string(table);
|
||||
// assert_true(table_str != NULL);
|
||||
// const char *table_str_etalon =
|
||||
// "+----+----+\n"
|
||||
// "| 00 | 02 |\n"
|
||||
// "| 10 | 12 |\n"
|
||||
// "| 20 | 22 |\n"
|
||||
// "+----+----+\n";
|
||||
// assert_str_equal(table_str, table_str_etalon);
|
||||
// ft_destroy_table(table);
|
||||
// }
|
||||
|
||||
// WHEN("Erase last column") {
|
||||
// ft_table_t *table = create_test_table();
|
||||
// assert_true(FT_IS_SUCCESS(ft_erase_range(table, 0, 2, 999, 2)));
|
||||
|
||||
// const char *table_str = ft_to_string(table);
|
||||
// assert_true(table_str != NULL);
|
||||
// const char *table_str_etalon =
|
||||
// "+----+----+\n"
|
||||
// "| 00 | 01 |\n"
|
||||
// "| 10 | 11 |\n"
|
||||
// "| 20 | 21 |\n"
|
||||
// "+----+----+\n";
|
||||
// assert_str_equal(table_str, table_str_etalon);
|
||||
// ft_destroy_table(table);
|
||||
// }
|
||||
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ void test_table_geometry(void);
|
||||
void test_table_basic(void);
|
||||
void test_table_copy(void);
|
||||
void test_table_changing_cell(void);
|
||||
void test_table_cell_deletion(void);
|
||||
void test_table_erase(void);
|
||||
#ifdef FT_HAVE_WCHAR
|
||||
void test_wcs_table_boundaries(void);
|
||||
#endif
|
||||
@@ -53,7 +53,7 @@ struct test_case bb_test_suite [] = {
|
||||
{"test_table_write", test_table_write},
|
||||
{"test_table_insert_strategy", test_table_insert_strategy},
|
||||
{"test_table_changing_cell", test_table_changing_cell},
|
||||
{"test_table_cell_deletion", test_table_cell_deletion},
|
||||
{"test_table_erase", test_table_erase},
|
||||
{"test_table_border_style", test_table_border_style},
|
||||
{"test_table_builtin_border_styles", test_table_builtin_border_styles},
|
||||
{"test_table_cell_properties", test_table_cell_properties},
|
||||
|
@@ -6,6 +6,7 @@
|
||||
void test_cpp_table_basic(void);
|
||||
void test_cpp_table_write(void);
|
||||
void test_cpp_table_insert(void);
|
||||
void test_cpp_table_erase(void);
|
||||
void test_cpp_table_changing_cell(void);
|
||||
void test_cpp_table_tbl_properties(void);
|
||||
void test_cpp_table_cell_properties(void);
|
||||
@@ -17,6 +18,7 @@ struct test_case bb_test_suite [] = {
|
||||
{"test_cpp_table_basic", test_cpp_table_basic},
|
||||
{"test_cpp_table_write", test_cpp_table_write},
|
||||
{"test_cpp_table_insert", test_cpp_table_insert},
|
||||
{"test_cpp_table_erase", test_cpp_table_erase},
|
||||
{"test_cpp_table_changing_cell", test_cpp_table_changing_cell},
|
||||
{"test_cpp_table_tbl_properties", test_cpp_table_tbl_properties},
|
||||
{"test_cpp_table_cell_properties", test_cpp_table_cell_properties},
|
||||
|
Reference in New Issue
Block a user