argument parsing: handle --help option in order
[platform/upstream/isl.git] / isl_test.c
index 485d8b4..e086b93 100644 (file)
@@ -205,6 +205,9 @@ int test_parse(struct isl_ctx *ctx)
                                      "[n] -> { [i] : i <= n }") < 0)
                return -1;
 
+       if (test_parse_map_equal(ctx, "{ [*] }", "{ [a] }") < 0)
+               return -1;
+
        return 0;
 }
 
@@ -3418,10 +3421,12 @@ static int test_ast(isl_ctx *ctx)
        expr = isl_ast_expr_add(expr1, expr2);
        expr = isl_ast_expr_neg(expr);
        str = isl_ast_expr_to_str(expr);
-       ok = !strcmp(str, "-(A + B)");
+       ok = str ? !strcmp(str, "-(A + B)") : -1;
        free(str);
        isl_ast_expr_free(expr);
 
+       if (ok < 0)
+               return -1;
        if (!ok)
                isl_die(ctx, isl_error_unknown,
                        "isl_ast_expr printed incorrectly", return -1);
@@ -3432,10 +3437,12 @@ static int test_ast(isl_ctx *ctx)
        expr3 = isl_ast_expr_from_id(isl_id_alloc(ctx, "C", NULL));
        expr = isl_ast_expr_sub(expr3, expr);
        str = isl_ast_expr_to_str(expr);
-       ok = !strcmp(str, "C - (A + B)");
+       ok = str ? !strcmp(str, "C - (A + B)") : -1;
        free(str);
        isl_ast_expr_free(expr);
 
+       if (ok < 0)
+               return -1;
        if (!ok)
                isl_die(ctx, isl_error_unknown,
                        "isl_ast_expr printed incorrectly", return -1);
@@ -3746,10 +3753,40 @@ static int test_ast_gen(isl_ctx *ctx)
        return 0;
 }
 
+/* Check if dropping output dimensions from an isl_pw_multi_aff
+ * works properly.
+ */
+static int test_pw_multi_aff(isl_ctx *ctx)
+{
+       const char *str;
+       isl_pw_multi_aff *pma1, *pma2;
+       int equal;
+
+       str = "{ [i,j] -> [i+j, 4i-j] }";
+       pma1 = isl_pw_multi_aff_read_from_str(ctx, str);
+       str = "{ [i,j] -> [4i-j] }";
+       pma2 = isl_pw_multi_aff_read_from_str(ctx, str);
+
+       pma1 = isl_pw_multi_aff_drop_dims(pma1, isl_dim_out, 0, 1);
+
+       equal = isl_pw_multi_aff_plain_is_equal(pma1, pma2);
+
+       isl_pw_multi_aff_free(pma1);
+       isl_pw_multi_aff_free(pma2);
+       if (equal < 0)
+               return -1;
+       if (!equal)
+               isl_die(ctx, isl_error_unknown,
+                       "expressions not equal", return -1);
+
+       return 0;
+}
+
 struct {
        const char *name;
        int (*fn)(isl_ctx *ctx);
 } tests [] = {
+       { "piecewise multi affine expressions", &test_pw_multi_aff },
        { "conversion", &test_conversion },
        { "list", &test_list },
        { "align parameters", &test_align_parameters },