MCPcopy Create free account
hub / github.com/alibaba/async_simple / TEST_F

Function TEST_F

async_simple/test/CancellationTest.cpp:37–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 void caseTearDown() override {}
36};
37TEST_F(CancellationTest, testSimpleCancellation) {
38 auto signal = Signal::create();
39 auto slot = std::make_shared<Slot>(signal.get());
40 auto result = std::async([slot] {
41 while (!slot->canceled()) {
42 std::this_thread::yield();
43 }
44 return slot->signal()->state();
45 });
46 EXPECT_EQ(signal->state() != 0, false);
47 EXPECT_EQ(signal->emits(SignalType::Terminate), true);
48 EXPECT_EQ(signal->state() != 0, true);
49 EXPECT_EQ(result.get(), SignalType::Terminate);
50 EXPECT_EQ(slot->canceled(), true);
51 EXPECT_EQ(slot->signal()->state(), SignalType::Terminate);
52 EXPECT_EQ(signal->state(), SignalType::Terminate);
53}
54
55TEST_F(CancellationTest, testCancellationWithNoneType) {
56 std::atomic<bool> flag = false;

Callers

nothing calls this directly

Calls 15

createFunction · 0.85
asyncFunction · 0.85
canceledMethod · 0.80
stateMethod · 0.80
emitsMethod · 0.80
setScopedFilterMethod · 0.80
hasTriggeredMethod · 0.80
getMethod · 0.45
signalMethod · 0.45
emplaceMethod · 0.45
getFilterMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected