OSSP CVS Repository

ossp - Difference in ossp-pkg/ex/ex_test.c versions 1.6 and 1.7
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/ex/ex_test.c 1.6 -> 1.7

--- ex_test.c    2002/01/26 22:45:37     1.6
+++ ex_test.c    2002/01/30 10:33:36     1.7
@@ -140,6 +140,35 @@
         ts_test_fail(TS_CTX, "unexpected catching scope");
 }
 
+TS_TEST(test_cleanup)
+{
+    ex_t ex;
+    volatile int v1;
+    int cleanup;
+
+    ts_test_check(TS_CTX, "cleanup handling");
+
+    v1 = 1234;
+    cleanup = 0;
+    ex_try {
+        v1 = 5678;
+        ex_throw(1, 2, 3);
+    }
+    ex_cleanup {
+        if (v1 != 5678)
+            ts_test_fail(TS_CTX, "v1 = %d (!= 5678)", v1);
+        cleanup = 1;
+    }
+    ex_catch (ex) {
+        if (v1 != 5678)
+            ts_test_fail(TS_CTX, "v1 = %d (!= 5678)", v1);
+        if (!(ex.ex_class == (void *)1 && ex.ex_object == (void *)2 && ex.ex_value == (void *)3))
+            ts_test_fail(TS_CTX, "unexpected exception contents");
+    }
+    if (!cleanup)
+        ts_test_fail(TS_CTX, "ex_cleanup not executed");
+}
+
 int main(int argc, char *argv[])
 {
     ts_suite_t *ts;
@@ -150,6 +179,7 @@
     ts_suite_test(ts, test_value,       "exception value passing");
     ts_suite_test(ts, test_variables,   "variable value preservation");
     ts_suite_test(ts, test_shield,      "exception shielding");
+    ts_suite_test(ts, test_cleanup,     "cleanup handling");
     n = ts_suite_run(ts);
     ts_suite_free(ts);
     return n;

CVSTrac 2.0.1