From f8b81b5a5364bd6d6da004d92dac40b650e365f1 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 7 Feb 2012 12:26:43 +0100 Subject: [PATCH] add isl_printer_print_pw_aff test Signed-off-by: Sven Verdoolaege --- isl_test.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/isl_test.c b/isl_test.c index c090604e..689f75e6 100644 --- a/isl_test.c +++ b/isl_test.c @@ -2595,6 +2595,33 @@ int test_union_pw(isl_ctx *ctx) return 0; } +int test_output(isl_ctx *ctx) +{ + char *s; + const char *str; + isl_pw_aff *pa; + isl_printer *p; + int equal; + + str = "[x] -> { [1] : x % 4 <= 2; [2] : x = 3 }"; + pa = isl_pw_aff_read_from_str(ctx, str); + + p = isl_printer_to_str(ctx); + p = isl_printer_set_output_format(p, ISL_FORMAT_C); + p = isl_printer_print_pw_aff(p, pa); + s = isl_printer_get_str(p); + isl_printer_free(p); + isl_pw_aff_free(pa); + equal = !strcmp(s, "(2 - x + 4*floord(x, 4) >= 0) ? (1) : 2"); + free(s); + if (equal < 0) + return -1; + if (!equal) + isl_die(ctx, isl_error_unknown, "unexpected result", return -1); + + return 0; +} + int main() { struct isl_ctx *ctx; @@ -2603,6 +2630,8 @@ int main() assert(srcdir); ctx = isl_ctx_alloc(); + if (test_output(ctx) < 0) + goto error; if (test_vertices(ctx) < 0) goto error; if (test_fixed(ctx) < 0) -- 2.11.4.GIT