[A] Add functions to check if table is empty to the API

This commit is contained in:
seleznevae
2019-12-13 23:30:30 +03:00
parent f17f150e43
commit 71188fd0fb
9 changed files with 115 additions and 14 deletions

View File

@@ -197,6 +197,7 @@ void test_table_basic(void)
WHEN("Empty table") {
table = ft_create_table();
assert_true(table != NULL);
assert_true(ft_is_empty(table) == 1);
const char *table_str = ft_to_string(table);
assert_true(table_str != NULL);
@@ -213,6 +214,26 @@ void test_table_basic(void)
assert_true(table_str != NULL);
assert_str_equal(table_str, table_str_etalon);
#endif /* FT_HAVE_UTF8 */
ft_set_cur_cell(table, 5, 6);
assert_true(ft_is_empty(table) == 1);
ft_destroy_table(table);
}
WHEN("Empty string content") {
table = ft_create_table();
assert_true(table != NULL);
assert_true(ft_is_empty(table) == 1);
assert_true(ft_write_ln(table, "") == FT_SUCCESS);
assert_true(ft_is_empty(table) == 0);
const char *table_str = ft_to_string(table);
const char *table_str_etalon =
"+--+\n"
"| |\n"
"+--+\n";
assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table);
}
@@ -225,6 +246,7 @@ void test_table_basic(void)
assert_true(ft_write_ln(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
assert_true(ft_write_ln(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
assert_true(ft_write_ln(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
assert_true(ft_is_empty(table) == 0);
const char *table_str = ft_to_string(table);
assert_true(table_str != NULL);

View File

@@ -30,6 +30,16 @@ void test_cpp_bug_fixes(void)
void test_cpp_table_basic(void)
{
WHEN("Empty table.") {
fort::char_table table;
assert_true(set_cpp_test_props_for_table(&table));
std::string table_str = table.to_string();
std::string table_str_etalon = "";
assert_string_equal(table_str, table_str_etalon);
assert_true(table.is_empty());
}
WHEN("All columns are equal and not empty.") {
fort::char_table table;
assert_true(set_cpp_test_props_for_table(&table));
@@ -55,6 +65,7 @@ void test_cpp_table_basic(void)
"| | | | |\n"
"+---+---+-----+----------+\n";
assert_string_equal(table_str, table_str_etalon);
assert_true(table.is_empty() == false);
}
WHEN("Checking basic constructors and assignmets.") {