summaryrefslogtreecommitdiffhomepage
path: root/tests/test-webserver.cpp
blob: 7683b932bfdf13bdf77225508c8f8f67966d4bd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#define BOOST_TEST_MODULE webserver_test

#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/dataset.hpp>
#include <boost/test/data/monomorphic.hpp>
#include <boost/test/data/test_case.hpp>

#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;

BOOST_AUTO_TEST_CASE(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)*/);

 BOOST_CHECK_EQUAL(ss.str(), "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<list><listentry type=\"file1\">name1.txt</listentry><listentry type=\"file2\">name2.txt</listentry></list>");
}

BOOST_AUTO_TEST_CASE(string_stoul)
{
 unsigned long l = std::stoul("-1");

 BOOST_CHECK_EQUAL(l, std::numeric_limits<unsigned long>::max());
}