From 099c97312af01b57a0dd6a932274f14438553392 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Sat, 1 Dec 2018 11:25:38 +0300 Subject: [PATCH] [A] Added more tests --- tests/bb_tests/test_table_basic.c | 44 ++++++++++++++++++++++++ tests/bb_tests/test_table_border_style.c | 2 +- tests/main_test.c | 2 ++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/bb_tests/test_table_basic.c b/tests/bb_tests/test_table_basic.c index 7d7699e..f1a99eb 100644 --- a/tests/bb_tests/test_table_basic.c +++ b/tests/bb_tests/test_table_basic.c @@ -869,3 +869,47 @@ void test_table_copy(void) +void test_table_changing_cell(void) +{ + ft_table_t *table = NULL; + + WHEN("All columns are equal and not empty") { + table = ft_create_table(); + assert_true(table != NULL); + assert_true(set_test_props_for_table(table) == FT_SUCCESS); + + ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); + 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_cur_row(table) == 3); + assert_true(ft_cur_col(table) == 0); + + ft_set_cur_cell(table, 1, 1); + assert_true(ft_cur_row(table) == 1); + assert_true(ft_cur_col(table) == 1); + assert_true(ft_write(table, "A") == FT_SUCCESS); + assert_true(ft_cur_row(table) == 1); + assert_true(ft_cur_col(table) == 2); + + 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" + "| 3 | A | 234 | 3.140000 |\n" + "| | | | |\n" + "+---+---+-----+----------+\n" + "| | | | |\n" + "| 3 | c | 234 | 3.140000 |\n" + "| | | | |\n" + "+---+---+-----+----------+\n"; + assert_str_equal(table_str, table_str_etalon); + ft_destroy_table(table); + } +} diff --git a/tests/bb_tests/test_table_border_style.c b/tests/bb_tests/test_table_border_style.c index 4d0075b..a8211d5 100644 --- a/tests/bb_tests/test_table_border_style.c +++ b/tests/bb_tests/test_table_border_style.c @@ -428,7 +428,7 @@ void test_table_builtin_border_styles(void) assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); -#ifdef FT_HAVE_WCHAR +#if defined(FT_HAVE_WCHAR) && !defined(FT_MICROSOFT_COMPILER) ft_set_default_border_style(FT_DOUBLE2_STYLE); table = create_basic_wtable(); table_wstr = ft_to_wstring(table); diff --git a/tests/main_test.c b/tests/main_test.c index 20ab223..9e1067a 100644 --- a/tests/main_test.c +++ b/tests/main_test.c @@ -13,6 +13,7 @@ void test_table_sizes(void); void test_table_geometry(void); void test_table_basic(void); void test_table_copy(void); +void test_table_changing_cell(void); #ifdef FT_HAVE_WCHAR void test_wcs_table_boundaries(void); #endif @@ -46,6 +47,7 @@ struct test_case bb_test_suit [] = { {"test_wcs_table_boundaries", test_wcs_table_boundaries}, #endif {"test_table_write", test_table_write}, + {"test_table_changing_cell", test_table_changing_cell}, {"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},