| 30 | } |
| 31 | |
| 32 | Y_UNIT_TEST(TestExceptionSafety) { |
| 33 | TExceptionSafeContext main; |
| 34 | TExceptionSafeContext* volatile nextPtr = nullptr; |
| 35 | |
| 36 | bool hasUncaught = true; |
| 37 | |
| 38 | auto func = [&]() { |
| 39 | hasUncaught = UncaughtException(); |
| 40 | nextPtr->SwitchTo(&main); |
| 41 | }; |
| 42 | |
| 43 | auto closure = Wrap(func); |
| 44 | |
| 45 | TExceptionSafeContext next(closure); |
| 46 | |
| 47 | nextPtr = &next; |
| 48 | |
| 49 | struct THelper { |
| 50 | inline ~THelper() { |
| 51 | M->SwitchTo(N); |
| 52 | } |
| 53 | |
| 54 | TExceptionSafeContext* M; |
| 55 | TExceptionSafeContext* N; |
| 56 | }; |
| 57 | |
| 58 | bool throwed = false; |
| 59 | |
| 60 | try { |
| 61 | THelper helper{&main, &next}; |
| 62 | |
| 63 | throw 1; |
| 64 | } catch (...) { |
| 65 | throwed = true; |
| 66 | } |
| 67 | |
| 68 | UNIT_ASSERT(throwed); |
| 69 | UNIT_ASSERT(!hasUncaught); |
| 70 | } |
| 71 | } // Y_UNIT_TEST_SUITE(TestContext) |
nothing calls this directly
no test coverage detected