drop redundant input_format argument from reading functions
[platform/upstream/isl.git] / isl_test.c
index 7aa2db0..2823e2d 100644 (file)
@@ -1,3 +1,12 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the GNU LGPLv2.1 license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
 #include <assert.h>
 #include <stdio.h>
 #include <limits.h>
@@ -21,8 +30,8 @@ void test_read(struct isl_ctx *ctx)
        input = fopen(filename, "r");
        assert(input);
 
-       bset1 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_OMEGA);
-       bset2 = isl_basic_set_read_from_str(ctx, str, 0, ISL_FORMAT_OMEGA);
+       bset1 = isl_basic_set_read_from_file(ctx, input, 0);
+       bset2 = isl_basic_set_read_from_str(ctx, str, 0);
 
        assert(isl_basic_set_is_equal(bset1, bset2) == 1);
 
@@ -361,12 +370,12 @@ void test_application_case(struct isl_ctx *ctx, const char *name)
        input = fopen(filename, "r");
        assert(input);
 
-       bset1 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_OMEGA);
-       bmap = isl_basic_map_read_from_file(ctx, input, 0, ISL_FORMAT_OMEGA);
+       bset1 = isl_basic_set_read_from_file(ctx, input, 0);
+       bmap = isl_basic_map_read_from_file(ctx, input, 0);
 
        bset1 = isl_basic_set_apply(bset1, bmap);
 
-       bset2 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_OMEGA);
+       bset2 = isl_basic_set_read_from_file(ctx, input, 0);
 
        assert(isl_basic_set_is_equal(bset1, bset2) == 1);
 
@@ -395,8 +404,8 @@ void test_affine_hull_case(struct isl_ctx *ctx, const char *name)
        input = fopen(filename, "r");
        assert(input);
 
-       bset1 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_POLYLIB);
-       bset2 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_POLYLIB);
+       bset1 = isl_basic_set_read_from_file(ctx, input, 0);
+       bset2 = isl_basic_set_read_from_file(ctx, input, 0);
 
        bset1 = isl_basic_set_affine_hull(bset1);
 
@@ -429,13 +438,13 @@ void test_convex_hull_case(struct isl_ctx *ctx, const char *name)
        input = fopen(filename, "r");
        assert(input);
 
-       bset1 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_POLYLIB);
-       bset2 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_POLYLIB);
+       bset1 = isl_basic_set_read_from_file(ctx, input, 0);
+       bset2 = isl_basic_set_read_from_file(ctx, input, 0);
 
        set = isl_basic_set_union(bset1, bset2);
        bset1 = isl_set_convex_hull(set);
 
-       bset2 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_POLYLIB);
+       bset2 = isl_basic_set_read_from_file(ctx, input, 0);
 
        assert(isl_basic_set_is_equal(bset1, bset2) == 1);
 
@@ -461,6 +470,7 @@ void test_convex_hull(struct isl_ctx *ctx)
        test_convex_hull_case(ctx, "convex11");
        test_convex_hull_case(ctx, "convex12");
        test_convex_hull_case(ctx, "convex13");
+       test_convex_hull_case(ctx, "convex14");
 }
 
 void test_gist_case(struct isl_ctx *ctx, const char *name)
@@ -469,7 +479,6 @@ void test_gist_case(struct isl_ctx *ctx, const char *name)
        FILE *input;
        int n;
        struct isl_basic_set *bset1, *bset2;
-       struct isl_set *set;
 
        n = snprintf(filename, sizeof(filename),
                        "%s/test_inputs/%s.polylib", srcdir, name);
@@ -477,12 +486,12 @@ void test_gist_case(struct isl_ctx *ctx, const char *name)
        input = fopen(filename, "r");
        assert(input);
 
-       bset1 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_POLYLIB);
-       bset2 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_POLYLIB);
+       bset1 = isl_basic_set_read_from_file(ctx, input, 0);
+       bset2 = isl_basic_set_read_from_file(ctx, input, 0);
 
        bset1 = isl_basic_set_gist(bset1, bset2);
 
-       bset2 = isl_basic_set_read_from_file(ctx, input, 0, ISL_FORMAT_POLYLIB);
+       bset2 = isl_basic_set_read_from_file(ctx, input, 0);
 
        assert(isl_basic_set_is_equal(bset1, bset2) == 1);
 
