Skip to content
Snippets Groups Projects
Commit 4d983de6 authored by Martin Killenberg's avatar Martin Killenberg
Browse files

added more tests

parent f0e5a742
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
#include "splitStringAtFirstSlash.h"
namespace ChimeraTK{
//LCOV_EXCL_START
void print_indentation(unsigned int indentation)
{
for(unsigned int i = 0; i < indentation; ++i)
......@@ -98,7 +99,8 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
}
}
}
//LCOV_EXCL_STOP
VariableMapper & VariableMapper::getInstance(){
static VariableMapper instance;
return instance;
......@@ -134,9 +136,15 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0)
if (nameAttribute){
name = nameAttribute->get_value();
}else{
std::cout << "Whoopy, name from source is not implemented yet" << std::endl;
name = "Whoopsy";
if (source[0] == '/'){
name = source.substr(1);
}else{
name = source;
}
// replace / with . in name
name = std::regex_replace(name, std::regex("/"), ".");
}
std::string absoluteSource;
if (source[0] == '/'){
absoluteSource=source;
......
......@@ -91,7 +91,8 @@ BOOST_AUTO_TEST_CASE( testImportLocation ){
}
BOOST_AUTO_TEST_CASE( testImportAll ){
testXmlParsing("variableTreeXml/importAll.xml", { {"/A/a/di", {"A","a.di"}},
std::map< std::string, VariableMapper::PropertyDescription > propertyMap(
{ {"/A/a/di", {"A","a.di"}},
{"/A/a/do", {"A","a.do"}},
{"/A/b", {"A","b"}},
{"/B/a/dr", {"B","a.dr"}},
......@@ -106,6 +107,17 @@ BOOST_AUTO_TEST_CASE( testImportAll ){
{"/DIRECT/INT", {"DIRECT","INT"}},
{"/DIRECT/INT_ARRAY", {"DIRECT","INT_ARRAY"}}
});
testXmlParsing("variableTreeXml/importAll.xml", propertyMap);
// modify the expected property map for the renaming case
propertyMap["/DIRECT/DOUBLE"]= VariableMapper::PropertyDescription("DIRECT","BAR");
propertyMap["/DIRECT/INT"]= VariableMapper::PropertyDescription("DIRECT","FOO");
testXmlParsing("variableTreeXml/globalImportAndRename.xml", propertyMap);
}
BOOST_AUTO_TEST_CASE( testImportTooShort ){
BOOST_CHECK_THROW(testXmlParsing("variableTreeXml/globalImportPartTooShort.xml", {}),
std::logic_error);
}
BOOST_AUTO_TEST_CASE( testGlobalImportPart ){
......@@ -121,3 +133,10 @@ BOOST_AUTO_TEST_CASE( testImportAndRename ){
{"/DIRECT/INT_ARRAY", {"DIRECT","INT_ARRAY"}}
});
}
BOOST_AUTO_TEST_CASE( testCherryPicking ){
testXmlParsing("variableTreeXml/cherryPick.xml", { {"/A/b/do", {"DIRECT","A.b.do"}},
{"/DIRECT/INT", {"DIRECT","INT"}}
});
}
<?xml version="1.0" encoding="UTF-8"?>
<device_server xmlns="https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter">
<location name="DIRECT">
<property source="INT" name="FOO"/>
<property source="/DIRECT/DOUBLE" name="BAR"/>
</location>
<import>/</import>
</device_server>
<?xml version="1.0" encoding="UTF-8"?>
<device_server xmlns="https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter">
<import>/A</import>
</device_server>
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