16 #include <boost/test/unit_test.hpp>
18 #define GETTEXT_DOMAIN "wesnoth-test"
36 #if defined(__APPLE__)
37 defines_map.try_emplace(
"APPLE");
95 BOOST_REQUIRE_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
96 defines_map.begin() ,defines_map.end());
101 defines_map.try_emplace(
"TEST");;
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());
114 defines_map.try_emplace(
"TEST");;
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";
156 BOOST_CHECK_EQUAL(test_config, cached_config);
163 BOOST_CHECK_EQUAL(test_config, cached_config);
173 child[
"define"] =
"transaction";
175 child2[
"defined"] =
"parameter";
182 BOOST_CHECK_EQUAL(test_config, cached_config);
186 BOOST_CHECK_EQUAL(test_config, cached_config);
194 (*child)[
"define"] =
"transaction";
195 child = &test_config.
add_child(
"test_key4");
196 (*child)[
"defined"] =
"parameter";
206 BOOST_CHECK_EQUAL(test_config, cached_config);
211 (*child)[
"test"] =
"umc load";
212 child = &umc_config.
add_child(
"test_key3");
213 (*child)[
"define"] =
"transaction";
214 child = &umc_config.
add_child(
"test_key4");
215 (*child)[
"defined"] =
"parameter";
216 cached_config = cache.get_config(
"data/test/test/umc.cfg");
217 BOOST_CHECK_EQUAL(umc_config, cached_config);
226 (*child)[
"define"] =
"transaction";
227 child = &test_config.
add_child(
"test_key4");
228 (*child)[
"defined"] =
"parameter";
238 BOOST_CHECK_EQUAL(test_config, cached_config);
242 cache.set_force_invalid_cache(
true);
245 (*child)[
"test"] =
"umc load";
246 child = &umc_config.
add_child(
"test_key3");
247 (*child)[
"define"] =
"transaction";
248 child = &umc_config.
add_child(
"test_key4");
249 (*child)[
"defined"] =
"parameter";
250 cached_config = cache.get_config(
"data/test/test/umc.cfg");
251 BOOST_CHECK_EQUAL(umc_config, cached_config);
252 cache.set_force_invalid_cache(
false);
258 test_config.
add_child(
"test_lead_space")[
"space"] =
"empty char in middle";
260 cache.set_force_invalid_cache(
true);
261 config cached_config = cache.get_config(
"data/test/test/leading_space.cfg");
262 BOOST_CHECK_EQUAL(test_config, cached_config);
263 cache.set_force_invalid_cache(
false);
264 cached_config = cache.get_config(
"data/test/test/leading_space.cfg");
265 BOOST_CHECK_EQUAL(test_config, cached_config);
274 config cfg_ref = cache.get_config(
"data/");
276 for (
int i=0;
i < 3; ++
i)
278 cfg_ref = cache.get_config(
"data/");
284 BOOST_AUTO_TEST_SUITE_END()
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(std::string_view key)
config & mandatory_child(std::string_view key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
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::string to_string(const Range &range, const Func &op)
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)