From 0dc63a6e96d6bf1798be4f6cb49f2db81b322003 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 10 Jan 2021 10:05:36 +0100 Subject: [PATCH] merge test_plain_unshifted_simple_hull and test_unshifted_simple_hull These two testing functions are identical apart from the specific simple hull function that is being called. Specifying this function in the input data allows the two testing functions to be merged into a single testing function. This will make it easier to add another simple hull test in the next commit. Signed-off-by: Sven Verdoolaege --- isl_test.c | 70 +++++++++++++++----------------------------------------------- 1 file changed, 17 insertions(+), 53 deletions(-) diff --git a/isl_test.c b/isl_test.c index 86f611e9..bb63e80a 100644 --- a/isl_test.c +++ b/isl_test.c @@ -1402,76 +1402,42 @@ static isl_stat test_plain_unshifted_simple_hull_special(isl_ctx *ctx) return isl_stat_ok; } -/* Pairs of sets and the corresponding expected results of - * isl_set_plain_unshifted_simple_hull. +/* Inputs for simple hull tests, consisting of + * the specific simple hull function, the input set and the expected result. */ struct { + __isl_give isl_basic_set *(*fn)(__isl_take isl_set *set); const char *set; const char *hull; -} plain_unshifted_simple_hull_tests[] = { - { "{ [i,j] : i >= 1 and j >= 1 or i >= 2 and j <= 10 }", +} simple_hull_tests[] = { + { &isl_set_plain_unshifted_simple_hull, + "{ [i,j] : i >= 1 and j >= 1 or i >= 2 and j <= 10 }", "{ [i,j] : i >= 1 }" }, - { "{ [n,i,j,k] : (i mod 3 = 2 and j mod 4 = 2) or " + { &isl_set_plain_unshifted_simple_hull, + "{ [n,i,j,k] : (i mod 3 = 2 and j mod 4 = 2) or " "(j mod 4 = 2 and k mod 6 = n) }", "{ [n,i,j,k] : j mod 4 = 2 }" }, -}; - -/* Basic tests for isl_set_plain_unshifted_simple_hull. - */ -static int test_plain_unshifted_simple_hull(isl_ctx *ctx) -{ - int i; - isl_set *set; - isl_basic_set *hull, *expected; - isl_bool equal; - - for (i = 0; i < ARRAY_SIZE(plain_unshifted_simple_hull_tests); ++i) { - const char *str; - str = plain_unshifted_simple_hull_tests[i].set; - set = isl_set_read_from_str(ctx, str); - str = plain_unshifted_simple_hull_tests[i].hull; - expected = isl_basic_set_read_from_str(ctx, str); - hull = isl_set_plain_unshifted_simple_hull(set); - equal = isl_basic_set_is_equal(hull, expected); - isl_basic_set_free(hull); - isl_basic_set_free(expected); - if (equal < 0) - return -1; - if (!equal) - isl_die(ctx, isl_error_unknown, "unexpected hull", - return -1); - } - - return 0; -} - -/* Pairs of sets and the corresponding expected results of - * isl_set_unshifted_simple_hull. - */ -struct { - const char *set; - const char *hull; -} unshifted_simple_hull_tests[] = { - { "{ [0,x,y] : x <= -1; [1,x,y] : x <= y <= -x; [2,x,y] : x <= 1 }", + { &isl_set_unshifted_simple_hull, + "{ [0,x,y] : x <= -1; [1,x,y] : x <= y <= -x; [2,x,y] : x <= 1 }", "{ [t,x,y] : 0 <= t <= 2 and x <= 1 }" }, }; -/* Basic tests for isl_set_unshifted_simple_hull. +/* Basic tests for various simple hull functions. */ -static int test_unshifted_simple_hull(isl_ctx *ctx) +static int test_various_simple_hull(isl_ctx *ctx) { int i; isl_set *set; isl_basic_set *hull, *expected; isl_bool equal; - for (i = 0; i < ARRAY_SIZE(unshifted_simple_hull_tests); ++i) { + for (i = 0; i < ARRAY_SIZE(simple_hull_tests); ++i) { const char *str; - str = unshifted_simple_hull_tests[i].set; + str = simple_hull_tests[i].set; set = isl_set_read_from_str(ctx, str); - str = unshifted_simple_hull_tests[i].hull; + str = simple_hull_tests[i].hull; expected = isl_basic_set_read_from_str(ctx, str); - hull = isl_set_unshifted_simple_hull(set); + hull = simple_hull_tests[i].fn(set); equal = isl_basic_set_is_equal(hull, expected); isl_basic_set_free(hull); isl_basic_set_free(expected); @@ -1508,9 +1474,7 @@ static int test_simple_hull(struct isl_ctx *ctx) if (test_plain_unshifted_simple_hull_special(ctx) < 0) return -1; - if (test_plain_unshifted_simple_hull(ctx) < 0) - return -1; - if (test_unshifted_simple_hull(ctx) < 0) + if (test_various_simple_hull(ctx) < 0) return -1; return 0; -- 2.11.4.GIT