xref: /netbsd-src/external/mit/isl/dist/isl_test_plain_equal_templ.c (revision 5971e316fdea024efff6be8f03536623db06833e)
1 /*
2  * Copyright 2012      Ecole Normale Superieure
3  *
4  * Use of this software is governed by the MIT license
5  *
6  * Written by Sven Verdoolaege,
7  * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8  */
9 
10 #define xCAT(A,B) A ## B
11 #define CAT(A,B) xCAT(A,B)
12 #undef TYPE
13 #define TYPE CAT(isl_,BASE)
14 #define xFN(TYPE,NAME) TYPE ## _ ## NAME
15 #define FN(TYPE,NAME) xFN(TYPE,NAME)
16 
17 /* Is "obj" obviously equal to the object represented by "str"?
18  */
FN(BASE,plain_is_equal)19 static isl_bool FN(BASE,plain_is_equal)(__isl_keep TYPE *obj, const char *str)
20 {
21 	isl_ctx *ctx;
22 	TYPE *obj2;
23 	isl_bool equal;
24 
25 	if (!obj)
26 		return isl_bool_error;
27 
28 	ctx = FN(TYPE,get_ctx)(obj);
29 	obj2 = FN(TYPE,read_from_str)(ctx, str);
30 	equal = FN(TYPE,plain_is_equal)(obj, obj2);
31 	FN(TYPE,free)(obj2);
32 
33 	return equal;
34 }
35 
36 /* Check that "obj" is obviously equal to the object represented by "str".
37  */
FN(BASE,check_plain_equal)38 static isl_stat FN(BASE,check_plain_equal)(__isl_keep TYPE *obj,
39 	const char *str)
40 {
41 	isl_bool equal;
42 
43 	equal = FN(BASE,plain_is_equal)(obj, str);
44 	if (equal < 0)
45 		return isl_stat_error;
46 	if (!equal)
47 		isl_die(FN(TYPE,get_ctx)(obj), isl_error_unknown,
48 			"result not as expected", return isl_stat_error);
49 	return isl_stat_ok;
50 }
51