15 #include <boost/test/unit_test.hpp>
17 #define GETTEXT_DOMAIN "wesnoth-test"
35 #if defined(__APPLE__)
93 BOOST_REQUIRE_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
94 defines_map.begin() ,defines_map.end());
101 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
102 defines_map.begin() ,defines_map.end());
103 defines_map.erase(
"TEST");
107 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
108 defines_map.begin() ,defines_map.end());
113 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
114 defines_map.begin() ,defines_map.end());
118 defines_map.erase(
"TEST");
119 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
120 defines_map.begin() ,defines_map.end());
129 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
130 defines_map.begin() ,defines_map.end());
144 child = &test_config.
add_child(
"test_key");
145 (*child)[
"define"] =
"test";
156 BOOST_CHECK_EQUAL(test_config, cached_config);
163 cached_config.
clear();
165 BOOST_CHECK_EQUAL(test_config, cached_config);
167 BOOST_CHECK_EQUAL(test_config.
child(
"test_key2")[
"define"].str(), cached_config.
child(
"test_key2")[
"define"].str());
179 BOOST_CHECK_EQUAL(test_config, cfg);
186 child[
"some_junk"] =
"hah";
188 BOOST_CHECK_EQUAL(test_config, cfg);
197 child[
"define"] =
"transaction";
199 child2[
"defined"] =
"parameter";
207 BOOST_CHECK_EQUAL(test_config, cached_config);
210 cached_config.
clear();
212 BOOST_CHECK_EQUAL(test_config, cached_config);
222 (*child)[
"define"] =
"transaction";
223 child = &test_config.
add_child(
"test_key4");
224 (*child)[
"defined"] =
"parameter";
235 BOOST_CHECK_EQUAL(test_config, cached_config);
240 (*child)[
"test"] =
"umc load";
241 child = &umc_config.
add_child(
"test_key3");
242 (*child)[
"define"] =
"transaction";
243 child = &umc_config.
add_child(
"test_key4");
244 (*child)[
"defined"] =
"parameter";
245 cached_config.
clear();
246 cache.get_config(
"data/test/test/umc.cfg", cached_config);
247 BOOST_CHECK_EQUAL(umc_config, cached_config);
256 (*child)[
"define"] =
"transaction";
257 child = &test_config.
add_child(
"test_key4");
258 (*child)[
"defined"] =
"parameter";
269 BOOST_CHECK_EQUAL(test_config, cached_config);
273 cache.set_force_invalid_cache(
true);
276 (*child)[
"test"] =
"umc load";
277 child = &umc_config.
add_child(
"test_key3");
278 (*child)[
"define"] =
"transaction";
279 child = &umc_config.
add_child(
"test_key4");
280 (*child)[
"defined"] =
"parameter";
281 cached_config.
clear();
282 cache.get_config(
"data/test/test/umc.cfg", cached_config);
283 BOOST_CHECK_EQUAL(umc_config, cached_config);
284 cache.set_force_invalid_cache(
false);
290 test_config.
add_child(
"test_lead_space")[
"space"] =
"empty char in middle";
292 cache.set_force_invalid_cache(
true);
294 cache.get_config(
"data/test/test/leading_space.cfg", cached_config);
295 BOOST_CHECK_EQUAL(test_config, cached_config);
296 cache.set_force_invalid_cache(
false);
297 cached_config.
clear();
298 cache.get_config(
"data/test/test/leading_space.cfg", cached_config);
299 BOOST_CHECK_EQUAL(test_config, cached_config);
309 cache.get_config(
"data/", cfg_ref);
311 for (
int i=0;
i < 3; ++
i)
313 cache.get_config(
"data/");
319 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(test_preproc_defines)
void lock()
Lock the transaction so no more macros are added.
void remove_define(const std::string &define)
Remove a entry to preproc defines map.
static test_config_cache & instance()
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
Definitions for the interface to Wesnoth Markup Language (WML).
void set_language(const std::string &slocale, const std::vector< std::string > *alternates)
const config & get_test_config_ref()
std::map< std::string, preproc_define > preproc_map
test_scoped_define test_def
test_config_cache & cache
This module controls the multiplayer lobby.
static preproc_map setup_test_preproc_map()
const preproc_map & get_preproc_map() const
config & add_child(const std::string &key)
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 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)
Used to share macros between cache objects You have to create transaction object to load all macros t...
static config setup_test_config()
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
void set_force_invalid_cache(bool force)
const std::string test_data_path("data/test/test/_main.cfg")
A config object defines a single node in a WML file, with access to child nodes.
Interfaces for manipulating version numbers of engine, add-ons, etc.
void add_define(const std::string &define)
Add a entry to preproc defines map.
Singleton class to manage game config file caching.