The Battle for Wesnoth  1.17.6+dev
test_simple_wml.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 - 2022
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 
24 BOOST_AUTO_TEST_CASE( simple_wml_first_test )
25 {
26  const char* doctext = R"([test]
27 a="blah"
28 b="blah"
29 c="\\"
30 d="\"""
31 [/test])";
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: */
49 BOOST_AUTO_TEST_SUITE_END()
node & set_attr(const char *key, const char *value)
Definition: simple_wml.cpp:412
BOOST_AUTO_TEST_CASE(simple_wml_first_test)
node * child(const char *name)
Definition: simple_wml.cpp:607
BOOST_AUTO_TEST_SUITE(filesystem)