16 #include <boost/test/unit_test.hpp> 18 #define GETTEXT_DOMAIN "wesnoth-test" 36 #if defined(__APPLE__) 94 BOOST_REQUIRE_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
95 defines_map.begin() ,defines_map.end());
102 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
103 defines_map.begin() ,defines_map.end());
104 defines_map.erase(
"TEST");
108 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
109 defines_map.begin() ,defines_map.end());
114 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
115 defines_map.begin() ,defines_map.end());
119 defines_map.erase(
"TEST");
120 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
121 defines_map.begin() ,defines_map.end());
130 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
131 defines_map.begin() ,defines_map.end());
145 child = &test_config.
add_child(
"test_key");
146 (*child)[
"define"] =
"test";
157 BOOST_CHECK_EQUAL(test_config, cached_config);
164 cached_config.
clear();
166 BOOST_CHECK_EQUAL(test_config, cached_config);
168 BOOST_CHECK_EQUAL(test_config.
child(
"test_key2")[
"define"].str(), cached_config.
child(
"test_key2")[
"define"].str());
180 BOOST_CHECK_EQUAL(test_config, cfg);
187 child[
"some_junk"] =
"hah";
189 BOOST_CHECK_EQUAL(test_config, cfg);
198 child[
"define"] =
"transaction";
200 child2[
"defined"] =
"parameter";
208 BOOST_CHECK_EQUAL(test_config, cached_config);
211 cached_config.
clear();
213 BOOST_CHECK_EQUAL(test_config, cached_config);
223 (*child)[
"define"] =
"transaction";
224 child = &test_config.
add_child(
"test_key4");
225 (*child)[
"defined"] =
"parameter";
236 BOOST_CHECK_EQUAL(test_config, cached_config);
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.
clear();
247 cache.get_config(
"data/test/test/umc.cfg", cached_config);
248 BOOST_CHECK_EQUAL(umc_config, cached_config);
257 (*child)[
"define"] =
"transaction";
258 child = &test_config.
add_child(
"test_key4");
259 (*child)[
"defined"] =
"parameter";
270 BOOST_CHECK_EQUAL(test_config, cached_config);
274 cache.set_force_invalid_cache(
true);
277 (*child)[
"test"] =
"umc load";
278 child = &umc_config.
add_child(
"test_key3");
279 (*child)[
"define"] =
"transaction";
280 child = &umc_config.
add_child(
"test_key4");
281 (*child)[
"defined"] =
"parameter";
282 cached_config.
clear();
283 cache.get_config(
"data/test/test/umc.cfg", cached_config);
284 BOOST_CHECK_EQUAL(umc_config, cached_config);
285 cache.set_force_invalid_cache(
false);
291 test_config.
add_child(
"test_lead_space")[
"space"] =
"empty char in middle";
293 cache.set_force_invalid_cache(
true);
295 cache.get_config(
"data/test/test/leading_space.cfg", cached_config);
296 BOOST_CHECK_EQUAL(test_config, cached_config);
297 cache.set_force_invalid_cache(
false);
298 cached_config.
clear();
299 cache.get_config(
"data/test/test/leading_space.cfg", cached_config);
300 BOOST_CHECK_EQUAL(test_config, cached_config);
310 cache.get_config(
"data/", cfg_ref);
312 for (
int i=0;
i < 3; ++
i)
314 cache.get_config(
"data/");
320 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(test_preproc_defines)
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Interfaces for manipulating version numbers of engine, add-ons, etc.
void lock()
Lock the transaction so no more macros are added.
void set_language(const std::string &language, const std::vector< std::string > *)
void remove_define(const std::string &define)
Remove a entry to preproc defines map.
static test_config_cache & instance()
Definitions for the interface to Wesnoth Markup Language (WML).
const config & get_test_config_ref()
test_scoped_define test_def
test_config_cache & cache
Main entry points of multiplayer mode.
static preproc_map setup_test_preproc_map()
game_config::scoped_preproc_define_internal< test_config_cache > test_scoped_define
Used to redirect defines settings to test cache.
Game configuration data as global variables.
const preproc_map & get_preproc_map() const
const language_def & get_language()
void set_force_invalid_cache(bool)
Used to make distinct singleton for testing it because other tests will need original one to load dat...
const version_info wesnoth_version(VERSION)
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...
static config setup_test_config()
void set_force_invalid_cache(bool force)
const std::string test_data_path("data/test/test/_main.cfg")
std::map< std::string, struct preproc_define > preproc_map
A config object defines a single node in a WML file, with access to child nodes.
void add_define(const std::string &define)
Add a entry to preproc defines map.
Singleton class to manage game config file caching.