[F] Fix compilation error

This commit is contained in:
seleznevae
2020-01-19 22:24:17 +03:00
parent 1ed13718d5
commit 4871105b0f
4 changed files with 131 additions and 53 deletions

View File

@@ -1825,7 +1825,7 @@ static struct ft_table *create_test_table()
void test_table_erase(void)
{
WHEN("Test invalid arguments") {
WHEN("Invalid arguments") {
ft_table_t *table = create_test_table();
// invalid rows

View File

@@ -401,6 +401,31 @@ static fort::char_table create_test_table()
void test_cpp_table_erase(void)
{
WHEN("Invalid arguments") {
std::string err_msg;
try {
fort::char_table table = create_test_table();
table.range(1, 1, 0, 0).erase();
} catch (std::exception &e) {
err_msg = e.what();
}
assert_string_equal(err_msg, std::string("Failed to erase column"));
}
WHEN("Erase one cell") {
fort::char_table table = create_test_table();
table.range(1, 1, 1, 1).erase();
std::string table_str = table.to_string();
std::string table_str_etalon =
"+----+----+----+\n"
"| 00 | 01 | 02 |\n"
"| 10 | 12 | |\n"
"| 20 | 21 | 22 |\n"
"+----+----+----+\n";
assert_string_equal(table_str, table_str_etalon);
}
WHEN("Erase row") {
fort::char_table table = create_test_table();
table[1].erase();
@@ -414,51 +439,44 @@ void test_cpp_table_erase(void)
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)));
WHEN("Erase last row") {
fort::char_table table = create_test_table();
table[2].erase();
// 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);
// }
std::string table_str = table.to_string();
std::string table_str_etalon =
"+----+----+----+\n"
"| 00 | 01 | 02 |\n"
"| 10 | 11 | 12 |\n"
"+----+----+----+\n";
assert_string_equal(table_str, table_str_etalon);
}
// WHEN("Erase column") {
// ft_table_t *table = create_test_table();
// assert_true(FT_IS_SUCCESS(ft_erase_range(table, 0, 1, 999, 1)));
WHEN("Erase column") {
fort::char_table table = create_test_table();
table.column(1).erase();
// 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);
// }
std::string table_str = table.to_string();
std::string table_str_etalon =
"+----+----+\n"
"| 00 | 02 |\n"
"| 10 | 12 |\n"
"| 20 | 22 |\n"
"+----+----+\n";
assert_string_equal(table_str, table_str_etalon);
}
// 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);
// }
WHEN("Erase last column") {
fort::char_table table = create_test_table();
table.column(2).erase();
std::string table_str = table.to_string();
std::string table_str_etalon =
"+----+----+\n"
"| 00 | 01 |\n"
"| 10 | 11 |\n"
"| 20 | 21 |\n"
"+----+----+\n";
assert_string_equal(table_str, table_str_etalon);
}
}