6 #include <isl/options.h>
9 /* Throw a runtime exception.
11 static void die_impl(const char *file
, int line
, const char *message
)
13 std::ostringstream ss
;
14 ss
<< file
<< ":" << line
<< ": " << message
;
15 throw std::runtime_error(ss
.str());
18 #define die(msg) die_impl(__FILE__, __LINE__, msg)
20 #include "isl_test_cpp17-generic.cc"
22 /* Check that an isl::exception_invalid gets thrown by "fn".
24 static void check_invalid(const std::function
<void(void)> &fn
)
29 } catch (const isl::exception_invalid
&e
) {
33 die("no invalid exception was generated");
38 * In particular, check that the object attached to an identifier
39 * can be retrieved again and that retrieving an object of the wrong type
40 * or retrieving an object when no object was attached results in an exception.
42 static void test_user(isl::ctx ctx
)
44 isl::id
id(ctx
, "test", 5);
45 isl::id
id2(ctx
, "test2");
46 isl::id
id3(ctx
, "test3", std::string("s"));
48 auto int_user
= id
.user
<int>();
50 die("wrong integer retrieved from isl::id");
51 auto s_user
= id3
.user
<std::string
>();
53 die("wrong string retrieved from isl::id");
54 check_invalid([&id
] () { id
.user
<std::string
>(); });
55 check_invalid([&id2
] () { id2
.user
<int>(); });
56 check_invalid([&id2
] () { id2
.user
<std::string
>(); });
57 check_invalid([&id3
] () { id3
.user
<int>(); });
60 /* Test the C++17 specific features of the (unchecked) isl C++ interface
68 isl_ctx
*ctx
= isl_ctx_alloc();
70 isl_options_set_on_error(ctx
, ISL_ON_ERROR_ABORT
);