MCPcopy Create free account
hub / github.com/catboost/catboost / Y_UNIT_TEST

Function Y_UNIT_TEST

util/system/context_ut.cpp:32–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 3

UncaughtExceptionFunction · 0.85
WrapFunction · 0.70
SwitchToMethod · 0.45

Tested by

no test coverage detected