Przeglądaj źródła

Extended XMLReader class

- parsing of values does work now
- extended tests for XMLReader class (more detailed)
patrick 4 lat temu
rodzic
commit
9c9cc0da31

+ 2 - 1
source/io/xml/XMLParseMode.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-10-13
  * Created:         2020-10-13
- * Changed:         2020-10-13
+ * Changed:         2020-10-22
  *
  *
  * */
  * */
 
 
@@ -15,6 +15,7 @@ namespace ls_std {
     XML_PARSE_MODE_ANALYZE = 0,
     XML_PARSE_MODE_ANALYZE = 0,
     XML_PARSE_MODE_DECLARATION,
     XML_PARSE_MODE_DECLARATION,
     XML_PARSE_MODE_OPENING_TAG,
     XML_PARSE_MODE_OPENING_TAG,
+    XML_PARSE_MODE_VALUE,
     XML_PARSE_MODE_CLOSING_TAG
     XML_PARSE_MODE_CLOSING_TAG
   };
   };
 }
 }

+ 34 - 3
source/io/xml/XMLReader.cpp

@@ -58,6 +58,7 @@ void ls_std::XMLReader::_analyze(const ls_std::byte_field &_data, std::string::s
   this->_isDeclaration(_data, _index);
   this->_isDeclaration(_data, _index);
   this->_isClosingTag(_data, _index);
   this->_isClosingTag(_data, _index);
   this->_isOpeningTag(_data, _index);
   this->_isOpeningTag(_data, _index);
+  this->_isValue(_data, _index);
 }
 }
 
 
 void ls_std::XMLReader::_checkDocumentExistence(const std::shared_ptr<ls_std::XMLDocument>& _document)
 void ls_std::XMLReader::_checkDocumentExistence(const std::shared_ptr<ls_std::XMLDocument>& _document)
@@ -179,6 +180,22 @@ void ls_std::XMLReader::_isOpeningTag(const ls_std::byte_field &_data, std::stri
   }
   }
 }
 }
 
 
+void ls_std::XMLReader::_isValue(const ls_std::byte_field &_data, std::string::size_type _index)
+{
+  if(this->mode == XML_PARSE_MODE_ANALYZE) {
+    std::string::size_type end = _data.substr(_index).find('<');
+    bool isValue = _data[_index - 1] == '>' && end != std::string::npos && end > 0;
+
+    if(isValue) {
+      ls_std::String value {_data.substr(_index, end)};
+
+      if(!value.contains("\n") && !value.contains("\r\n") ) {
+        this->mode = XML_PARSE_MODE_VALUE;
+      }
+    }
+  }
+}
+
 void ls_std::XMLReader::_mergeNodes()
 void ls_std::XMLReader::_mergeNodes()
 {
 {
   while(this->maxLevel > 1) {
   while(this->maxLevel > 1) {
@@ -240,6 +257,12 @@ void ls_std::XMLReader::_parse(const ls_std::byte_field &_data)
         index = ls_std::XMLReader::_parseOpeningTag(_data, index);
         index = ls_std::XMLReader::_parseOpeningTag(_data, index);
         this->mode = XML_PARSE_MODE_ANALYZE;
         this->mode = XML_PARSE_MODE_ANALYZE;
       } break;
       } break;
+      case XML_PARSE_MODE_VALUE:
+      {
+        --index;
+        index = ls_std::XMLReader::_parseValue(_data, index);
+        this->mode = XML_PARSE_MODE_ANALYZE;
+      } break;
       case XML_PARSE_MODE_CLOSING_TAG:
       case XML_PARSE_MODE_CLOSING_TAG:
       {
       {
         --index;
         --index;
@@ -288,7 +311,7 @@ size_t ls_std::XMLReader::_parseClosingTag(const ls_std::byte_field &_data, std:
 {
 {
   std::string tagString = ls_std::XMLReader::_getNextTagString(_data, _index);
   std::string tagString = ls_std::XMLReader::_getNextTagString(_data, _index);
   this->currentLevel -= 1;
   this->currentLevel -= 1;
-  return tagString.empty() ? _index : _index + tagString.size();
+  return tagString.empty() ? _index : _index + (tagString.size() - 1);
 }
 }
 
 
 size_t ls_std::XMLReader::_parseDeclaration(const ls_std::byte_field &_data, std::string::size_type _index)
 size_t ls_std::XMLReader::_parseDeclaration(const ls_std::byte_field &_data, std::string::size_type _index)
@@ -301,7 +324,7 @@ size_t ls_std::XMLReader::_parseDeclaration(const ls_std::byte_field &_data, std
     this->document->setDeclaration(declaration);
     this->document->setDeclaration(declaration);
   }
   }
 
 
-  return !isValidTagString ? _index : _index + tagString.size();
+  return !isValidTagString ? _index : _index + (tagString.size() - 1);
 }
 }
 
 
 size_t ls_std::XMLReader::_parseOpeningTag(const ls_std::byte_field &_data, std::string::size_type _index)
 size_t ls_std::XMLReader::_parseOpeningTag(const ls_std::byte_field &_data, std::string::size_type _index)
@@ -323,7 +346,7 @@ size_t ls_std::XMLReader::_parseOpeningTag(const ls_std::byte_field &_data, std:
     }
     }
   }
   }
 
 