@@ -504,8 +513,8 @@ static struct isl_set *s_union(struct isl_ctx *ctx,
        struct isl_basic_set *bset2;
        struct isl_set *set1, *set2;
 
-       bset1 = isl_basic_set_read_from_str(ctx, s1, 0, ISL_FORMAT_OMEGA);
-       bset2 = isl_basic_set_read_from_str(ctx, s2, 0, ISL_FORMAT_OMEGA);
+       bset1 = isl_basic_set_read_from_str(ctx, s1, 0);
+       bset2 = isl_basic_set_read_from_str(ctx, s2, 0);
        set1 = isl_set_from_basic_set(bset1);
        set2 = isl_set_from_basic_set(bset2);
        return isl_set_union(set1, set2);
@@ -518,61 +527,61 @@ void test_coalesce(struct isl_ctx *ctx)
        set = s_union(ctx, "{[x,y]: x >= 0 & x <= 10 & y >= 0 & y <= 10}",
                           "{[x,y]: y >= x & x >= 2 & 5 >= y}");
        set = isl_set_coalesce(set);
-       assert(set->n == 1);
+       assert(set && set->n == 1);
        isl_set_free(set);
 
        set = s_union(ctx, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0}",
                       "{[x,y]: x + y >= 10 & y <= x & x + y <= 20 & y >= 0}");
        set = isl_set_coalesce(set);
-       assert(set->n == 1);
+       assert(set && set->n == 1);
        isl_set_free(set);
 
        set = s_union(ctx, "{[x,y]: y >= 0 & 2x + y <= 30 & y <= 10 & x >= 0}",
                       "{[x,y]: x + y >= 10 & y <= x & x + y <= 19 & y >= 0}");
        set = isl_set_coalesce(set);
-       assert(set->n == 2);
+       assert(set && set->n == 2);
        isl_set_free(set);
 
        set = s_union(ctx, "{[x,y]: y >= 0 & x <= 5 & y <= x}",
                       "{[x,y]: y >= 0 & x >= 6 & x <= 10 & y <= x}");
        set = isl_set_coalesce(set);
-       assert(set->n == 1);
+       assert(set && set->n == 1);
        isl_set_free(set);
 
        set = s_union(ctx, "{[x,y]: y >= 0 & x <= 5 & y <= x}",
                       "{[x,y]: y >= 0 & x >= 7 & x <= 10 & y <= x}");
        set = isl_set_coalesce(set);
-       assert(set->n == 2);
+       assert(set && set->n == 2);
        isl_set_free(set);
 
        set = s_union(ctx, "{[x,y]: y >= 0 & x <= 5 & y <= x}",
                       "{[x,y]: y >= 0 & x >= 6 & x <= 10 & y + 1 <= x}");
        set = isl_set_coalesce(set);
-       assert(set->n == 2);
+       assert(set && set->n == 2);
        isl_set_free(set);
 
        set = s_union(ctx, "{[x,y]: y >= 0 & x <= 5 & y <= x}",
                       "{[x,y]: y >= 0 & x = 6 & y <= 6}");
        set = isl_set_coalesce(set);
-       assert(set->n == 1);
+       assert(set && set->n == 1);
        isl_set_free(set);
 
        set = s_union(ctx, "{[x,y]: y >= 0 & x <= 5 & y <= x}",
                       "{[x,y]: y >= 0 & x = 7 & y <= 6}");
        set = isl_set_coalesce(set);
-       assert(set->n == 2);
+       assert(set && set->n == 2);
        isl_set_free(set);
 
        set = s_union(ctx, "{[x,y]: y >= 0 & x <= 5 & y <= x}",
                       "{[x,y]: y >= 0 & x = 6 & y <= 5}");
        set = isl_set_coalesce(set);
-       assert(set->n == 2);
+       assert(set && set->n == 2);
        isl_set_free(set);
 
        set = s_union(ctx, "{[x,y]: y >= 0 & x <= 5 & y <= x}",
                       "{[x,y]: y >= 0 & x = 6 & y <= 7}");
        set = isl_set_coalesce(set);
-       assert(set->n == 2);
+       assert(set && set->n == 2);
        isl_set_free(set);
 }
 
@@ -581,6 +590,7 @@ int main()
        struct isl_ctx *ctx;
 
        srcdir = getenv("srcdir");
+       assert(srcdir);
 
        ctx = isl_ctx_alloc();
        test_read(ctx);