16 #include <boost/test/unit_test.hpp>
18 #define GETTEXT_DOMAIN "wesnoth-test"
37 #if defined(__APPLE__)
95 BOOST_REQUIRE_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
96 defines_map.begin() ,defines_map.end());
103 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
104 defines_map.begin() ,defines_map.end());
105 defines_map.erase(
"TEST");
109 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
110 defines_map.begin() ,defines_map.end());
115 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
116 defines_map.begin() ,defines_map.end());
120 defines_map.erase(
"TEST");
121 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
122 defines_map.begin() ,defines_map.end());
131 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
132 defines_map.begin() ,defines_map.end());
146 child = &test_config.
add_child(
"test_key");
147 (*child)[
"define"] =
"test";
158 BOOST_CHECK_EQUAL(test_config, cached_config);
165 cached_config.
clear();
167 BOOST_CHECK_EQUAL(test_config, cached_config);
181 BOOST_CHECK_EQUAL(test_config, cfg);
188 child[
"some_junk"] =
"hah";
190 BOOST_CHECK_EQUAL(test_config, cfg);
199 child[
"define"] =
"transaction";
201 child2[
"defined"] =
"parameter";
209 BOOST_CHECK_EQUAL(test_config, cached_config);
212 cached_config.
clear();
214 BOOST_CHECK_EQUAL(test_config, cached_config);
224 (*child)[
"define"] =
"transaction";
225 child = &test_config.
add_child(
"test_key4");
226 (*child)[
"defined"] =
"parameter";
237 BOOST_CHECK_EQUAL(test_config, cached_config);
242 (*child)[
"test"] =
"umc load";
243 child = &umc_config.
add_child(
"test_key3");
244 (*child)[
"define"] =
"transaction";
245 child = &umc_config.
add_child(
"test_key4");
246 (*child)[
"defined"] =
"parameter";
247 cached_config.
clear();
248 cache.get_config(
"data/test/test/umc.cfg", cached_config);
249 BOOST_CHECK_EQUAL(umc_config, cached_config);
258 (*child)[
"define"] =
"transaction";
259 child = &test_config.
add_child(
"test_key4");
260 (*child)[
"defined"] =
"parameter";
271 BOOST_CHECK_EQUAL(test_config, cached_config);
275 cache.set_force_invalid_cache(
true);
278 (*child)[
"test"] =
"umc load";
279 child = &umc_config.
add_child(
"test_key3");
280 (*child)[
"define"] =
"transaction";
281 child = &umc_config.
add_child(
"test_key4");
282 (*child)[
"defined"] =
"parameter";
283 cached_config.
clear();
284 cache.get_config(
"data/test/test/umc.cfg", cached_config);
285 BOOST_CHECK_EQUAL(umc_config, cached_config);
286 cache.set_force_invalid_cache(
false);
292 test_config.
add_child(
"test_lead_space")[
"space"] =
"empty char in middle";
294 cache.set_force_invalid_cache(
true);
296 cache.get_config(
"data/test/test/leading_space.cfg", cached_config);
297 BOOST_CHECK_EQUAL(test_config, cached_config);
298 cache.set_force_invalid_cache(
false);
299 cached_config.
clear();
300 cache.get_config(
"data/test/test/leading_space.cfg", cached_config);
301 BOOST_CHECK_EQUAL(test_config, cached_config);
311 cache.get_config(
"data/", cfg_ref);
313 for (
int i=0;
i < 3; ++
i)
315 cache.get_config(
"data/");
321 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)