summaryrefslogtreecommitdiff
path: root/isl_test.c
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2008-08-15 21:56:30 +0200
committerSven Verdoolaege <skimo@kotnet.org>2008-08-25 10:15:08 +0200
commit6ee7c30d7fedfd81f6254fe15534a154ce7624a1 (patch)
treeaa3add251079db8f50677b0f2b2be262712fc24e /isl_test.c
parentfb6acf38cd8a8220b2282406613fe229aa96fa73 (diff)
downloadisl-6ee7c30d7fedfd81f6254fe15534a154ce7624a1.tar.gz
isl-6ee7c30d7fedfd81f6254fe15534a154ce7624a1.tar.bz2
isl-6ee7c30d7fedfd81f6254fe15534a154ce7624a1.zip
add convex hull computation
Diffstat (limited to 'isl_test.c')
-rw-r--r--isl_test.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/isl_test.c b/isl_test.c
new file mode 100644
index 00000000..c5fdd922
--- /dev/null
+++ b/isl_test.c
@@ -0,0 +1,61 @@
+#include <assert.h>
+#include <stdio.h>
+#include <limits.h>
+#include <isl_ctx.h>
+#include <isl_set.h>
+
+static char *srcdir;
+
+void test_convex_hull_case(struct isl_ctx *ctx, const char *name)
+{
+ char filename[PATH_MAX];
+ 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);
+ assert(n < sizeof(filename));
+ input = fopen(filename, "r");
+ assert(input);
+
+ bset1 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_POLYLIB);
+ bset2 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_POLYLIB);
+
+ set = isl_basic_set_union(ctx, bset1, bset2);
+ bset1 = isl_set_convex_hull(ctx, set);
+
+ bset2 = isl_basic_set_read_from_file(ctx, input, ISL_FORMAT_POLYLIB);
+
+ assert(isl_basic_set_is_equal(ctx, bset1, bset2) == 1);
+
+ isl_basic_set_free(ctx, bset1);
+ isl_basic_set_free(ctx, bset2);
+
+ fclose(input);
+}
+
+void test_convex_hull(struct isl_ctx *ctx)
+{
+ test_convex_hull_case(ctx, "convex0");
+ test_convex_hull_case(ctx, "convex1");
+ test_convex_hull_case(ctx, "convex2");
+ test_convex_hull_case(ctx, "convex3");
+ test_convex_hull_case(ctx, "convex4");
+ test_convex_hull_case(ctx, "convex5");
+ test_convex_hull_case(ctx, "convex6");
+ test_convex_hull_case(ctx, "convex7");
+}
+
+int main()
+{
+ struct isl_ctx *ctx;
+
+ srcdir = getenv("srcdir");
+
+ ctx = isl_ctx_alloc();
+ test_convex_hull(ctx);
+ isl_ctx_free(ctx);
+ return 0;
+}