Merge branch 'maint'
[platform/upstream/isl.git] / isl_test.c
index 5c267f2..6f47057 100644 (file)
@@ -196,6 +196,10 @@ int test_parse(struct isl_ctx *ctx)
                                      "{ [a] -> [b] : true }") < 0)
                return -1;
 
+       if (test_parse_map_equal(ctx, "{ [i] : i/2 <= 5 }",
+                                     "{ [i] : i <= 10 }") < 0)
+               return -1;
+
        return 0;
 }
 
@@ -312,7 +316,9 @@ void test_dim(struct isl_ctx *ctx)
 
 static int test_div(isl_ctx *ctx)
 {
+       unsigned n;
        const char *str;
+       int empty;
        isl_int v;
        isl_space *dim;
        isl_set *set;
@@ -617,6 +623,28 @@ static int test_div(isl_ctx *ctx)
        if (!set)
                return -1;
 
+       str = "{ [i,j] : 2*[i/2] + 3 * [j/4] <= 10 and 2 i = j }";
+       bset = isl_basic_set_read_from_str(ctx, str);
+       n = isl_basic_set_dim(bset, isl_dim_div);
+       isl_basic_set_free(bset);
+       if (!bset)
+               return -1;
+       if (n != 0)
+               isl_die(ctx, isl_error_unknown,
+                       "expecting no existentials", return -1);
+
+       str = "{ [i,j,k] : 3 + i + 2j >= 0 and 2 * [(i+2j)/4] <= k }";
+       set = isl_set_read_from_str(ctx, str);
+       set = isl_set_remove_divs_involving_dims(set, isl_dim_set, 0, 2);
+       set = isl_set_fix_si(set, isl_dim_set, 2, -3);
+       empty = isl_set_is_empty(set);
+       isl_set_free(set);
+       if (empty < 0)
+               return -1;
+       if (!empty)
+               isl_die(ctx, isl_error_unknown,
+                       "result not as accurate as expected", return -1);
+
        return 0;
 }
 
@@ -3039,10 +3067,54 @@ int test_align_parameters(isl_ctx *ctx)
        return 0;
 }
 
+static int test_list(isl_ctx *ctx)
+{
+       isl_id *a, *b, *c, *d, *id;
+       isl_id_list *list;
+       int ok;
+
+       a = isl_id_alloc(ctx, "a", NULL);
+       b = isl_id_alloc(ctx, "b", NULL);
+       c = isl_id_alloc(ctx, "c", NULL);
+       d = isl_id_alloc(ctx, "d", NULL);
+
+       list = isl_id_list_alloc(ctx, 4);
+       list = isl_id_list_add(list, a);
+       list = isl_id_list_add(list, b);
+       list = isl_id_list_add(list, c);
+       list = isl_id_list_add(list, d);
+       list = isl_id_list_drop(list, 1, 1);
+
+       if (isl_id_list_n_id(list) != 3) {
+               isl_id_list_free(list);
+               isl_die(ctx, isl_error_unknown,
+                       "unexpected number of elements in list", return -1);
+       }
+
+       id = isl_id_list_get_id(list, 0);
+       ok = id == a;
+       isl_id_free(id);
+       id = isl_id_list_get_id(list, 1);
+       ok = ok && id == c;
+       isl_id_free(id);
+       id = isl_id_list_get_id(list, 2);
+       ok = ok && id == d;
+       isl_id_free(id);
+
+       isl_id_list_free(list);
+
+       if (!ok)
+               isl_die(ctx, isl_error_unknown,
+                       "unexpected elements in list", return -1);
+
+       return 0;
+}
+
 struct {
        const char *name;
        int (*fn)(isl_ctx *ctx);
 } tests [] = {
+       { "list", &test_list },
        { "align parameters", &test_align_parameters },
        { "eliminate", &test_eliminate },
        { "reisdue class", &test_residue_class },