Commit 31015044 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2202] Try throwing std::exception too

parent c4e44c1a
...@@ -73,18 +73,28 @@ throwSomething() { ...@@ -73,18 +73,28 @@ throwSomething() {
throw 42; // Throw something really unusual, to see everything is caught. throw 42; // Throw something really unusual, to see everything is caught.
} }
void
throwException() {
throw std::exception();
}
// Exception in the thread we forget about should not do anything to us // Exception in the thread we forget about should not do anything to us
TEST(ThreadTest, detachedException) { TEST(ThreadTest, detachedException) {
for (size_t i = 0; i < detached_iterations; ++i) { for (size_t i = 0; i < detached_iterations; ++i) {
Thread thread(throwSomething); Thread thread(throwSomething);
} }
for (size_t i = 0; i < detached_iterations; ++i) {
Thread thread(throwException);
}
} }
// An uncaught exception in the thread should propagate through wait // An uncaught exception in the thread should propagate through wait
TEST(ThreadTest, exception) { TEST(ThreadTest, exception) {
for (size_t i = 0; i < iterations; ++i) { for (size_t i = 0; i < iterations; ++i) {
Thread thread(throwSomething); Thread thread(throwSomething);
Thread thread2(throwException);
ASSERT_THROW(thread.wait(), Thread::UncaughtException); ASSERT_THROW(thread.wait(), Thread::UncaughtException);
ASSERT_THROW(thread2.wait(), Thread::UncaughtException);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment