privately export isl_basic_map_fast_cmp and isl_basic_map_fast_is_equal
[platform/upstream/isl.git] / isl_test.c
index a87de2c..5b7a9ea 100644 (file)
@@ -152,7 +152,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_div, pos, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       assert(bset->n_div == 1);
+       assert(bset && bset->n_div == 1);
        isl_basic_set_free(bset);
 
        /* test 2 */
@@ -181,7 +181,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_div, pos, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       assert(bset->n_div == 1);
+       assert(bset && bset->n_div == 1);
        isl_basic_set_free(bset);
 
        /* test 3 */
@@ -210,7 +210,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_div, pos, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       assert(bset->n_div == 1);
+       assert(bset && bset->n_div == 1);
        isl_basic_set_free(bset);
 
        /* test 4 */
@@ -262,7 +262,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       assert(bset->n_div == 0);
+       assert(bset && bset->n_div == 0);
        isl_basic_set_free(bset);
 
        /* test 6 */
@@ -285,7 +285,7 @@ void test_div(struct isl_ctx *ctx)
        isl_constraint_set_coefficient(c, isl_dim_set, 1, v);
        bset = isl_basic_set_add_constraint(bset, c);
 
-       assert(bset->n_div == 1);
+       assert(bset && bset->n_div == 1);
        isl_basic_set_free(bset);
 
        /* test 7 */
@@ -316,7 +316,7 @@ void test_div(struct isl_ctx *ctx)
 
        /* Test disabled for now */
        /*
-       assert(bset->n_div == 1);
+       assert(bset && bset->n_div == 1);
        */
        isl_basic_set_free(bset);
 
@@ -348,7 +348,7 @@ void test_div(struct isl_ctx *ctx)
 
        /* Test disabled for now */
        /*
-       assert(bset->n_div == 1);
+       assert(bset && bset->n_div == 1);
        */
        isl_basic_set_free(bset);
 
@@ -1311,6 +1311,35 @@ void test_sv(struct isl_ctx *ctx)
        isl_map_free(map);
 }
 
+void test_bijective_case(struct isl_ctx *ctx, const char *str, int bijective)
+{
+       isl_map *map;
+
+       map = isl_map_read_from_str(ctx, str, -1);
+       if (bijective)
+               assert(isl_map_is_bijective(map));
+       else
+               assert(!isl_map_is_bijective(map));
+       isl_map_free(map);
+}
+
+void test_bijective(struct isl_ctx *ctx)
+{
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [i]}", 0);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [i] : j=i}", 1);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [i] : j=0}", 1);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [i] : j=N}", 1);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [j,i]}", 1);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [i+j]}", 0);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> []}", 0);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [i,j,N]}", 1);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [2i]}", 0);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [i,i]}", 0);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [2i,i]}", 0);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [2i,j]}", 1);
+       test_bijective_case(ctx, "[N,M]->{[i,j] -> [x,y] : 2x=i & y =j}", 1);
+}
+
 int main()
 {
        struct isl_ctx *ctx;
@@ -1320,6 +1349,7 @@ int main()
 
        ctx = isl_ctx_alloc();
        test_sv(ctx);
+       test_bijective(ctx);
        test_dep(ctx);
        test_read(ctx);
        test_bounded(ctx);