FairMQ/test/device/_transitions.cxx
Dennis Klein 4a612ba9a7 feat!: Remove Device::TransitionTo() without replacement
BREAKING CHANGE

However, this API was never advertised nor used by anyone.
2023-02-28 17:06:05 +01:00

46 lines
1.3 KiB
C++

/********************************************************************************
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include <fairmq/Device.h>
#include <fairlogger/Logger.h>
#include <gtest/gtest.h>
#include <vector>
#include <thread>
namespace
{
using namespace std;
using namespace fair::mq;
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