-  return !isValidTagString ? _index : _index + tagString.toString().size();
+  return !isValidTagString ? _index : _index + (tagString.toString().size() - 1);
 }
 }
 
 
 ls_std::byte_field ls_std::XMLReader::_parseTagName(const ls_std::byte_field &_data)
 ls_std::byte_field ls_std::XMLReader::_parseTagName(const ls_std::byte_field &_data)
@@ -337,6 +360,14 @@ ls_std::byte_field ls_std::XMLReader::_parseTagName(const ls_std::byte_field &_d
   return _data.substr(1, position - 1);
   return _data.substr(1, position - 1);
 }
 }
 
 
+size_t ls_std::XMLReader::_parseValue(const ls_std::byte_field &_data, std::string::size_type _index)
+{
+  ls_std::byte_field value = _data.substr(_index, _data.substr(_index).find('<'));
+  this->parseData.back().node->setValue(value);
+
+  return _index + (value.size() - 1);
+}
+
 void ls_std::XMLReader::_reset()
 void ls_std::XMLReader::_reset()
 {
 {
   this->currentLevel = 1;
   this->currentLevel = 1;

+ 2 - 0
source/io/xml/XMLReader.hpp

@@ -59,6 +59,7 @@ namespace ls_std {
       void _isClosingTag(const ls_std::byte_field& _data, std::string::size_type _index);
       void _isClosingTag(const ls_std::byte_field& _data, std::string::size_type _index);
       void _isDeclaration(const ls_std::byte_field& _data, std::string::size_type _index);
       void _isDeclaration(const ls_std::byte_field& _data, std::string::size_type _index);
       void _isOpeningTag(const ls_std::byte_field& _data, std::string::size_type _index);
       void _isOpeningTag(const ls_std::byte_field& _data, std::string::size_type _index);
+      void _isValue(const ls_std::byte_field& _data, std::string::size_type _index);
       void _mergeNodes();
       void _mergeNodes();
       void _mergeChildrenToParentNode(const std::shared_ptr<ls_std::XMLNode>& _parent, std::list<ls_std::XMLParseData>::iterator& _iterator, uint8_t _parentLevel);
       void _mergeChildrenToParentNode(const std::shared_ptr<ls_std::XMLNode>& _parent, std::list<ls_std::XMLParseData>::iterator& _iterator, uint8_t _parentLevel);
       void _mergeNodesOnCurrentLevel();
       void _mergeNodesOnCurrentLevel();
@@ -69,6 +70,7 @@ namespace ls_std {
       size_t _parseDeclaration(const ls_std::byte_field& _data, std::string::size_type _index);
       size_t _parseDeclaration(const ls_std::byte_field& _data, std::string::size_type _index);
       size_t _parseOpeningTag(const ls_std::byte_field& _data, std::string::size_type _index);
       size_t _parseOpeningTag(const ls_std::byte_field& _data, std::string::size_type _index);
       static ls_std::byte_field _parseTagName(const ls_std::byte_field& _data);
       static ls_std::byte_field _parseTagName(const ls_std::byte_field& _data);
+      size_t _parseValue(const ls_std::byte_field& _data, std::string::size_type _index);
       void _reset();
       void _reset();
       void _setMaxLevel();
       void _setMaxLevel();
   };
   };

+ 103 - 3
test/cases/io/xml/XMLReaderTest.cpp

@@ -27,7 +27,7 @@ namespace {
   {
   {
     std::string xmlPath = TestHelper::getResourcesFolderLocation() + "state_machine_test.xml";
     std::string xmlPath = TestHelper::getResourcesFolderLocation() + "state_machine_test.xml";
     ls_std::XMLReader xmlReader {std::make_shared<ls_std::XMLDocument>(), xmlPath};
     ls_std::XMLReader xmlReader {std::make_shared<ls_std::XMLDocument>(), xmlPath};
-    std::list<std::shared_ptr<ls_std::XMLNode>> children, statesChildren, memoryChildren {};
+    std::list<std::shared_ptr<ls_std::XMLNode>> children, statesChildren, memoryChildren, connectionChildren {};
     std::list<std::shared_ptr<ls_std::XMLAttribute>> attributes {};
     std::list<std::shared_ptr<ls_std::XMLAttribute>> attributes {};
 
 
     ASSERT_TRUE(!xmlReader.read().empty());
     ASSERT_TRUE(!xmlReader.read().empty());
@@ -43,15 +43,19 @@ namespace {
     std::shared_ptr<ls_std::XMLNode> root = xmlReader.getDocument()->getRootElement();
     std::shared_ptr<ls_std::XMLNode> root = xmlReader.getDocument()->getRootElement();
     ASSERT_STREQ("stateMachine", root->getName().c_str());
     ASSERT_STREQ("stateMachine", root->getName().c_str());
     ASSERT_STREQ("name", root->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("name", root->getAttributes().front()->getName().c_str());
+    ASSERT_EQ(1, root->getAttributes().size());
     ASSERT_STREQ("test_machine", root->getAttributes().front()->getValue().c_str());
     ASSERT_STREQ("test_machine", root->getAttributes().front()->getValue().c_str());
 
 
-    // check 2. level
+    // root children
 
 
     children = root->getChildren();
     children = root->getChildren();
     ASSERT_EQ(3, children.size());
     ASSERT_EQ(3, children.size());
     ASSERT_STREQ("states", ls_std::STLUtils::getListElementAt(children, 0)->getName().c_str());
     ASSERT_STREQ("states", ls_std::STLUtils::getListElementAt(children, 0)->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(children, 0)->getAttributes().empty());
     ASSERT_STREQ("currentState", ls_std::STLUtils::getListElementAt(children, 1)->getName().c_str());
     ASSERT_STREQ("currentState", ls_std::STLUtils::getListElementAt(children, 1)->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(children, 1)->getAttributes().empty());
     ASSERT_STREQ("memory", ls_std::STLUtils::getListElementAt(children, 2)->getName().c_str());
     ASSERT_STREQ("memory", ls_std::STLUtils::getListElementAt(children, 2)->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(children, 2)->getAttributes().empty());
 
 
     // states
     // states
 
 
@@ -59,26 +63,111 @@ namespace {
     ASSERT_EQ(5, statesChildren.size());
     ASSERT_EQ(5, statesChildren.size());
 
 
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 0)->getName().c_str());
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 0)->getName().c_str());
+    ASSERT_EQ(1, ls_std::STLUtils::getListElementAt(statesChildren, 0)->getAttributes().size());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 0)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 0)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("A", ls_std::STLUtils::getListElementAt(statesChildren, 0)->getAttributes().front()->getValue().c_str());
     ASSERT_STREQ("A", ls_std::STLUtils::getListElementAt(statesChildren, 0)->getAttributes().front()->getValue().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 0)->getValue().empty());
+    ASSERT_EQ(1, ls_std::STLUtils::getListElementAt(statesChildren, 0)->getChildren().size());
+    ASSERT_STREQ("connections", ls_std::STLUtils::getListElementAt(statesChildren, 0)->getChildren().front()->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 0)->getChildren().front()->getValue().empty());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 0)->getChildren().front()->getAttributes().empty());
+    connectionChildren = ls_std::STLUtils::getListElementAt(statesChildren, 0)->getChildren().front()->getChildren();
+    ASSERT_EQ(1, connectionChildren.size());
+    ASSERT_STREQ("connection", ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getValue().empty());
+    attributes = ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getAttributes();
+    ASSERT_EQ(3, attributes.size());
+    ASSERT_STREQ("connectionId", ls_std::STLUtils::getListElementAt(attributes, 0)->getName().c_str());
+    ASSERT_STREQ("AB", ls_std::STLUtils::getListElementAt(attributes, 0)->getValue().c_str());
+    ASSERT_STREQ("condition", ls_std::STLUtils::getListElementAt(attributes, 1)->getName().c_str());
+    ASSERT_STREQ("false", ls_std::STLUtils::getListElementAt(attributes, 1)->getValue().c_str());
+    ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(attributes, 2)->getName().c_str());
+    ASSERT_STREQ("B", ls_std::STLUtils::getListElementAt(attributes, 2)->getValue().c_str());
 
 
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 1)->getName().c_str());
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 1)->getName().c_str());
+    ASSERT_EQ(1, ls_std::STLUtils::getListElementAt(statesChildren, 1)->getAttributes().size());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 1)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 1)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("B", ls_std::STLUtils::getListElementAt(statesChildren, 1)->getAttributes().front()->getValue().c_str());
     ASSERT_STREQ("B", ls_std::STLUtils::getListElementAt(statesChildren, 1)->getAttributes().front()->getValue().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 1)->getValue().empty());
