MCPcopy Create free account
hub / github.com/boostorg/stacktrace / test_from_other_thread

Function test_from_other_thread

test/test_from_exception.cpp:159–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159BOOST_NOINLINE BOOST_SYMBOL_VISIBLE void test_from_other_thread() {
160
161// MinGW error: 'thread' is not a member of 'std'
162#ifndef __MINGW32__
163 std::exception_ptr ptr;
164
165 std::thread t([&ptr]{
166 try {
167 in_test_throw_1("test_other_exception_active");
168 } catch (const std::exception&) {
169 try {
170 in_test_throw_2("test_other_exception_active 2");
171 } catch (const std::exception&) {
172 ptr = std::current_exception();
173 }
174 }
175 });
176 t.join();
177
178 try {
179 std::rethrow_exception(ptr);
180 } catch (...) {
181 auto trace = stacktrace::from_current_exception();
182 BOOST_TEST(trace);
183 std::cout << "Tarce in test_rethrow_nested(): " << trace << '\n';
184 BOOST_TEST(to_string(trace).find("in_test_throw_1") == std::string::npos);
185#if defined(BOOST_MSVC)
186 BOOST_TEST(to_string(trace).find("in_test_throw_2") == std::string::npos);
187#else
188 BOOST_TEST(to_string(trace).find("in_test_throw_2") != std::string::npos);
189#endif
190 }
191#endif
192}
193
194int main() {
195 const test_no_pending_on_finish guard{};

Callers 1

mainFunction · 0.85

Calls 4

in_test_throw_2Function · 0.85
from_current_exceptionFunction · 0.85
to_stringFunction · 0.85
in_test_throw_1Function · 0.70

Tested by

no test coverage detected