Skip to content
Snippets Groups Projects
Commit 66c4a1e5 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

added tests for multiple consumers and some combinations of pull and push mode

parent 9e062761
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,11 @@ class TestModule : public ctk::ApplicationModule {
SCALAR_ACCESSOR(T, consumingPush2, ctk::VariableDirection::consuming, "MV/m", ctk::UpdateMode::push);
SCALAR_ACCESSOR(T, consumingPush3, ctk::VariableDirection::consuming, "MV/m", ctk::UpdateMode::push);
SCALAR_ACCESSOR(T, feedingPoll, ctk::VariableDirection::feeding, "MV/m", ctk::UpdateMode::poll);
SCALAR_ACCESSOR(T, consumingPoll, ctk::VariableDirection::consuming, "MV/m", ctk::UpdateMode::poll);
SCALAR_ACCESSOR(T, consumingPoll2, ctk::VariableDirection::consuming, "MV/m", ctk::UpdateMode::poll);
SCALAR_ACCESSOR(T, consumingPoll3, ctk::VariableDirection::consuming, "MV/m", ctk::UpdateMode::poll);
void mainLoop() {}
};
......@@ -148,3 +153,93 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( testFourScalarPushAccessors, T, test_types ) {
BOOST_CHECK( testModule.consumingPush3 == 120 );
}
/*********************************************************************************************************************/
/* test case for two scalar accessors in poll mode */
BOOST_AUTO_TEST_CASE_TEMPLATE( testTwoScalarPollAccessors, T, test_types ) {
TestApplication app("Test Suite");
TestModule<T> testModule;
testModule.feedingPoll.connectTo(testModule.consumingPoll);
app.makeConnections();
// single theaded test only, since read() does not block in this case
testModule.consumingPoll = 0;
testModule.feedingPoll = 42;
BOOST_CHECK(testModule.consumingPoll == 0);
testModule.feedingPoll.write();
BOOST_CHECK(testModule.consumingPoll == 0);
testModule.consumingPoll.read();
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.consumingPoll.read();
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.consumingPoll.read();
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.feedingPoll = 120;
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.feedingPoll.write();
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.consumingPoll.read();
BOOST_CHECK( testModule.consumingPoll == 120 );
testModule.consumingPoll.read();
BOOST_CHECK( testModule.consumingPoll == 120 );
testModule.consumingPoll.read();
BOOST_CHECK( testModule.consumingPoll == 120 );
}
/*********************************************************************************************************************/
/* test case for two scalar accessors, feeder in push mode and consumer in poll mode */
BOOST_AUTO_TEST_CASE_TEMPLATE( testTwoScalarPushPollAccessors, T, test_types ) {
TestApplication app("Test Suite");
TestModule<T> testModule;
testModule.feedingPush.connectTo(testModule.consumingPoll);
app.makeConnections();
// single theaded test only, since read() does not block in this case
testModule.consumingPoll = 0;
testModule.feedingPush = 42;
BOOST_CHECK(testModule.consumingPoll == 0);
testModule.feedingPush.write();
BOOST_CHECK(testModule.consumingPoll == 0);
testModule.consumingPoll.read();
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.consumingPoll.read();
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.consumingPoll.read();
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.feedingPush = 120;
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.feedingPush.write();
BOOST_CHECK(testModule.consumingPoll == 42);
testModule.consumingPoll.read();
BOOST_CHECK( testModule.consumingPoll == 120 );
testModule.consumingPoll.read();
BOOST_CHECK( testModule.consumingPoll == 120 );
testModule.consumingPoll.read();
BOOST_CHECK( testModule.consumingPoll == 120 );
}
/*********************************************************************************************************************/
/* test case for two scalar accessors, feeder in poll mode and consumer in push mode (without trigger) */
BOOST_AUTO_TEST_CASE_TEMPLATE( testTwoScalarPollPushAccessors, T, test_types ) {
TestApplication app("Test Suite");
TestModule<T> testModule;
testModule.feedingPoll.connectTo(testModule.consumingPush);
try {
app.makeConnections();
BOOST_ERROR("Exception expected.");
}
catch(ctk::ApplicationExceptionWithID<ctk::ApplicationExceptionID::illegalVariableNetwork> &e) {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment