8#ifndef SEN_LIBS_KERNEL_TEST_INTEGRATION_TRANSPORT_HELPERS_H
9#define SEN_LIBS_KERNEL_TEST_INTEGRATION_TRANSPORT_HELPERS_H
16#include "test_helpers/test_helpers.stl.h"
27#include <spdlog/logger.h>
48[[nodiscard]]
inline bool eq(T a, T b)
53 return eq(a.get(), b.get());
56 if constexpr (std::is_floating_point_v<T>)
58 constexpr T eps = 1e-3;
59 return std::fabs(a - b) < eps;
65template <
typename PropType>
66[[nodiscard]]
inline bool checkProp(std::promise<TestResult>& promise,
67 const std::string& propName,
71 if (!
eq(value, expectation))
74 err.append(
"Incorrect value of ");
76 promise.set_value(TestResult(err));
83[[nodiscard]]
inline bool checkMember(std::promise<TestResult>& promise,
const std::string& memberName,
bool isOk)
90 std::string err =
"Member ";
91 err.append(memberName);
92 err.append(
" adaptation failed.");
93 promise.set_value(TestResult(err));
98[[nodiscard]]
inline bool allObjectsWithState(
const std::list<T*>& objects,
const ConnectionState state)
100 return std::all_of(objects.begin(), objects.end(), [state](
const T* obj) { return obj->getState() == state; });
114 std::shared_ptr<sen::Subscription<StatefulObjectInterface>> objectsSub_;
115 std::vector<sen::ConnectionGuard> guards_;
116 std::shared_ptr<spdlog::logger> logger_;
134 std::shared_ptr<spdlog::logger> logger_;
154 std::shared_ptr<sen::ObjectSource> bus_;
155 std::shared_ptr<sen::Subscription<ListenerInterface>> listenersSub_;
156 std::vector<sen::ConnectionGuard> cbGuards_;
157 std::array<bool, 5U> actionFlags_ = {
false,
false,
false,
false,
false};
178 std::shared_ptr<sen::ObjectSource> bus_;
179 std::shared_ptr<sen::Subscription<PublisherInterface>> publisherSub_;
180 std::vector<sen::ConnectionGuard> cbGuards_;
181 std::array<bool, 5U> checkFlags_ = {
false,
false,
false,
false,
false};
Here we define a set of template meta-programming helpers to let the compiler take some decisions bas...
User-facing kernel functions.
Definition component_api.h:113
API for objects when registered.
Definition component_api.h:206
What can be done while a component is running.
Definition component_api.h:260
void registered(sen::kernel::RegistrationApi &api) override
ListenerImpl(std::string name, const sen::VarMap &args)
void update(sen::kernel::RunApi &runApi) override
void registered(sen::kernel::RegistrationApi &api) override
ProcessTerminatorImpl(std::string name, const sen::VarMap &args)
void update(sen::kernel::RunApi &runApi) override
void registered(sen::kernel::RegistrationApi &api) override
PublisherImpl(std::string name, const sen::VarMap &args)
StateFulObjectImpl(std::string name, const sen::VarMap &args)
void registered(sen::kernel::RegistrationApi &api) override
spdlog::logger * getLogger() const
sen::kernel::KernelApi * getApi() const
std::conditional_t< std::is_arithmetic_v< T >||shouldBePassedByValueV< T >, T, AddConstRef< T > > MaybeRef
returns 'const T&' or 'T' depending on the type
Definition class_helpers.h:46
std::map< std::string, Var, std::less<> > VarMap
A map of vars to represent structures.
Definition var.h:107
Definition reader_writer.h:19
bool eq(T a, T b)
Definition helpers.h:48
bool checkProp(std::promise< TestResult > &promise, const std::string &propName, sen::MaybeRef< PropType > value, sen::MaybeRef< PropType > expectation)
Definition helpers.h:66
bool allObjectsWithState(const std::list< T * > &objects, const ConnectionState state)
Definition helpers.h:98
bool checkMember(std::promise< TestResult > &promise, const std::string &memberName, bool isOk)
Definition helpers.h:83
return false if T has not an 'using ValueType' or a 'typedef ValueType'
Definition class_helpers.h:51