The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
test_simple_wml.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2007 - 2025
3 by Karol Nowak <grywacz@gmail.com>
4 Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY.
12
13 See the COPYING file for more details.
14*/
15
16#define GETTEXT_DOMAIN "wesnoth-test"
17
18#include <boost/test/unit_test.hpp>
19
21
23
24BOOST_AUTO_TEST_CASE( simple_wml_first_test )
25{
26 const char* doctext = R"([test]
27a="blah"
28b="blah"
29c="\\"
30d="\"""
31[/test])";
32 simple_wml::document doc(doctext, INIT_STATE::INIT_COMPRESSED);
33
34 simple_wml::node& node = doc.root();
35 simple_wml::node* test_node = node.child("test");
36 node.set_attr("blah", "blah");
37 test_node->set_attr("e", "f");
38
39 BOOST_CHECK(test_node);
40 BOOST_CHECK((*test_node)["a"] == "blah");
41 BOOST_CHECK((*test_node)["b"] == "blah");
42 BOOST_CHECK((*test_node)["c"] == "\\\\");
43 BOOST_CHECK((*test_node)["d"] == "\\\"\"");
44 BOOST_CHECK(node["blah"] == "blah");
45 BOOST_CHECK((*test_node)["e"] == "f");
46}
47
48/* vim: set ts=4 sw=4: */
49BOOST_AUTO_TEST_SUITE_END()
node * child(const char *name)
node & set_attr(const char *key, const char *value)
BOOST_AUTO_TEST_SUITE(filesystem)
BOOST_AUTO_TEST_CASE(simple_wml_first_test)