Fixed test use correct way to translate t_string...
...for comparing with parsed config object
This commit is contained in:
parent
b4a94859bd
commit
9a1f9012cc
2 changed files with 20 additions and 4 deletions
|
@ -43,11 +43,19 @@ static void exception_translator_network(const network::error& e)
|
||||||
throw boost::execution_exception(boost::execution_exception::cpp_exception_error, "network::error: " + e.message);
|
throw boost::execution_exception(boost::execution_exception::cpp_exception_error, "network::error: " + e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void exception_translator_game(const game::error& e)
|
static void exception_translator_game(const game::error& e)
|
||||||
{
|
{
|
||||||
throw boost::execution_exception(boost::execution_exception::cpp_exception_error, "game::error: " + e.message);
|
throw boost::execution_exception(boost::execution_exception::cpp_exception_error, "game::error: " + e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool match_english(const language_def& def)
|
||||||
|
{
|
||||||
|
return def.localename == "C";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct wesnoth_global_fixture {
|
struct wesnoth_global_fixture {
|
||||||
wesnoth_global_fixture()
|
wesnoth_global_fixture()
|
||||||
{
|
{
|
||||||
|
@ -56,6 +64,12 @@ struct wesnoth_global_fixture {
|
||||||
|
|
||||||
load_language_list();
|
load_language_list();
|
||||||
::init_textdomains(game_config::config_cache::instance().get_config());
|
::init_textdomains(game_config::config_cache::instance().get_config());
|
||||||
|
const std::vector<language_def>& languages = get_languages();
|
||||||
|
std::vector<language_def>::const_iterator English = std::find_if(languages.begin(),
|
||||||
|
languages.end(),
|
||||||
|
match_english); // Using German because the most active translation
|
||||||
|
::set_language(*English);
|
||||||
|
|
||||||
|
|
||||||
// Initialize unit tests
|
// Initialize unit tests
|
||||||
SDL_Init(SDL_INIT_TIMER);
|
SDL_Init(SDL_INIT_TIMER);
|
||||||
|
|
|
@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE( test_load_config )
|
||||||
cache.add_define("TEST_DEFINE");
|
cache.add_define("TEST_DEFINE");
|
||||||
|
|
||||||
child = &test_config.add_child("test_key");
|
child = &test_config.add_child("test_key");
|
||||||
(*child)["define"] = _("testing translation reset.");
|
(*child)["define"] = t_string("testing translation reset.", GETTEXT_DOMAIN);
|
||||||
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(test_config, cache.get_config());
|
BOOST_CHECK_EQUAL(test_config, cache.get_config());
|
||||||
|
@ -144,9 +144,10 @@ BOOST_AUTO_TEST_CASE( test_translation_reload )
|
||||||
(*child)["define"] = "test";
|
(*child)["define"] = "test";
|
||||||
|
|
||||||
child = &test_config.add_child("test_key");
|
child = &test_config.add_child("test_key");
|
||||||
(*child)["define"] = _("testing translation reset.");
|
(*child)["define"] = t_string("testing translation reset.", GETTEXT_DOMAIN);
|
||||||
|
|
||||||
// Change language
|
// Change language
|
||||||
|
const language_def& original_lang = get_language();
|
||||||
const std::vector<language_def>& languages = get_languages();
|
const std::vector<language_def>& languages = get_languages();
|
||||||
BOOST_CHECK_MESSAGE(languages.size()>0, "No languages found!");
|
BOOST_CHECK_MESSAGE(languages.size()>0, "No languages found!");
|
||||||
std::vector<language_def>::const_iterator German = std::find_if(languages.begin(),
|
std::vector<language_def>::const_iterator German = std::find_if(languages.begin(),
|
||||||
|
@ -156,11 +157,12 @@ BOOST_AUTO_TEST_CASE( test_translation_reload )
|
||||||
::set_language(*German);
|
::set_language(*German);
|
||||||
cache.reload_translations();
|
cache.reload_translations();
|
||||||
|
|
||||||
BOOST_CHECK_MESSAGE( test_config != cache.get_config(), "Translation update failed update translations!" );
|
BOOST_CHECK_MESSAGE( test_config != cache.get_config(), "Translation update failed to update translations!" );
|
||||||
|
|
||||||
(*child)["define"] = _("testing translation reset.");
|
(*child)["define"].reset_translation();
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(test_config, cache.get_config());
|
BOOST_CHECK_EQUAL(test_config, cache.get_config());
|
||||||
|
set_language(original_lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set ts=4 sw=4: */
|
/* vim: set ts=4 sw=4: */
|
||||||
|
|
Loading…
Add table
Reference in a new issue