+    ASSERT_EQ(1, ls_std::STLUtils::getListElementAt(statesChildren, 1)->getChildren().size());
+    ASSERT_STREQ("connections", ls_std::STLUtils::getListElementAt(statesChildren, 1)->getChildren().front()->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 1)->getChildren().front()->getValue().empty());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 1)->getChildren().front()->getAttributes().empty());
+    connectionChildren = ls_std::STLUtils::getListElementAt(statesChildren, 1)->getChildren().front()->getChildren();
+    ASSERT_EQ(2, connectionChildren.size());
+    ASSERT_STREQ("connection", ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getValue().empty());
+    attributes = ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getAttributes();
+    ASSERT_EQ(3, attributes.size());
+    ASSERT_STREQ("connectionId", ls_std::STLUtils::getListElementAt(attributes, 0)->getName().c_str());
+    ASSERT_STREQ("BC", ls_std::STLUtils::getListElementAt(attributes, 0)->getValue().c_str());
+    ASSERT_STREQ("condition", ls_std::STLUtils::getListElementAt(attributes, 1)->getName().c_str());
+    ASSERT_STREQ("false", ls_std::STLUtils::getListElementAt(attributes, 1)->getValue().c_str());
+    ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(attributes, 2)->getName().c_str());
+    ASSERT_STREQ("C", ls_std::STLUtils::getListElementAt(attributes, 2)->getValue().c_str());
+    ASSERT_STREQ("connection", ls_std::STLUtils::getListElementAt(connectionChildren, 1)->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(connectionChildren, 1)->getValue().empty());
+    attributes = ls_std::STLUtils::getListElementAt(connectionChildren, 1)->getAttributes();
+    ASSERT_EQ(3, attributes.size());
+    ASSERT_STREQ("connectionId", ls_std::STLUtils::getListElementAt(attributes, 0)->getName().c_str());
+    ASSERT_STREQ("BD", ls_std::STLUtils::getListElementAt(attributes, 0)->getValue().c_str());
+    ASSERT_STREQ("condition", ls_std::STLUtils::getListElementAt(attributes, 1)->getName().c_str());
+    ASSERT_STREQ("false", ls_std::STLUtils::getListElementAt(attributes, 1)->getValue().c_str());
+    ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(attributes, 2)->getName().c_str());
+    ASSERT_STREQ("D", ls_std::STLUtils::getListElementAt(attributes, 2)->getValue().c_str());
 
 
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 2)->getName().c_str());
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 2)->getName().c_str());
+    ASSERT_EQ(1, ls_std::STLUtils::getListElementAt(statesChildren, 2)->getAttributes().size());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 2)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 2)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("C", ls_std::STLUtils::getListElementAt(statesChildren, 2)->getAttributes().front()->getValue().c_str());
     ASSERT_STREQ("C", ls_std::STLUtils::getListElementAt(statesChildren, 2)->getAttributes().front()->getValue().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 2)->getValue().empty());
