Browse Source

Extended basic xml test

- added test for reading direct text without file
loading
Patrick 4 years ago
parent
commit
88c769c511
1 changed files with 12 additions and 0 deletions
  1. 12 0
      test/cases/serialization/xml/XMLTest.cpp

+ 12 - 0
test/cases/serialization/xml/XMLTest.cpp

@@ -12,6 +12,7 @@
 #include "../../../../source/io/File.hpp"
 #include "../../../TestHelper.hpp"
 #include "../../../../source/io/FileReader.hpp"
+#include "../../../../source/boxing/String.hpp"
 
 namespace {
   class XMLTest : public ::testing::Test {
@@ -56,4 +57,15 @@ namespace {
 
     ASSERT_EQ(5, amount);
   }
+
+  TEST_F(XMLTest, readText)
+  {
+    rapidxml::xml_document<> document {};
+    ls_std::String data {R"(<connection id="test">\n</connection>)"}; // needs to have line break?
+    document.parse<0>(data.getByteData().data());
+
+    rapidxml::xml_node<>* connectionNode = document.first_node("connection");
+    ASSERT_TRUE(connectionNode != nullptr);
+    ASSERT_STREQ("test", connectionNode->first_attribute("id")->value());
+  }
 }