Move simple_wml unit test into the actual unit tests.
This commit is contained in:
parent
408571cc42
commit
b586e38e30
6 changed files with 52 additions and 32 deletions
|
@ -8,7 +8,6 @@ tests/test_commandline_options.cpp
|
|||
tests/test_config.cpp
|
||||
tests/test_config_cache.cpp
|
||||
tests/test_filesystem.cpp
|
||||
tests/test_formula_ai.cpp
|
||||
tests/test_formula_core.cpp
|
||||
tests/test_formula_function.cpp
|
||||
tests/test_formula_timespan.cpp
|
||||
|
@ -20,6 +19,7 @@ tests/test_mp_connect.cpp
|
|||
tests/test_recall_list.cpp
|
||||
tests/test_rng.cpp
|
||||
tests/test_serialization.cpp
|
||||
tests/test_simple_wml.cpp
|
||||
tests/test_team.cpp
|
||||
tests/test_unit_map.cpp
|
||||
tests/test_util.cpp
|
||||
|
|
|
@ -2,7 +2,6 @@ addon/validation.cpp
|
|||
server/common/dbconn.cpp
|
||||
server/common/forum_user_handler.cpp
|
||||
server/common/server_base.cpp
|
||||
server/common/simple_wml.cpp
|
||||
server/common/resultsets/ban_check.cpp
|
||||
server/common/resultsets/tournaments.cpp
|
||||
server/common/resultsets/game_history.cpp
|
||||
|
|
|
@ -30,4 +30,5 @@ serialization/string_utils.cpp
|
|||
serialization/tokenizer.cpp
|
||||
serialization/unicode.cpp
|
||||
serialization/validator.cpp
|
||||
server/common/simple_wml.cpp
|
||||
tstring.cpp
|
||||
|
|
|
@ -4,7 +4,6 @@ server/common/resultsets/ban_check.cpp
|
|||
server/common/resultsets/tournaments.cpp
|
||||
server/common/resultsets/game_history.cpp
|
||||
server/common/server_base.cpp
|
||||
server/common/simple_wml.cpp
|
||||
server/wesnothd/ban.cpp
|
||||
server/wesnothd/game.cpp
|
||||
server/wesnothd/metrics.cpp
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
static lg::log_domain log_config("config");
|
||||
#define ERR_SWML LOG_STREAM(err, log_config)
|
||||
#define LOG_SWML LOG_STREAM(info, log_config)
|
||||
|
||||
namespace simple_wml {
|
||||
|
||||
|
@ -1237,32 +1238,3 @@ void swap(document& lhs, document& rhs)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef UNIT_TEST_SIMPLE_WML
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
char* doctext = strdup(
|
||||
"[test]\n"
|
||||
"a=\"blah\"\n"
|
||||
"b=\"blah\"\n"
|
||||
"c=\"\\\\\"\n"
|
||||
"d=\"\\\"\"\n"
|
||||
"[/test]");
|
||||
std::cerr << doctext << "\n";
|
||||
simple_wml::document doc(doctext);
|
||||
|
||||
simple_wml::node& node = doc.root();
|
||||
simple_wml::node* test_node = node.child("test");
|
||||
assert(test_node);
|
||||
assert((*test_node)["a"] == "blah");
|
||||
assert((*test_node)["b"] == "blah");
|
||||
assert((*test_node)["c"] == "\\\\");
|
||||
assert((*test_node)["d"] == "\\\"");
|
||||
|
||||
node.set_attr("blah", "blah");
|
||||
test_node->set_attr("e", "f");
|
||||
std::cerr << doc.output();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
49
src/tests/test_simple_wml.cpp
Normal file
49
src/tests/test_simple_wml.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
Copyright (C) 2007 - 2022
|
||||
by Karol Nowak <grywacz@gmail.com>
|
||||
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-test"
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "server/common/simple_wml.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE( simple_wml )
|
||||
|
||||
BOOST_AUTO_TEST_CASE( simple_wml_first_test )
|
||||
{
|
||||
const char* doctext = R"([test]
|
||||
a="blah"
|
||||
b="blah"
|
||||
c="\\"
|
||||
d="\"""
|
||||
[/test])";
|
||||
simple_wml::document doc(doctext, INIT_STATE::INIT_COMPRESSED);
|
||||
|
||||
simple_wml::node& node = doc.root();
|
||||
simple_wml::node* test_node = node.child("test");
|
||||
node.set_attr("blah", "blah");
|
||||
test_node->set_attr("e", "f");
|
||||
|
||||
BOOST_CHECK(test_node);
|
||||
BOOST_CHECK((*test_node)["a"] == "blah");
|
||||
BOOST_CHECK((*test_node)["b"] == "blah");
|
||||
BOOST_CHECK((*test_node)["c"] == "\\\\");
|
||||
BOOST_CHECK((*test_node)["d"] == "\\\"\"");
|
||||
BOOST_CHECK(node["blah"] == "blah");
|
||||
BOOST_CHECK((*test_node)["e"] == "f");
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4: */
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
Loading…
Add table
Reference in a new issue