From 1c94089001ed4dde914165688c6b26c20e432de3 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Sat, 24 Mar 2018 17:01:29 +0300 Subject: [PATCH] [C] Replaced old string cmp macros with the new one --- tests/test_table_basic.c | 28 +++++++------------ tests/test_table_border_style.c | 23 +++------------- tests/test_table_options.c | 48 +++++++-------------------------- tests/tests.h | 16 +++++------ 4 files changed, 30 insertions(+), 85 deletions(-) diff --git a/tests/test_table_basic.c b/tests/test_table_basic.c index b76fcb0..a17576a 100644 --- a/tests/test_table_basic.c +++ b/tests/test_table_basic.c @@ -31,8 +31,7 @@ void test_table_basic(void) "| 3 | c | 234 | 3.140000 |\n" "| | | | |\n" "+---+---+-----+----------+\n"; -// fprintf(stderr, "content:\n%s", table_str); - assert_true( strcmp(table_str, table_str_etalon) == 0); + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -62,8 +61,7 @@ void test_table_basic(void) L"| 3 | c | 234 | 3.140000 |\n" L"| | | | |\n" L"+---+---+-----+----------+\n"; -// fprintf(stderr, "content:\n%s", table_str); - assert_true( wcscmp(table_str, table_str_etalon) == 0); + assert_wcs_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -95,8 +93,7 @@ void test_table_basic(void) "| 234 | 3.140000 | 3 | c |\n" "| | | | |\n" "+-----+----------+----------+----------+\n"; -// fprintf(stderr, "content:\n%s", table_str); - assert_true( strcmp(table_str, table_str_etalon) == 0); + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -126,8 +123,7 @@ void test_table_basic(void) L"| 234 | 3.140000 | 3 | c |\n" L"| | | | |\n" L"+-----+----------+----------+----------+\n"; -// fprintf(stderr, "content:\n%s", table_str); - assert_true( wcscmp(table_str, table_str_etalon) == 0); + assert_wcs_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -157,8 +153,7 @@ void test_table_basic(void) "| 234 | 3.140000 | | |\n" "| | | | |\n" "+-----+----------+----------+----------+\n"; -// fprintf(stderr, "content:\n%s", table_str); - assert_true( strcmp(table_str, table_str_etalon) == 0); + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -188,8 +183,7 @@ void test_table_basic(void) L"| 234 | 3.140000 | | |\n" L"| | | | |\n" L"+-----+----------+----------+----------+\n"; -// fwprintf(stdout, L"content:\n%ls", table_str); - assert_true( wcscmp(table_str, table_str_etalon) == 0); + assert_wcs_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -219,8 +213,7 @@ void test_table_basic(void) "| | | | |\n" "| | | | |\n" "+--+--+--+--+\n"; -// fprintf(stderr, "content:\n%s", table_str); - assert_true( strcmp(table_str, table_str_etalon) == 0); + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -250,8 +243,7 @@ void test_table_basic(void) L"| | | | |\n" L"| | | | |\n" L"+--+--+--+--+\n"; -// fprintf(stderr, "content:\n%s", table_str); - assert_true( wcscmp(table_str, table_str_etalon) == 0); + assert_wcs_equal(table_str, table_str_etalon); ft_destroy_table(table); } } @@ -289,9 +281,7 @@ void test_wcs_table_boundaries(void) L"| 234 | 123456789 | c |\n" L"| | | |\n" L"+-----+-----------+---+\n"; -// setlocale(LC_CTYPE, ""); -// fprintf(stdout, "content:\n%ls", table_str); - assert_wcs_equal( table_str, table_str_etalon ); + assert_wcs_equal(table_str, table_str_etalon); ft_destroy_table(table); } } diff --git a/tests/test_table_border_style.c b/tests/test_table_border_style.c index bc77012..18bcb07 100644 --- a/tests/test_table_border_style.c +++ b/tests/test_table_border_style.c @@ -49,10 +49,7 @@ void test_table_border_style(void) "= 3 = 4 = 55 = 67 =\n" "= = = = =\n" "+|||+|||+||||+||||+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); @@ -90,10 +87,7 @@ void test_table_border_style(void) "= 3 = 4 = 55 = 67 =\n" "= 3 = 4 = 55 = 67 =\n" "+|||+|||+||||+||||+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -127,18 +121,7 @@ void test_table_border_style(void) "| 3 | 4 | 55 | 67 |\n" "| | | | |\n" "+---+---+----+----+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } - - - - - - - - } diff --git a/tests/test_table_options.c b/tests/test_table_options.c index 582ab52..c4d2ee6 100644 --- a/tests/test_table_options.c +++ b/tests/test_table_options.c @@ -43,10 +43,7 @@ void test_table_options(void) "| 3 | 4 | 55 | 67 |\n" "| | | | |\n" "+---+---+----+----+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -71,10 +68,7 @@ void test_table_options(void) "+---+---+----+----+\n" "| 3 | 4 | 55 | 67 |\n" "+---+---+----+----+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -103,10 +97,7 @@ void test_table_options(void) "|3|4|55|67|\n" "| | | | |\n" "+-+-+--+--+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -129,10 +120,7 @@ void test_table_options(void) "+-+-+--+--+\n" "|3|4|55|67|\n" "+-+-+--+--+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -167,10 +155,7 @@ void test_table_options(void) "| | | | |\n" "| | | | |\n" "+---+---+----+----+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -195,9 +180,7 @@ void test_table_options(void) "+-+-+--+--+\n" "|3|4|55|67|\n" "+-+-+--+--+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); + assert_str_equal(table_str, table_str_etalon); ft_set_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_OPT_BOTTOM_PADDING, 1); @@ -222,9 +205,7 @@ void test_table_options(void) "|3|4|55|67|\n" "| | | | |\n" "+-+-+--+--+\n"; -// fprintf(stderr, "content:\n%s", table_str); - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -263,10 +244,7 @@ void test_table_options(void) "| 3 | 4 | 55 | 67 |\n" "| | | | |\n" "+---+-------+--------+------+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -297,9 +275,7 @@ void test_table_options(void) "| 3 | 4 | 55 | 67 |\n" "| | | | |\n" "+-----+-----+-----+-----+\n"; - // fprintf(stderr, "content:\n%s", table_str); - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } @@ -334,11 +310,7 @@ void test_table_options(void) "| 3 | c | 234 | 3.140000 |\n" "| | | | |\n" "+---+---+-----+----------+\n"; -// fprintf(stderr, "content:\n%s", table_str); - - assert_true( strcmp(table_str, table_str_etalon) == 0); - + assert_str_equal(table_str, table_str_etalon); ft_destroy_table(table); } - } diff --git a/tests/tests.h b/tests/tests.h index bdc0c83..9535492 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -37,11 +37,6 @@ struct test_case #define assert_true(args) assert(args) -int set_test_options_for_table(FTABLE *table); -int set_test_options_as_default(); -FTABLE *create_test_int_table(int set_test_opts); - - #define assert_str_equal(str1, str2) \ if (strcmp(str1, str2) != 0) \ { \ @@ -51,8 +46,6 @@ FTABLE *create_test_int_table(int set_test_opts); exit(EXIT_FAILURE); \ } - - #define assert_wcs_equal(str1, str2) \ if (wcscmp(str1, str2) != 0) \ { \ @@ -61,7 +54,14 @@ FTABLE *create_test_int_table(int set_test_opts); fwprintf(stdout, L"Left string:\n%ls\n", str1); \ fwprintf(stdout, L"Right string:\n%ls\n", str2); \ exit(EXIT_FAILURE); \ - } \ + } + +int set_test_options_for_table(FTABLE *table); +int set_test_options_as_default(); +FTABLE *create_test_int_table(int set_test_opts); + + +