1 /*******************************/
2 /* GENERATED FILE, DO NOT EDIT */
3 /*******************************/
7 /*******************************/
8 /* GENERATED FILE, DO NOT EDIT */
9 /*******************************/
16 XBT_TEST_UNIT("controlflow", test_controlflow, "basic nested control flow")
21 xbt_test_add0("basic nested control flow");
25 xbt_test_fail1("M1: n=%d (!= 1)", n);
29 xbt_test_fail1("M2: n=%d (!= 2)", n);
31 THROW0(unknown_error, 0, "something");
35 xbt_test_fail1("M3: n=%d (!= 3)", n);
42 xbt_test_fail1("M2: n=%d (!= 5)", n);
44 THROW0(unknown_error, 0, "something");
48 xbt_test_fail1("M3: n=%d (!= 6)", n);
53 xbt_test_fail1("MX: n=%d (shouldn't reach this point)", n);
57 xbt_test_fail1("M4: n=%d (!= 7)", n);
62 xbt_test_fail1("M5: n=%d (!= 8)", n);
65 XBT_TEST_UNIT("value", test_value, "exception value passing")
70 THROW0(unknown_error, 2, "toto");
73 xbt_test_add0("exception value passing");
74 if (ex.category != unknown_error)
75 xbt_test_fail1("category=%d (!= 1)", ex.category);
77 xbt_test_fail1("value=%d (!= 2)", ex.value);
78 if (strcmp(ex.msg, "toto"))
79 xbt_test_fail1("message=%s (!= toto)", ex.msg);
84 XBT_TEST_UNIT("variables", test_variables, "variable value preservation")
90 r1 = r2 = v1 = v2 = 1234;
94 THROW0(unknown_error, 0, "toto");
96 xbt_test_add0("variable preservation");
98 xbt_test_fail1("r1=%d (!= 1234)", r1);
100 xbt_test_fail1("v1=%d (!= 1234)", v1);
101 /* r2 is allowed to be destroyed because not volatile */
103 xbt_test_fail1("v2=%d (!= 5678)", v2);
108 XBT_TEST_UNIT("cleanup", test_cleanup, "cleanup handling")
114 xbt_test_add0("cleanup handling");
120 THROW0(1, 2, "blah");
123 xbt_test_fail1("v1 = %d (!= 5678)", v1);
128 xbt_test_fail1("v1 = %d (!= 5678)", v1);
129 if (!(ex.category == 1 && ex.value == 2 && !strcmp(ex.msg, "blah")))
130 xbt_test_fail0("unexpected exception contents");
134 xbt_test_fail0("xbt_ex_free not executed");
139 * The following is the example included in the documentation. It's a good
140 * idea to check its syntax even if we don't try to run it.
141 * And actually, it allows to put comments in the code despite doxygen.
143 static char *mallocex(int size)
148 #define SMALLAMOUNT 10
149 #define TOOBIG 100000000
151 #if 0 /* this contains syntax errors, actually */
152 static void bad_example(void)
161 char *cp1, *cp2, *cp3;
163 cp1 = mallocex(SMALLAMOUNT);
164 globalcontext->first = cp1;
165 cp2 = mallocex(TOOBIG);
166 cp3 = mallocex(SMALLAMOUNT);
178 printf("cp3=%s", cp3);
181 /* end_of_bad_example */
188 static void good_example(void)
190 global_context_t *global_context = malloc(sizeof(global_context_t));
195 char *volatile /*03 */ cp1 = NULL /*02 */ ;
196 char *volatile /*03 */ cp2 = NULL /*02 */ ;
197 char *volatile /*03 */ cp3 = NULL /*02 */ ;
199 cp1 = mallocex(SMALLAMOUNT);
200 global_context->first = cp1;
201 cp1 = NULL /*05 give away */ ;
202 cp2 = mallocex(TOOBIG);
203 cp3 = mallocex(SMALLAMOUNT);
207 printf("cp3=%s", cp3 == NULL /*02 */ ? "" : cp3);
212 /*05 cp1 was given away */
215 /*05 global context untouched */
219 /* end_of_good_example */
221 /*******************************/
222 /* GENERATED FILE, DO NOT EDIT */
223 /*******************************/