]> git.mdlowis.com Git - projs/libcds.git/commitdiff
Added tests for asserts
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 29 Aug 2014 15:07:16 +0000 (11:07 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 29 Aug 2014 15:07:16 +0000 (11:07 -0400)
source/exn/exn.c
tests/test_exn.c

index b081db5a96ff63bce13745230d23d0a6d2f69082..95113dbcc707eb73af8c18d780402f6d6a99fbed 100755 (executable)
@@ -55,13 +55,9 @@ bool exn_process(void) {
 
         case EXN_FINALLY:
             if (!Exn_Handled)
-            {
                 exn_rethrow();
-            }
             else
-            {
                 exn_handler()->state = EXN_DONE;
-            }
             break;
 
         case EXN_DONE:
index 9c705c1383f887e345bc91c3bc315861db1aa786..fba5d48e7b745d9a70689e67cdc6d77c298b52b3 100644 (file)
@@ -89,4 +89,29 @@ TEST_SUITE(Exn) {
         finally { counter++; }
         CHECK(counter == 2);
     }
+
+    //-------------------------------------------------------------------------
+    // Test assertions
+    //-------------------------------------------------------------------------
+    TEST(Verify_successful_assertions_do_not_throw_an_exception)
+    {
+        int counter = 0;
+        try {
+            assert(true);
+            counter++;
+        }
+        catch(AssertionException) { counter--; }
+        CHECK(counter == 1);
+    }
+
+    TEST(Verify_successful_assertions_do_not_throw_an_exception)
+    {
+        int counter = 0;
+        try {
+            assert(false);
+            counter++;
+        }
+        catch(AssertionException) { counter--; }
+        CHECK(counter == -1);
+    }
 }