diff --git a/.vscode/settings.json b/.vscode/settings.json
index 74f6069cf585e8f43536c679b946b5944dcfdaa1..7614e593ad69951ced71b52ebd2b2e7eb45fc6fc 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -44,6 +44,7 @@
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
- "xutility": "cpp"
+ "xutility": "cpp",
+ "format": "cpp"
}
}
\ No newline at end of file
diff --git a/data/simple.xml b/data/simple.xml
index 346f499d4fa7690ea75a91cb972f234a7a9d424f..2310a0e3cd451a2ed47662319a454c12e49ec74d 100644
--- a/data/simple.xml
+++ b/data/simple.xml
@@ -1,4 +1,12 @@
-
+
+ 这是一段介绍. 这是一段介绍.
+
+
+ 这是一段介绍. 这是一段介绍.
+
+
+ 这是一段介绍. 这是一段介绍.
+
\ No newline at end of file
diff --git a/test/test_tinyxml2_find_node.cpp b/test/test_tinyxml2_find_node.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..990740d76c99e26c2f5d9e3fda573baf06cb2e76
--- /dev/null
+++ b/test/test_tinyxml2_find_node.cpp
@@ -0,0 +1,42 @@
+#include
+#include
+
+#include "doctest/doctest.h"
+#include "tinyxml2.h"
+#include "spdlog/spdlog.h"
+#include "khl_xml_config/khl_xml_config.hpp"
+
+TEST_CASE("tinyxml2_find_node")
+{
+ std::string simpleXmlPath;
+
+ tinyxml2::XMLDocument doc;
+ tinyxml2::XMLError xmlError;
+
+ /**
+ * 查找节点
+ */
+ SUBCASE("find_node")
+ {
+ simpleXmlPath = getXmlPath("/data/simple.xml");
+ xmlError = doc.LoadFile(simpleXmlPath.c_str());
+ CHECK(tinyxml2::XMLError::XML_SUCCESS == xmlError);
+
+ const char* id = "1002";
+
+ auto rootEl = doc.RootElement();
+ auto personNode = rootEl->FirstChildElement("person");
+ while( nullptr != personNode )
+ {
+ if( strcmp(id,personNode->Attribute("id")))
+ {
+ break;
+ }
+
+ personNode = personNode->NextSiblingElement();
+ }
+
+ bool find = nullptr != personNode;
+ CHECK(find);
+ }
+}
\ No newline at end of file
diff --git a/test/test_tinyxml2_load.cpp b/test/test_tinyxml2_load.cpp
index 2ef2d98504a07a153a1642c8b8552c7e2bc547d7..e822a1ef5db488f7025905913695ceb90b7d86b6 100644
--- a/test/test_tinyxml2_load.cpp
+++ b/test/test_tinyxml2_load.cpp
@@ -1,9 +1,8 @@
-#include "doctest/doctest.h"
+#include
+#include "doctest/doctest.h"
#include "tinyxml2.h"
-
#include "spdlog/spdlog.h"
-
#include "khl_xml_config/khl_xml_config.hpp"
TEST_CASE("tinyxml2_load")
@@ -32,4 +31,41 @@ TEST_CASE("tinyxml2_load")
xmlError = doc.LoadFile(simpleXmlPath.c_str());
CHECK(tinyxml2::XMLError::XML_ERROR_FILE_NOT_FOUND == xmlError);
}
+
+ /**
+ * 使用 FILE * 加载
+ */
+ SUBCASE("load_by_file")
+ {
+ simpleXmlPath = getXmlPath("/data/simple.xml");
+ FILE *file = fopen(simpleXmlPath.c_str(), "rb");
+ bool openSuccess = NULL != file;
+ CHECK(openSuccess);
+
+ xmlError = doc.LoadFile(simpleXmlPath.c_str());
+ CHECK(tinyxml2::XMLError::XML_SUCCESS == xmlError);
+
+ bool closeSuccess = 0 == fclose(file);
+ CHECK(closeSuccess);
+ }
+
+ /**
+ * 从字符串加载
+ */
+ SUBCASE("load_by_charbuffe")
+ {
+ static const char *xml = "";
+ xmlError = doc.Parse(xml);
+ CHECK(tinyxml2::XMLError::XML_SUCCESS == xmlError);
+ }
+
+ /**
+ * 从字符串加载
+ */
+ SUBCASE("load_by_charbuffe")
+ {
+ static const char *xml = "";
+ xmlError = doc.Parse(xml);
+ CHECK(tinyxml2::XMLError::XML_ERROR_EMPTY_DOCUMENT == xmlError);
+ }
}
\ No newline at end of file
diff --git a/test/tmp_test.cpp b/test/tmp_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d2e2f89bb512835d9c570dee82554a86e1ffb33c
--- /dev/null
+++ b/test/tmp_test.cpp
@@ -0,0 +1,18 @@
+#include
+#include
+#include
+
+#include "doctest/doctest.h"
+
+#include "spdlog/spdlog.h"
+
+#include "khl_xml_config/khl_xml_config.hpp"
+
+TEST_CASE("test_tmp")
+{
+ spdlog::info("test tmp");
+
+ char* a = "one";
+ char* b = "one";
+ CHECK(0 == strcmp(a,b));
+}
\ No newline at end of file