4#define BOOST_TEST_MODULE testFanIn
12#include <boost/test/included/unit_test.hpp>
14using namespace boost::unit_test_framework;
23 using ctk::ApplicationModule::ApplicationModule;
33 using ctk::ApplicationModule::ApplicationModule;
61 using TheReceiverBase::TheReceiverBase;
77 std::cout <<
"***************************************************************" << std::endl;
78 std::cout <<
"==> TestAggregatedValue" << std::endl;
84 auto out = test.getScalar<int32_t>(
"/path/to/fanIn");
86 test.runApplication();
89 BOOST_TEST(out == 1 + 10);
90 BOOST_TEST(!out.readNonBlocking());
91 BOOST_TEST(app.
r.
in == 1 + 10);
94 test.stepApplication();
95 BOOST_TEST(app.
r.
in == 42 + 17);
96 BOOST_TEST(out.readNonBlocking());
97 BOOST_TEST(out == 42 + 17);
98 BOOST_TEST(!out.readNonBlocking());
101 test.stepApplication();
102 BOOST_TEST(app.
r.
in == 43 + 17);
103 BOOST_TEST(out.readNonBlocking());
104 BOOST_TEST(out == 43 + 17);
105 BOOST_TEST(!out.readNonBlocking());
120 using TheReceiverBase::TheReceiverBase;
123 this,
"fanIn", {
"myAdditionalInput",
"/absolute/path/input"},
"",
"", ctk::fanInKeepLastValue};
129 std::cout <<
"***************************************************************" << std::endl;
130 std::cout <<
"==> TestAdditionalInputs" << std::endl;
136 auto out = test.getScalar<int32_t>(
"/path/to/fanIn");
137 auto addIn = test.getScalar<int32_t>(
"/path/to/myAdditionalInput");
138 auto absIn = test.getScalar<int32_t>(
"/absolute/path/input");
141 test.setScalarDefault(
"/path/to/myAdditionalInput", 1);
142 test.setScalarDefault(
"/absolute/path/input", 1);
144 test.runApplication();
147 BOOST_TEST(out == 1);
148 BOOST_TEST(!out.readNonBlocking());
149 BOOST_TEST(app.
r.
in == 1);
152 test.stepApplication();
153 BOOST_TEST(app.
r.
in == 42);
155 addIn.setAndWrite(43);
156 test.stepApplication();
157 BOOST_TEST(app.
r.
in == 43);
159 absIn.setAndWrite(44);
160 test.stepApplication();
161 BOOST_TEST(app.
r.
in == 44);
173 using ctk::ModuleGroup::ModuleGroup;
177 using ctk::ApplicationModule::ApplicationModule;
187 using TheReceiverBase::TheReceiverBase;
192 } mg{
this,
"/some/directory",
""};
196 std::cout <<
"***************************************************************" << std::endl;
197 std::cout <<
"==> TestRelativeSenderNames" << std::endl;
203 auto out = test.getScalar<int32_t>(
"/some/directory/path/to/fanIn");
205 test.runApplication();
208 BOOST_TEST(out == 1);
209 BOOST_TEST(!out.readNonBlocking());
210 BOOST_TEST(app.mg.r.in == 1);
212 app.mg.a.out.setAndWrite(42);
213 test.stepApplication();
214 BOOST_TEST(app.mg.r.in == 42);
226 using TheReceiverBase::TheReceiverBase;
242 std::cout <<
"---> " << msg << std::endl;
247 for(
auto& acc :
in.inputs()) {
248 validator.
add(
"testOnIndividual", [&] {
return acc > -10; }, acc);
269 std::cout <<
"***************************************************************" << std::endl;
270 std::cout <<
"==> TestUserInputValidation" << std::endl;
276 auto out = test.getScalar<int32_t>(
"/path/to/fanIn");
277 auto a = test.getScalar<int32_t>(
"/path/to/a");
278 auto b = test.getScalar<int32_t>(
"/path/to/b");
279 auto err = test.getScalar<std::string>(
"/path/to/err");
281 test.setScalarDefault<int32_t>(
"/path/to/a", 1);
282 test.setScalarDefault<int32_t>(
"/path/to/b", -20);
284 test.runApplication();
287 BOOST_TEST(app.
r.
in == 2);
288 BOOST_TEST(!err.readNonBlocking());
289 BOOST_TEST(out == 2);
290 BOOST_TEST(!out.readNonBlocking());
293 test.stepApplication();
294 BOOST_TEST(app.
r.
in == 2);
295 BOOST_TEST(err.readNonBlocking());
296 BOOST_TEST(std::string(err) ==
"testOnAggregated");
297 BOOST_TEST(out.readNonBlocking());
298 BOOST_TEST(out == 2);
299 BOOST_TEST(!out.readNonBlocking());
302 test.stepApplication();
303 BOOST_TEST(app.
r.
in == 2);
304 BOOST_TEST(err.readNonBlocking());
305 BOOST_TEST(std::string(err) ==
"testOnAggregated");
306 BOOST_TEST(out.readNonBlocking());
307 BOOST_TEST(out == 2);
308 BOOST_TEST(!out.readNonBlocking());
311 test.stepApplication();
312 BOOST_TEST(app.
r.
in == 2);
313 BOOST_TEST(err.readNonBlocking());
314 BOOST_TEST(std::string(err) ==
"testOnIndividual");
315 BOOST_TEST(out.readNonBlocking());
316 BOOST_TEST(out == 2);
317 BOOST_TEST(!out.readNonBlocking());
320 test.stepApplication();
321 BOOST_TEST(app.
r.
in == 2);
322 BOOST_TEST(err.readNonBlocking());
323 BOOST_TEST(std::string(err) ==
"testOnIndividual");
324 BOOST_TEST(out.readNonBlocking());
325 BOOST_TEST(out == 2);
326 BOOST_TEST(!out.readNonBlocking());
329 test.stepApplication();
330 BOOST_TEST(app.
r.
in == 4);
331 BOOST_TEST(!err.readNonBlocking());
332 BOOST_TEST(out.readNonBlocking());
333 BOOST_TEST(out == 4);
334 BOOST_TEST(!out.readNonBlocking());
void shutdown() override
This will remove the global pointer to the instance and allows creating another instance afterwards.
Special accessor allows multiple incoming connections to the same logical process variable.
ChimeraTK::ReadAnyGroup readAnyGroup()
Create a ChimeraTK::ReadAnyGroup for all readable variables in this Module.
void setAndWrite(UserType newValue, VersionNumber versionNumber)=delete
Helper class to facilitate tests of applications based on ApplicationCore.
ctk::ScalarFanIn< int32_t > in
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
~TestAggregatedValueApp() override
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
void prepare() override
Prepare the execution of the module.
ctk::ScalarOutput< int32_t > out
ctk::ScalarFanIn< int32_t > in
~TestRelativeSenderNamesApp() override
TestRelativeSenderNamesApp()
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
ctk::TransferElementID change
void prepare() override
Prepare the execution of the module.
ctk::ScalarOutput< int32_t > out
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
InvalidityTracer application module.
BOOST_AUTO_TEST_CASE(TestAggregatedValue)
Convenience class for output scalar accessors (always UpdateMode::push)