2#include "../../../../tests/catch2/catch.hpp"
6#include "../../../../libMagAOX/libMagAOX.hpp"
8#define XWC_XIGNODE_TEST
9#include "../staticNode.hpp"
13 std::ofstream fout(
"/tmp/xigNode_test.xml" );
14 fout <<
"<mxfile host=\"test\">\n";
15 fout <<
" <diagram id=\"test\" name=\"test\">\n";
16 fout <<
" <mxGraphModel>\n";
18 fout <<
" <mxCell id=\"0\"/>\n";
19 fout <<
" <mxCell id=\"1\" parent=\"0\"/>\n";
20 fout <<
" <mxCell id=\"node:ttmpupil\" />\n";
21 fout <<
" <mxCell id=\"input:ttmpupil:in1\" parent=\"node:ttmpupil\" style=\"fontSize=17;\" />\n";
22 fout <<
" <mxCell id=\"input:ttmpupil:in2\" parent=\"node:ttmpupil\" style=\"fontSize=17;\" />\n";
23 fout <<
" <mxCell id=\"input:ttmpupil:in3\" parent=\"node:ttmpupil\" style=\"fontSize=17;\" />\n";
24 fout <<
" <mxCell id=\"input:ttmpupil:in4\" parent=\"node:ttmpupil\" style=\"fontSize=17;\" />\n";
25 fout <<
" <mxCell id=\"output:ttmpupil:out1\" parent=\"node:ttmpupil\" style=\"fontSize=17;\" />\n";
26 fout <<
" <mxCell id=\"output:ttmpupil:out2\" parent=\"node:ttmpupil\" style=\"fontSize=17;\" />\n";
27 fout <<
" <mxCell id=\"output:ttmpupil:out3\" parent=\"node:ttmpupil\" style=\"fontSize=17;\" />\n";
28 fout <<
" <mxCell id=\"output:ttmpupil:out4\" parent=\"node:ttmpupil\" style=\"fontSize=17;\" />\n";
30 fout <<
" </mxGraphModel>\n";
31 fout <<
" </diagram>\n";
32 fout <<
"</mxfile>\n";
36TEST_CASE(
"Creating and configuring an staticNode",
"[instGraph::staticNode]" )
38 SECTION(
"node is in file, setting pwr key" )
40 ingr::instGraphXML parentGraph;
42 mx::app::writeConfigFile(
"/tmp/staticNode_test.conf",
43 {
"ttmpupil",
"ttmpupil",
"ttmpupil",
"ttmpupil",
"ttmpupil" },
44 {
"type",
"inputsOn",
"inputsOff",
"outputsOn",
"outputsOff" },
45 {
"static",
"in1,in2",
"in3,in4",
"out1,out2",
"out3,out4" } );
46 mx::app::appConfigurator config;
47 config.readConfig(
"/tmp/staticNode_test.conf" );
51 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
54 REQUIRE( emsg ==
"" );
60 tsn =
new staticNode(
"ttmpupil", &parentGraph );
63 catch(
const std::exception &e )
65 std::cerr << e.what() <<
"\n";
68 REQUIRE( pass ==
true );
69 REQUIRE( tsn !=
nullptr );
71 REQUIRE( tsn->
name() ==
"ttmpupil" );
72 REQUIRE( tsn->
node()->name() ==
"ttmpupil" );
80 catch(
const std::exception &e )
82 std::cerr << e.what() <<
"\n";
85 REQUIRE( pass ==
true );
88 REQUIRE( tsn->
inputsOn().size() == 2 );
89 REQUIRE( tsn->
inputsOn().count(
"in1" ) == 1 );
90 REQUIRE( tsn->
inputsOn().count(
"in2" ) == 1 );
92 REQUIRE( tsn->
inputsOff().count(
"in3" ) == 1 );
93 REQUIRE( tsn->
inputsOff().count(
"in4" ) == 1 );
95 REQUIRE( tsn->
outputsOn().count(
"out1" ) == 1 );
96 REQUIRE( tsn->
outputsOn().count(
"out2" ) == 1 );
98 REQUIRE( tsn->
outputsOff().count(
"out3" ) == 1 );
99 REQUIRE( tsn->
outputsOff().count(
"out4" ) == 1 );
An instGraph node which is static, with status set at config time and not changing.
const std::set< std::string > & inputsOff() const
Get the always off inputs.
const std::set< std::string > & inputsOn() const
Get the always on inputs.
const std::set< std::string > & outputsOn() const
Get the always on outputs.
const std::set< std::string > & outputsOff() const
Get the always off outputs.
void loadConfig(mx::app::appConfigurator &config)
Configure this node form an appConfigurator.
ingr::instNode * node()
Get the pointer to the underlying node.
std::string name()
Get the name of this node.
TEST_CASE("Creating and configuring an staticNode", "[instGraph::staticNode]")