summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoranonymous <local@localhost>2010-06-28 18:12:51 +0000
committeranonymous <local@localhost>2010-06-28 18:12:51 +0000
commitf2b9158f2813c948617c2c8ef6c0f653c1aa5f10 (patch)
treeb42e811acb1fd89e90ea5ddc9475b99f2fc39add /test
parent81adee0f2476af72ce3923874f35dceff9fedf9a (diff)
downloadlibcxxrt-f2b9158f2813c948617c2c8ef6c0f653c1aa5f10.tar.gz
libcxxrt-f2b9158f2813c948617c2c8ef6c0f653c1aa5f10.tar.bz2
libcxxrt-f2b9158f2813c948617c2c8ef6c0f653c1aa5f10.tar.xz
Added test for correctly setting unexpected handler and calling it when
an eception spec is violated.
Diffstat (limited to 'test')
-rw-r--r--test/test_exception.cc13
1 files changed, 11 insertions, 2 deletions
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 <stdlib.h>
#include <stdint.h>
+#include <exception>
+
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",
}