From: Michael D. Lowis Date: Fri, 29 Aug 2014 15:07:16 +0000 (-0400) Subject: Added tests for asserts X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=4bdf96bb6e5669f54f3b8a551fbdfdac5dd69fe0;p=projs%2Flibcds.git Added tests for asserts --- diff --git a/source/exn/exn.c b/source/exn/exn.c index b081db5..95113db 100755 --- a/source/exn/exn.c +++ b/source/exn/exn.c @@ -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: diff --git a/tests/test_exn.c b/tests/test_exn.c index 9c705c1..fba5d48 100644 --- a/tests/test_exn.c +++ b/tests/test_exn.c @@ -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); + } }