8#define BOOST_TEST_MODULE testHierarchyModifyingGroup
16#include <boost/mpl/list.hpp>
17#include <boost/test/included/unit_test.hpp>
18#include <boost/thread.hpp>
22 using namespace boost::unit_test_framework;
41 using ctk::VariableGroup::VariableGroup;
50 using ctk::ApplicationModule::ApplicationModule;
55 using ctk::VariableGroup::VariableGroup;
57 } extraHierarchy{
this,
"ExtraHierarchy",
"Extra depth"};
68 } testModule{
this,
"mod",
"The test module"};
74 static int myCounter = 42;
77 auto acc = test.getScalar<
int>(name +
"/myVar");
78 test.runApplication();
83 test.stepApplication();
85 BOOST_TEST(
int(group.
myVar) == myCounter);
94 std::cout <<
"*** VariableGroupLike" << std::endl;
96 app.testModule.g = {&app.testModule,
"VariableGroupLike",
"Use like normal VariableGroup"};
97 check(app, app.testModule.g,
"/mod/VariableGroupLike");
103 std::cout <<
"*** MoveToRoot" << std::endl;
105 app.testModule.g = {&app.testModule,
"/MoveToRoot",
"Use like normal VariableGroup with MoveToRoot"};
106 check(app, app.testModule.g,
"/MoveToRoot");
112 std::cout <<
"*** ../oneUp" << std::endl;
114 app.testModule.g = {&app.testModule,
"../oneUp",
"Use like normal VariableGroup with oneUp"};
115 check(app, app.testModule.g,
"/oneUp");
121 std::cout <<
"*** .." << std::endl;
123 app.testModule.g = {&app.testModule,
"..",
"Use like normal VariableGroup with oneUpAndHide"};
124 check(app, app.testModule.g,
"");
130 std::cout <<
"*** local/hierarchy" << std::endl;
132 app.testModule.g = {&app.testModule,
"local/hierarchy",
"Create hierarchy locally"};
133 check(app, app.testModule.g,
"/mod/local/hierarchy");
139 std::cout <<
"*** /AtRoot/hierarchy" << std::endl;
141 app.testModule.g = {&app.testModule,
"/AtRoot/hierarchy",
"Create hierarchy at root"};
142 check(app, app.testModule.g,
"/AtRoot/hierarchy");
148 std::cout <<
"*** ../oneUp/hierarchy" << std::endl;
150 app.testModule.g = {&app.testModule,
"../oneUp/hierarchy",
"Create hierarchy one level up"};
151 check(app, app.testModule.g,
"/oneUp/hierarchy");
157 std::cout <<
"*** local/very/deep/hierarchy" << std::endl;
159 app.testModule.g = {&app.testModule,
"local/very/deep/hierarchy",
"Create deep hierarchy locally"};
160 check(app, app.testModule.g,
"/mod/local/very/deep/hierarchy");
166 std::cout <<
"*** /root/very/deep/hierarchy" << std::endl;
168 app.testModule.g = {&app.testModule,
"/root/very/deep/hierarchy",
"Create deep hierarchy at root"};
169 check(app, app.testModule.g,
"/root/very/deep/hierarchy");
175 std::cout <<
"*** ../oneUp/very/deep/hierarchy" << std::endl;
177 app.testModule.g = {&app.testModule,
"../oneUp/very/deep/hierarchy",
"Create deep hierarchy one level up"};
178 check(app, app.testModule.g,
"/oneUp/very/deep/hierarchy");
184 std::cout <<
"*** //extra//slashes////everywhere///" << std::endl;
186 BOOST_CHECK_THROW((app.testModule.g = {&app.testModule,
"//extra//slashes////everywhere///",
"Extra slashes"}),
187 ChimeraTK::logic_error);
188 BOOST_CHECK_THROW((app.testModule.g = {&app.testModule,
"/extra/slashes/everywhere/",
"Extra slashs at the end"}),
189 ChimeraTK::logic_error);
190 BOOST_CHECK_THROW((app.testModule.g = {&app.testModule,
"/extra/slashes//everywhere",
"Extra slash in the middle"}),
191 ChimeraTK::logic_error);
193 (app.testModule.g = {&app.testModule,
"//extra/slashes/everywhere",
"Extra slash in the beginning"}),
194 ChimeraTK::logic_error);
195 BOOST_CHECK_NO_THROW((app.testModule.g = {&app.testModule,
"/extra/slashes/everywhere",
"No extra slash"}));
201 std::cout <<
"*** twoUp" << std::endl;
203 app.testModule.extraHierarchy.g = {&app.testModule.extraHierarchy,
"../../twoUp",
"Two levels up"};
204 check(app, app.testModule.extraHierarchy.g,
"/twoUp");
210 std::cout <<
"*** hierarchy/with/../dots/../../anywhere/./also/./single/./dots/.." << std::endl;
213 &app.testModule,
"hierarchy/with/../dots/../../anywhere/./also/./single/./dots/..",
"Dots everywhere "};
215 check(app, app.testModule.g,
"/mod/anywhere/also/single");
221 std::cout <<
"*** ." << std::endl;
223 app.testModule.g = {&app.testModule,
".",
"This is like hideThis"};
224 check(app, app.testModule.g,
"/mod");
230 std::cout <<
"*** dot/at/end/." << std::endl;
232 app.testModule.g = {&app.testModule,
"dot/at/end/.",
"Gets effectively ignored..."};
233 check(app, app.testModule.g,
"/mod/dot/at/end");
239 std::cout <<
"*** MoveToRootFromHidden" << std::endl;
241 app.testModule = {&app,
".",
"The test module is hidden now"};
242 app.testModule.g = {&app.testModule,
"/MoveToRootFromHidden",
243 "Use like normal VariableGroup with MoveToRoot, and place inside a hidden to-level module"};
244 check(app, app.testModule.g,
"/MoveToRootFromHidden");
254 using ctk::ApplicationModule::ApplicationModule;
256 } testModule{
this,
"TestModule",
"The test module"};
262 std::cout <<
"*** bad_path_exception" << std::endl;
264 BOOST_CHECK_THROW(
TestGroup tg(&app.testModule,
"/../cannot/work",
"This is not allowed"), ctk::logic_error);
265 BOOST_CHECK_THROW(
TestGroup tg(&app.testModule,
"/..",
"This is not allowed either"), ctk::logic_error);
267 TestGroup tg(&app.testModule,
"/somthing/less/../../../obvious",
"This is also not allowed"), ctk::logic_error);
Model::RootProxy getModel()
Return the root of the application model.
void shutdown() override
This will remove the global pointer to the instance and allows creating another instance afterwards.
std::list< VariableNetworkNode > getAccessorListRecursive() const
Obtain the list of accessors/variables associated with this instance and any submodules.
void writeGraphViz(const std::string &filename, Args... args) const
Implementations of RootProxy.
void readAll(bool includeReturnChannels=false)
Read all readable variables in the group.
Helper class to facilitate tests of applications based on ApplicationCore.
InvalidityTracer application module.
void check(TestApplication &app, TestGroup &group, const std::string &name)
BOOST_AUTO_TEST_CASE(VariableGroupLike)
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
~TestApplicationEmpty() override
~TestApplication() override
This test checks use of relative paths in modules at the example of a VariableGroup.
ctk::ScalarPushInput< int > myVar