mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Test exceptions thrown in user code
This commit is contained in:
committed by
Dennis Klein
parent
bde12f58b2
commit
e39316c866
84
test/helper/devices/TestExceptions.cxx
Normal file
84
test/helper/devices/TestExceptions.cxx
Normal file
@@ -0,0 +1,84 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2018 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 <FairMQDevice.h>
|
||||
#include <FairMQLogger.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace fair
|
||||
{
|
||||
namespace mq
|
||||
{
|
||||
namespace test
|
||||
{
|
||||
|
||||
class TestExceptions : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
auto Init() -> void override
|
||||
{
|
||||
std::string state("Init");
|
||||
if (std::string::npos != GetId().find("_" + state + "_")) {
|
||||
throw std::runtime_error("exception in " + state + "()");
|
||||
}
|
||||
}
|
||||
|
||||
auto InitTask() -> void override
|
||||
{
|
||||
std::string state("InitTask");
|
||||
if (std::string::npos != GetId().find("_" + state + "_")) {
|
||||
throw std::runtime_error("exception in " + state + "()");
|
||||
}
|
||||
}
|
||||
|
||||
auto PreRun() -> void override
|
||||
{
|
||||
std::string state("PreRun");
|
||||
if (std::string::npos != GetId().find("_" + state + "_")) {
|
||||
throw std::runtime_error("exception in " + state + "()");
|
||||
}
|
||||
}
|
||||
|
||||
auto Run() -> void override
|
||||
{
|
||||
std::string state("Run");
|
||||
if (std::string::npos != GetId().find("_" + state + "_")) {
|
||||
throw std::runtime_error("exception in " + state + "()");
|
||||
}
|
||||
}
|
||||
|
||||
auto PostRun() -> void override
|
||||
{
|
||||
std::string state("PostRun");
|
||||
if (std::string::npos != GetId().find("_" + state + "_")) {
|
||||
throw std::runtime_error("exception in " + state + "()");
|
||||
}
|
||||
}
|
||||
|
||||
auto ResetTask() -> void override
|
||||
{
|
||||
std::string state("ResetTask");
|
||||
if (std::string::npos != GetId().find("_" + state + "_")) {
|
||||
throw std::runtime_error("exception in " + state + "()");
|
||||
}
|
||||
}
|
||||
|
||||
auto Reset() -> void override
|
||||
{
|
||||
std::string state("Reset");
|
||||
if (std::string::npos != GetId().find("_" + state + "_")) {
|
||||
throw std::runtime_error("exception in " + state + "()");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace mq
|
||||
} // namespace fair
|
@@ -18,6 +18,7 @@
|
||||
#include "devices/TestSub.cxx"
|
||||
#include "devices/TestTransferTimeout.cxx"
|
||||
#include "devices/TestWaitFor.cxx"
|
||||
#include "devices/TestExceptions.cxx"
|
||||
|
||||
#include <runFairMQDevice.h>
|
||||
|
||||
@@ -87,6 +88,10 @@ auto getDevice(const FairMQProgOptions& config) -> FairMQDevicePtr
|
||||
{
|
||||
return new TestWaitFor;
|
||||
}
|
||||
else if (0 == id.find("exceptions_"))
|
||||
{
|
||||
return new TestExceptions;
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "Don't know id '" << id << "'" << endl;
|
||||
|
Reference in New Issue
Block a user