From f2b9158f2813c948617c2c8ef6c0f653c1aa5f10 Mon Sep 17 00:00:00 2001 From: anonymous Date: Mon, 28 Jun 2010 18:12:51 +0000 Subject: Added test for correctly setting unexpected handler and calling it when an eception spec is violated. --- test/test_exception.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test_exception.cc b/test/test_exception.cc index 2a1be80..dde7492 100644 --- a/test/test_exception.cc +++ b/test/test_exception.cc @@ -3,6 +3,8 @@ #include #include +#include + void log(void* ignored) { printf("Cleanup called on %s\n", *(char**)ignored); @@ -78,7 +80,7 @@ static void test_catch(int s) catch(int i) { fprintf(stderr, "Caught int %d!\n", i); - TEST(s == 0 && i == 1, "Caught int"); + TEST((s == 0 && i == 1) || (s == 2 && i == 0), "Caught int"); return; } catch (float f) @@ -133,14 +135,21 @@ void test_nested() TEST(f == 1, "Caught re-thrown float"); } } + +static void throw_zero() +{ + throw 0; +} + void test_exceptions(void) { TEST_CLEANUP(test_catch(0)); TEST_CLEANUP(test_catch(1)); TEST_CLEANUP(test_catch(3)); TEST_CLEANUP(test_catch(4)); - //test_catch(2); TEST_CLEANUP(test_nested()); + std::set_unexpected(throw_zero); + test_catch(2); //printf("Test: %s\n", } -- cgit v1.2.3