+    ASSERT_EQ(1, ls_std::STLUtils::getListElementAt(statesChildren, 2)->getChildren().size());
+    ASSERT_STREQ("connections", ls_std::STLUtils::getListElementAt(statesChildren, 2)->getChildren().front()->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 2)->getChildren().front()->getValue().empty());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 2)->getChildren().front()->getAttributes().empty());
+    connectionChildren = ls_std::STLUtils::getListElementAt(statesChildren, 2)->getChildren().front()->getChildren();
+    ASSERT_EQ(1, connectionChildren.size());
+    ASSERT_STREQ("connection", ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getValue().empty());
+    attributes = ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getAttributes();
+    ASSERT_EQ(3, attributes.size());
+    ASSERT_STREQ("connectionId", ls_std::STLUtils::getListElementAt(attributes, 0)->getName().c_str());
+    ASSERT_STREQ("CE", ls_std::STLUtils::getListElementAt(attributes, 0)->getValue().c_str());
+    ASSERT_STREQ("condition", ls_std::STLUtils::getListElementAt(attributes, 1)->getName().c_str());
+    ASSERT_STREQ("false", ls_std::STLUtils::getListElementAt(attributes, 1)->getValue().c_str());
+    ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(attributes, 2)->getName().c_str());
+    ASSERT_STREQ("E", ls_std::STLUtils::getListElementAt(attributes, 2)->getValue().c_str());
 
 
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 3)->getName().c_str());
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 3)->getName().c_str());
+    ASSERT_EQ(1, ls_std::STLUtils::getListElementAt(statesChildren, 3)->getAttributes().size());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 3)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 3)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("D", ls_std::STLUtils::getListElementAt(statesChildren, 3)->getAttributes().front()->getValue().c_str());
     ASSERT_STREQ("D", ls_std::STLUtils::getListElementAt(statesChildren, 3)->getAttributes().front()->getValue().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 3)->getChildren().front()->getAttributes().empty());
