From 4bdf96bb6e5669f54f3b8a551fbdfdac5dd69fe0 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 29 Aug 2014 11:07:16 -0400 Subject: [PATCH] Added tests for asserts --- source/exn/exn.c | 4 ---- tests/test_exn.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) 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); + } } -- 2.54.0