16#include <boost/test/unit_test.hpp>
18#define GETTEXT_DOMAIN "wesnoth-test"
37 target.try_emplace(
"APPLE");
41 target.try_emplace(
"ANDROID");
45#if defined(MOUSE_TOUCH_EMULATION) || defined(TARGET_OS_IPHONE)
46 target.try_emplace(
"IPHONEOS");
106 BOOST_REQUIRE_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
107 defines_map.begin() ,defines_map.end());
112 defines_map.try_emplace(
"TEST");;
114 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
115 defines_map.begin() ,defines_map.end());
116 defines_map.erase(
"TEST");
120 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
121 defines_map.begin() ,defines_map.end());
124 cache.add_define(
"TEST");
125 defines_map.try_emplace(
"TEST");;
126 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
127 defines_map.begin() ,defines_map.end());
130 cache.remove_define(
"TEST");
131 defines_map.erase(
"TEST");
132 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
133 defines_map.begin() ,defines_map.end());
142 BOOST_CHECK_EQUAL_COLLECTIONS(test_defines.begin(),test_defines.end(),
143 defines_map.begin() ,defines_map.end());
157 child = &test_config.
add_child(
"test_key");
158 (*child)[
"define"] =
"test";
167 BOOST_CHECK_EQUAL(test_config, cached_config);
174 BOOST_CHECK_EQUAL(test_config, cached_config);
184 child[
"define"] =
"transaction";
186 child2[
"defined"] =
"parameter";
193 BOOST_CHECK_EQUAL(test_config, cached_config);
197 BOOST_CHECK_EQUAL(test_config, cached_config);
205 (*child)[
"define"] =
"transaction";
206 child = &test_config.
add_child(
"test_key4");
207 (*child)[
"defined"] =
"parameter";
217 BOOST_CHECK_EQUAL(test_config, cached_config);
222 (*child)[
"test"] =
"umc load";
223 child = &umc_config.
add_child(
"test_key3");
224 (*child)[
"define"] =
"transaction";
225 child = &umc_config.
add_child(
"test_key4");
226 (*child)[
"defined"] =
"parameter";
227 cached_config =
cache.get_config(
"data/test/test/umc.cfg");
228 BOOST_CHECK_EQUAL(umc_config, cached_config);
237 (*child)[
"define"] =
"transaction";
238 child = &test_config.
add_child(
"test_key4");
239 (*child)[
"defined"] =
"parameter";
249 BOOST_CHECK_EQUAL(test_config, cached_config);
253 cache.set_force_invalid_cache(
true);
256 (*child)[
"test"] =
"umc load";
257 child = &umc_config.
add_child(
"test_key3");
258 (*child)[
"define"] =
"transaction";
259 child = &umc_config.
add_child(
"test_key4");
260 (*child)[
"defined"] =
"parameter";
261 cached_config =
cache.get_config(
"data/test/test/umc.cfg");
262 BOOST_CHECK_EQUAL(umc_config, cached_config);
263 cache.set_force_invalid_cache(
false);
269 test_config.
add_child(
"test_lead_space")[
"space"] =
"empty char in middle";
271 cache.set_force_invalid_cache(
true);
272 config cached_config =
cache.get_config(
"data/test/test/leading_space.cfg");
273 BOOST_CHECK_EQUAL(test_config, cached_config);
274 cache.set_force_invalid_cache(
false);
275 cached_config =
cache.get_config(
"data/test/test/leading_space.cfg");
276 BOOST_CHECK_EQUAL(test_config, cached_config);
287 for (
int i=0;
i < 3; ++
i)
289 cfg_ref =
cache.get_config(
"data/");
295BOOST_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 set_force_invalid_cache(bool)
Used to set and unset scoped defines to preproc_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()
void set_language(const language_def &locale)
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()
std::map< std::string, struct preproc_define > preproc_map
std::unordered_map< std::string, cache_item > cache
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)