+    connectionChildren = ls_std::STLUtils::getListElementAt(statesChildren, 3)->getChildren().front()->getChildren();
+    ASSERT_EQ(1, connectionChildren.size());
+    ASSERT_STREQ("connection", ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getName().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getValue().empty());
+    attributes = ls_std::STLUtils::getListElementAt(connectionChildren, 0)->getAttributes();
+    ASSERT_EQ(3, attributes.size());
+    ASSERT_STREQ("connectionId", ls_std::STLUtils::getListElementAt(attributes, 0)->getName().c_str());
+    ASSERT_STREQ("DE", ls_std::STLUtils::getListElementAt(attributes, 0)->getValue().c_str());
+    ASSERT_STREQ("condition", ls_std::STLUtils::getListElementAt(attributes, 1)->getName().c_str());
+    ASSERT_STREQ("false", ls_std::STLUtils::getListElementAt(attributes, 1)->getValue().c_str());
+    ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(attributes, 2)->getName().c_str());
+    ASSERT_STREQ("E", ls_std::STLUtils::getListElementAt(attributes, 2)->getValue().c_str());
 
 
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 4)->getName().c_str());
     ASSERT_STREQ("state", ls_std::STLUtils::getListElementAt(statesChildren, 4)->getName().c_str());
+    ASSERT_EQ(1, ls_std::STLUtils::getListElementAt(statesChildren, 4)->getAttributes().size());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 4)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("id", ls_std::STLUtils::getListElementAt(statesChildren, 4)->getAttributes().front()->getName().c_str());
     ASSERT_STREQ("E", ls_std::STLUtils::getListElementAt(statesChildren, 4)->getAttributes().front()->getValue().c_str());
     ASSERT_STREQ("E", ls_std::STLUtils::getListElementAt(statesChildren, 4)->getAttributes().front()->getValue().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(statesChildren, 4)->getChildren().empty());
 
 
-    //TODO: current state
+    // current state
+
+    ASSERT_STREQ("currentState", ls_std::STLUtils::getListElementAt(children, 1)->getName().c_str());
+    ASSERT_STREQ("A", ls_std::STLUtils::getListElementAt(children, 1)->getValue().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(children, 1)->getChildren().empty());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(children, 1)->getAttributes().empty());
 
 
     // memory
     // memory
 
 
@@ -86,8 +175,19 @@ namespace {
     ASSERT_EQ(3, memoryChildren.size());
     ASSERT_EQ(3, memoryChildren.size());
 
 
     ASSERT_STREQ("location", ls_std::STLUtils::getListElementAt(memoryChildren, 0)->getName().c_str());
     ASSERT_STREQ("location", ls_std::STLUtils::getListElementAt(memoryChildren, 0)->getName().c_str());
+    ASSERT_STREQ("A", ls_std::STLUtils::getListElementAt(memoryChildren, 0)->getValue().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(memoryChildren, 0)->getChildren().empty());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(memoryChildren, 0)->getAttributes().empty());
+
     ASSERT_STREQ("location", ls_std::STLUtils::getListElementAt(memoryChildren, 1)->getName().c_str());
     ASSERT_STREQ("location", ls_std::STLUtils::getListElementAt(memoryChildren, 1)->getName().c_str());
+    ASSERT_STREQ("B", ls_std::STLUtils::getListElementAt(memoryChildren, 1)->getValue().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(memoryChildren, 1)->getChildren().empty());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(memoryChildren, 1)->getAttributes().empty());
+
     ASSERT_STREQ("location", ls_std::STLUtils::getListElementAt(memoryChildren, 2)->getName().c_str());
     ASSERT_STREQ("location", ls_std::STLUtils::getListElementAt(memoryChildren, 2)->getName().c_str());
+    ASSERT_STREQ("C", ls_std::STLUtils::getListElementAt(memoryChildren, 2)->getValue().c_str());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(memoryChildren, 2)->getChildren().empty());
+    ASSERT_TRUE(ls_std::STLUtils::getListElementAt(memoryChildren, 2)->getAttributes().empty());
   }
   }
 
 
   TEST_F(XMLReaderTest, getDocument)
   TEST_F(XMLReaderTest, getDocument)