API
 
Loading...
Searching...
No Matches
staticNode_test.cpp
Go to the documentation of this file.
1// #define CATCH_CONFIG_MAIN
2#include "../../../../tests/catch2/catch.hpp"
3
4#include <fstream>
5
6#include "../../../../libMagAOX/libMagAOX.hpp"
7
8#define XWC_XIGNODE_TEST
9#include "../staticNode.hpp"
10
12{
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";
17 fout << " <root>\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";
29 fout << " </root>\n";
30 fout << " </mxGraphModel>\n";
31 fout << " </diagram>\n";
32 fout << "</mxfile>\n";
33 fout.close();
34}
35
36TEST_CASE( "Creating and configuring an staticNode", "[instGraph::staticNode]" )
37{
38 SECTION( "node is in file, setting pwr key" )
39 {
40 ingr::instGraphXML parentGraph;
41 writeXML();
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" );
48
49 std::string emsg;
50
51 int rv = parentGraph.loadXMLFile( emsg, "/tmp/xigNode_test.xml" );
52
53 REQUIRE( rv == 0 );
54 REQUIRE( emsg == "" );
55
56 staticNode *tsn = nullptr;
57 bool pass = false;
58 try
59 {
60 tsn = new staticNode( "ttmpupil", &parentGraph );
61 pass = true;
62 }
63 catch( const std::exception &e )
64 {
65 std::cerr << e.what() << "\n";
66 }
67
68 REQUIRE( pass == true );
69 REQUIRE( tsn != nullptr );
70
71 REQUIRE( tsn->name() == "ttmpupil" );
72 REQUIRE( tsn->node()->name() == "ttmpupil" );
73
74 pass = false;
75 try
76 {
77 tsn->loadConfig( config );
78 pass = true;
79 }
80 catch( const std::exception &e )
81 {
82 std::cerr << e.what() << "\n";
83 }
84
85 REQUIRE( pass == true );
86
87 // check config-ed values
88 REQUIRE( tsn->inputsOn().size() == 2 );
89 REQUIRE( tsn->inputsOn().count( "in1" ) == 1 );
90 REQUIRE( tsn->inputsOn().count( "in2" ) == 1 );
91 REQUIRE( tsn->inputsOff().size() == 2 );
92 REQUIRE( tsn->inputsOff().count( "in3" ) == 1 );
93 REQUIRE( tsn->inputsOff().count( "in4" ) == 1 );
94 REQUIRE( tsn->outputsOn().size() == 2 );
95 REQUIRE( tsn->outputsOn().count( "out1" ) == 1 );
96 REQUIRE( tsn->outputsOn().count( "out2" ) == 1 );
97 REQUIRE( tsn->outputsOff().size() == 2 );
98 REQUIRE( tsn->outputsOff().count( "out3" ) == 1 );
99 REQUIRE( tsn->outputsOff().count( "out4" ) == 1 );
100 }
101}
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.
Definition xigNode.hpp:121
std::string name()
Get the name of this node.
Definition xigNode.hpp:106
TEST_CASE("Creating and configuring an staticNode", "[instGraph::staticNode]")
void writeXML()