16 #include <boost/test/unit_test.hpp>
18 #define GETTEXT_DOMAIN "wesnoth-test"
36 #if defined(__APPLE__)
37 defines_map.try_emplace(
"APPLE");
91 BOOST_REQUIRE_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
92 defines_map.begin() ,defines_map.end());
97 defines_map.try_emplace(
"TEST");;
99 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
100 defines_map.begin() ,defines_map.end());
101 defines_map.erase(
"TEST");
105 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
106 defines_map.begin() ,defines_map.end());
110 defines_map.try_emplace(
"TEST");;
111 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
112 defines_map.begin() ,defines_map.end());
116 defines_map.erase(
"TEST");
117 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
118 defines_map.begin() ,defines_map.end());
127 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
128 defines_map.begin() ,defines_map.end());
142 child = &test_config.
add_child(
"test_key");
143 (*child)[
"define"] =
"test";
152 BOOST_CHECK_EQUAL(test_config, cached_config);
159 BOOST_CHECK_EQUAL(test_config, cached_config);
169 child[
"define"] =
"transaction";
171 child2[
"defined"] =
"parameter";
178 BOOST_CHECK_EQUAL(test_config, cached_config);
182 BOOST_CHECK_EQUAL(test_config, cached_config);
190 (*child)[
"define"] =
"transaction";
191 child = &test_config.
add_child(
"test_key4");
192 (*child)[
"defined"] =
"parameter";
202 BOOST_CHECK_EQUAL(test_config, cached_config);
207 (*child)[
"test"] =
"umc load";
208 child = &umc_config.
add_child(
"test_key3");
209 (*child)[
"define"] =
"transaction";
210 child = &umc_config.
add_child(
"test_key4");
211 (*child)[
"defined"] =
"parameter";
212 cached_config = cache.get_config(
"data/test/test/umc.cfg");
213 BOOST_CHECK_EQUAL(umc_config, cached_config);
222 (*child)[
"define"] =
"transaction";
223 child = &test_config.
add_child(
"test_key4");
224 (*child)[
"defined"] =
"parameter";
234 BOOST_CHECK_EQUAL(test_config, cached_config);
238 cache.set_force_invalid_cache(
true);
241 (*child)[
"test"] =
"umc load";
242 child = &umc_config.
add_child(
"test_key3");
243 (*child)[
"define"] =
"transaction";
244 child = &umc_config.
add_child(
"test_key4");
245 (*child)[
"defined"] =
"parameter";
246 cached_config = cache.get_config(
"data/test/test/umc.cfg");
247 BOOST_CHECK_EQUAL(umc_config, cached_config);
248 cache.set_force_invalid_cache(
false);
254 test_config.
add_child(
"test_lead_space")[
"space"] =
"empty char in middle";
256 cache.set_force_invalid_cache(
true);
257 config cached_config = cache.get_config(
"data/test/test/leading_space.cfg");
258 BOOST_CHECK_EQUAL(test_config, cached_config);
259 cache.set_force_invalid_cache(
false);
260 cached_config = cache.get_config(
"data/test/test/leading_space.cfg");
261 BOOST_CHECK_EQUAL(test_config, cached_config);
270 config cfg_ref = cache.get_config(
"data/");
272 for (
int i=0;
i < 3; ++
i)
274 cfg_ref = cache.get_config(
"data/");
280 BOOST_AUTO_TEST_SUITE_END()
A config object defines a single node in a WML file, with access to child nodes.
config & mandatory_child(config_key_type key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
config & add_child(config_key_type key)
Used to share macros between cache objects You have to create transaction object to load all macros t...
void lock()
Lock the transaction so no more macros are added.
Singleton class to manage game config file caching.
void add_define(const std::string &define)
Add a entry to preproc defines map.
void set_force_invalid_cache(bool)
const preproc_map & get_preproc_map() const
void remove_define(const std::string &define)
Remove a entry to preproc defines map.
Used to make distinct singleton for testing it because other tests will need original one to load dat...
static test_config_cache & instance()
void set_force_invalid_cache(bool force)
Definitions for the interface to Wesnoth Markup Language (WML).
Interfaces for manipulating version numbers of engine, add-ons, etc.
const language_def & get_language()
Standard logging facilities (interface).
Game configuration data as global variables.
const version_info wesnoth_version(VERSION)
Main entry points of multiplayer mode.
const config & get_test_config_ref()
void set_language(const std::string &language, const std::vector< std::string > *)
std::map< std::string, struct preproc_define > preproc_map
test_config_cache & cache
test_scoped_define test_def
static config setup_test_config()
static preproc_map setup_test_preproc_map()
BOOST_AUTO_TEST_CASE(test_preproc_defines)
const std::string test_data_path("data/test/test/_main.cfg")
game_config::scoped_preproc_define_internal< test_config_cache > test_scoped_define
Used to redirect defines settings to test cache.
BOOST_FIXTURE_TEST_SUITE(test_map_location, MLFixture)