mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
feat: Improve ChangeState
API
* Add `[[nodiscard]]` to `bool Device::ChangeState()` * Introduce throwing variant `void Device::ChangeStateOrThrow()` resolves #441
This commit is contained in:
committed by
Dennis Klein
parent
5ef17fddbb
commit
435d07eaf9
@@ -97,4 +97,26 @@ TEST(Transitions, ConcurrentTransitionTos)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Transitions, InvalidChangeState)
|
||||
{
|
||||
Device device;
|
||||
thread t([&] { device.RunStateMachine(); });
|
||||
|
||||
ASSERT_FALSE(device.ChangeState(Transition::Connect));
|
||||
|
||||
ASSERT_TRUE(device.ChangeState(Transition::End));
|
||||
if (t.joinable()) { t.join(); }
|
||||
}
|
||||
|
||||
TEST(Transitions, InvalidChangeStateOrThrow)
|
||||
{
|
||||
Device device;
|
||||
thread t([&] { device.RunStateMachine(); });
|
||||
|
||||
ASSERT_THROW(device.ChangeStateOrThrow(Transition::Connect), std::system_error);
|
||||
|
||||
ASSERT_NO_THROW(device.ChangeStateOrThrow(Transition::End));
|
||||
if (t.joinable()) { t.join(); }
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user