summaryrefslogtreecommitdiffhomepage
path: root/tests/test-webserver.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-05-16 13:28:52 +0200
committerRoland Reichwein <mail@reichwein.it>2020-05-16 13:28:52 +0200
commit6b2a9dabbfad4d64268967a32dff0f1dc55763de (patch)
treeb3a1f68d8b44090b98ac3bdcf1c8423ebc08c846 /tests/test-webserver.cpp
parent83b25165218281c2a2e98b5e72a0375a7e6a71ca (diff)
Makefile cleanup, included missing files
Diffstat (limited to 'tests/test-webserver.cpp')
-rw-r--r--tests/test-webserver.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test-webserver.cpp b/tests/test-webserver.cpp
new file mode 100644
index 0000000..f7020af
--- /dev/null
+++ b/tests/test-webserver.cpp
@@ -0,0 +1,44 @@
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/xml_parser.hpp>
+
+#include <sstream>
+#include <string>
+
+using namespace std::string_literals;
+namespace pt = boost::property_tree;
+
+TEST(property_tree, put)
+{
+ pt::ptree p;
+ pt::ptree list;
+
+ pt::ptree entry;
+
+ entry.put_value("name1.txt");
+ entry.put("<xmlattr>.type", "file1");
+
+ list.push_back(pt::ptree::value_type("listentry", entry));
+
+ entry.put_value("name2.txt");
+ entry.put("<xmlattr>.type", "file2");
+
+ list.push_back(pt::ptree::value_type("listentry", entry));
+
+ p.push_back(pt::ptree::value_type("list", list));
+
+ std::stringstream ss;
+
+ pt::xml_parser::write_xml(ss, p /*, pt::xml_parser::xml_writer_make_settings<std::string>(' ', 1)*/);
+
+ EXPECT_EQ(ss.str(), "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<list><listentry type=\"file1\">name1.txt</listentry><listentry type=\"file2\">name2.txt</listentry></list>");
+}
+
+
+int main(int argc, char* argv[]) {
+ ::testing::InitGoogleMock(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+