diff --git a/src/direction.test.c b/src/direction.test.c index fc2dea46e..c2feebd3f 100644 --- a/src/direction.test.c +++ b/src/direction.test.c @@ -11,7 +11,7 @@ static void test_init_directions(CuTest *tc) { struct locale *lang; test_cleanup(); - lang = get_or_create_locale("en"); + lang = get_or_create_locale("de"); locale_setstring(lang, "dir_nw", "NW"); init_directions(lang); CuAssertIntEquals(tc, D_NORTHWEST, get_direction("nw", lang)); diff --git a/src/give.test.c b/src/give.test.c index 119c5f1a9..f12397bce 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -31,18 +31,11 @@ struct give { static void setup_give(struct give *env) { struct terrain_type *ter = test_create_terrain("plain", LAND_REGION); - struct locale *lang; race *rc; assert(env->f1); rc = test_create_race(env->f1->race ? env->f1->race->_name : "humon"); rc->ec_flags |= GIVEPERSON; - lang = get_or_create_locale(env->f1->locale ? locale_name(env->f1->locale) : "test"); - env->f1->locale = lang; - locale_setstring(lang, "ALLES", "ALLES"); - locale_setstring(lang, "PERSONEN", "PERSONEN"); - locale_setstring(lang, "KRAEUTER", "KRAUT"); - init_locale(lang); env->r = test_create_region(0, 0, ter); env->src = test_create_unit(env->f1, env->r); @@ -277,7 +270,6 @@ static void test_give(CuTest * tc) { static void test_give_herbs(CuTest * tc) { struct give env; struct order *ord; - struct locale * lang; char cmd[32]; test_cleanup(); @@ -286,12 +278,8 @@ static void test_give_herbs(CuTest * tc) { setup_give(&env); i_change(&env.src->items, env.itype, 10); - lang = get_or_create_locale("test"); - env.f1->locale = lang; - locale_setstring(lang, "KRAEUTER", "KRAUT"); - init_locale(lang); - _snprintf(cmd, sizeof(cmd), "%s KRAUT", itoa36(env.dst->no)); - ord = create_order(K_GIVE, lang, cmd); + _snprintf(cmd, sizeof(cmd), "%s %s", itoa36(env.dst->no), LOC(env.f1->locale, parameters[P_HERBS])); + ord = create_order(K_GIVE, env.f1->locale, cmd); assert(ord); give_cmd(env.src, ord); @@ -332,7 +320,6 @@ static void test_give_invalid_target(CuTest *tc) { // bug https://bugs.eressea.de/view.php?id=1685 struct give env; order *ord; - struct locale * lang; test_cleanup(); env.f1 = test_create_faction(0); @@ -340,11 +327,7 @@ static void test_give_invalid_target(CuTest *tc) { setup_give(&env); i_change(&env.src->items, env.itype, 10); - lang = get_or_create_locale("de"); - env.f1->locale = lang; - locale_setstring(lang, "KRAEUTER", "KRAUT"); - init_locale(lang); - ord = create_order(K_GIVE, lang, "## KRAUT"); + ord = create_order(K_GIVE, env.f1->locale, "## KRAUT"); assert(ord); give_cmd(env.src, ord); diff --git a/src/kernel/build.test.c b/src/kernel/build.test.c index 8e26d86c5..c2185cd29 100644 --- a/src/kernel/build.test.c +++ b/src/kernel/build.test.c @@ -34,7 +34,6 @@ static unit * setup_build(build_fixture *bf) { bf->rc = test_create_race("human"); bf->r = test_create_region(0, 0, 0); bf->f = test_create_faction(bf->rc); - bf->f->locale = get_or_create_locale("de"); assert(bf->rc && bf->f && bf->r); bf->u = test_create_unit(bf->f, bf->r); assert(bf->u); diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c index 7078d17ac..30b7cef90 100644 --- a/src/kernel/config.test.c +++ b/src/kernel/config.test.c @@ -22,8 +22,7 @@ static void test_read_unitid(CuTest *tc) { struct terrain_type *t_plain; test_cleanup(); - lang = get_or_create_locale("de"); - test_translate_param(lang, P_TEMP, "TEMP"); + lang = test_create_locale(); /* note that the english order is FIGHT, not COMBAT, so this is a poor example */ t_plain = test_create_terrain("plain", LAND_REGION); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, t_plain)); @@ -68,8 +67,7 @@ static void test_getunit(CuTest *tc) { struct terrain_type *t_plain; test_cleanup(); - lang = get_or_create_locale("de"); - test_translate_param(lang, P_TEMP, "TEMP"); + lang = test_create_locale(); /* note that the english order is FIGHT, not COMBAT, so this is a poor example */ t_plain = test_create_terrain("plain", LAND_REGION); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, t_plain)); diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 19b4da883..94a1910f8 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -97,7 +97,7 @@ static void test_addfaction(CuTest *tc) { test_cleanup(); rc = rc_get_or_create("human"); - lang = get_or_create_locale("en"); + lang = test_create_locale(); f = addfaction("test@eressea.de", "hurrdurr", rc, lang, 1234); CuAssertPtrNotNull(tc, f); CuAssertPtrNotNull(tc, f->name); diff --git a/src/laws.test.c b/src/laws.test.c index 64f65663c..1b2136db7 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -213,18 +213,16 @@ static void test_display_cmd(CuTest *tc) { test_cleanup(); r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION)); f = test_create_faction(0); - f->locale = get_or_create_locale("de"); assert(r && f); - test_translate_param(f->locale, P_UNIT, "EINHEIT"); u = test_create_unit(f, r); assert(u); - ord = create_order(K_DISPLAY, f->locale, "EINHEIT Hodor"); + ord = create_order(K_DISPLAY, f->locale, "%s Hodor", LOC(f->locale, parameters[P_UNIT])); CuAssertIntEquals(tc, 0, display_cmd(u, ord)); CuAssertStrEquals(tc, "Hodor", u->display); free_order(ord); - ord = create_order(K_DISPLAY, f->locale, "EINHEIT"); + ord = create_order(K_DISPLAY, f->locale, LOC(f->locale, parameters[P_UNIT])); CuAssertIntEquals(tc, 0, display_cmd(u, ord)); CuAssertPtrEquals(tc, NULL, u->display); free_order(ord); @@ -779,34 +777,27 @@ static void test_luck_message(CuTest *tc) { static unit * setup_name_cmd(void) { faction *f; - struct locale *lang; test_cleanup(); f = test_create_faction(0); - f->locale = lang = get_or_create_locale("en"); - locale_setstring(lang, parameters[P_UNIT], "UNIT"); - locale_setstring(lang, parameters[P_REGION], "REGION"); - locale_setstring(lang, parameters[P_FACTION], "FACTION"); - locale_setstring(lang, parameters[P_BUILDING], "BUILDING"); - locale_setstring(lang, parameters[P_SHIP], "SHIP"); - init_parameters(lang); return test_create_unit(f, test_create_region(0, 0, 0)); } static void test_name_unit(CuTest *tc) { unit *u; + faction *f; order *ord; u = setup_name_cmd(); - - ord = create_order(K_NAME, u->faction->locale, "UNIT Hodor"); + f = u->faction; + ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_UNIT])); name_cmd(u, ord); CuAssertStrEquals(tc, "Hodor", u->_name); free_order(ord); - ord = create_order(K_NAME, u->faction->locale, "UNIT"); + ord = create_order(K_NAME, f->locale, LOC(f->locale, parameters[P_UNIT])); name_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error84")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error84")); CuAssertStrEquals(tc, "Hodor", u->_name); free_order(ord); @@ -815,22 +806,24 @@ static void test_name_unit(CuTest *tc) { static void test_name_region(CuTest *tc) { unit *u; + faction *f; order *ord; u = setup_name_cmd(); + f = u->faction; - ord = create_order(K_NAME, u->faction->locale, "REGION Hodor"); + ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_REGION])); name_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error145")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error145")); u->building = test_create_building(u->region, 0); name_cmd(u, ord); CuAssertStrEquals(tc, "Hodor", u->region->land->name); free_order(ord); - ord = create_order(K_NAME, u->faction->locale, "REGION"); + ord = create_order(K_NAME, f->locale, LOC(f->locale, parameters[P_REGION])); name_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error84")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error84")); CuAssertStrEquals(tc, "Hodor", u->region->land->name); free_order(ord); @@ -839,22 +832,24 @@ static void test_name_region(CuTest *tc) { static void test_name_building(CuTest *tc) { unit *u; + faction *f; order *ord; u = setup_name_cmd(); + f = u->faction; - ord = create_order(K_NAME, u->faction->locale, "BUILDING Hodor"); + ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_BUILDING])); name_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error145")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error145")); u->building = test_create_building(u->region, 0); name_cmd(u, ord); CuAssertStrEquals(tc, "Hodor", u->building->name); free_order(ord); - ord = create_order(K_NAME, u->faction->locale, "BUILDING"); + ord = create_order(K_NAME, f->locale, LOC(f->locale, parameters[P_BUILDING])); name_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error84")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error84")); CuAssertStrEquals(tc, "Hodor", u->building->name); free_order(ord); @@ -868,19 +863,21 @@ static void test_name_building(CuTest *tc) { static void test_name_ship(CuTest *tc) { unit *u; + faction *f; order *ord; u = setup_name_cmd(); + f = u->faction; u->ship = test_create_ship(u->region, 0); - ord = create_order(K_NAME, u->faction->locale, "SHIP Hodor"); + ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_SHIP])); name_cmd(u, ord); CuAssertStrEquals(tc, "Hodor", u->ship->name); free_order(ord); - ord = create_order(K_NAME, u->faction->locale, "SHIP"); + ord = create_order(K_NAME, f->locale, LOC(f->locale, parameters[P_SHIP])); name_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error84")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error84")); CuAssertStrEquals(tc, "Hodor", u->ship->name); free_order(ord); @@ -896,7 +893,6 @@ static void test_long_order_normal(CuTest *tc) { u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); fset(u, UFL_MOVED); fset(u, UFL_LONGACTION); - u->faction->locale = get_or_create_locale("de"); unit_addorder(u, ord = create_order(K_MOVE, u->faction->locale, 0)); update_long_order(u); CuAssertPtrEquals(tc, ord->data, u->thisorder->data); @@ -913,7 +909,6 @@ static void test_long_order_none(CuTest *tc) { unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); - u->faction->locale = get_or_create_locale("de"); update_long_order(u); CuAssertPtrEquals(tc, 0, u->thisorder); CuAssertPtrEquals(tc, 0, u->orders); @@ -926,7 +921,6 @@ static void test_long_order_cast(CuTest *tc) { unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); - u->faction->locale = get_or_create_locale("de"); unit_addorder(u, create_order(K_CAST, u->faction->locale, 0)); unit_addorder(u, create_order(K_CAST, u->faction->locale, 0)); update_long_order(u); @@ -941,7 +935,6 @@ static void test_long_order_buy_sell(CuTest *tc) { unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); - u->faction->locale = get_or_create_locale("de"); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); unit_addorder(u, create_order(K_SELL, u->faction->locale, 0)); unit_addorder(u, create_order(K_SELL, u->faction->locale, 0)); @@ -957,7 +950,6 @@ static void test_long_order_multi_long(CuTest *tc) { unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); - u->faction->locale = get_or_create_locale("de"); unit_addorder(u, create_order(K_MOVE, u->faction->locale, 0)); unit_addorder(u, create_order(K_DESTROY, u->faction->locale, 0)); update_long_order(u); @@ -972,7 +964,6 @@ static void test_long_order_multi_buy(CuTest *tc) { unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); - u->faction->locale = get_or_create_locale("de"); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); update_long_order(u); @@ -987,7 +978,6 @@ static void test_long_order_multi_sell(CuTest *tc) { unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); - u->faction->locale = get_or_create_locale("de"); unit_addorder(u, create_order(K_SELL, u->faction->locale, 0)); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); unit_addorder(u, create_order(K_SELL, u->faction->locale, 0)); @@ -1003,7 +993,6 @@ static void test_long_order_buy_cast(CuTest *tc) { unit *u; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); - u->faction->locale = get_or_create_locale("de"); unit_addorder(u, create_order(K_BUY, u->faction->locale, 0)); unit_addorder(u, create_order(K_CAST, u->faction->locale, 0)); update_long_order(u); @@ -1021,7 +1010,6 @@ static void test_long_order_hungry(CuTest *tc) { config_set("hunger.long", "1"); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); fset(u, UFL_HUNGER); - u->faction->locale = get_or_create_locale("de"); unit_addorder(u, create_order(K_MOVE, u->faction->locale, 0)); unit_addorder(u, create_order(K_DESTROY, u->faction->locale, 0)); set_default_order(K_WORK); @@ -1040,7 +1028,6 @@ static void test_ally_cmd_errors(CuTest *tc) { test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); - u->faction->locale = get_or_create_locale("de"); fid = u->faction->no + 1; CuAssertPtrEquals(tc, 0, findfaction(fid)); @@ -1056,36 +1043,30 @@ static void test_ally_cmd(CuTest *tc) { unit *u; faction * f; order *ord; - struct locale *lang; test_cleanup(); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); f = test_create_faction(0); - u->faction->locale = lang = get_or_create_locale("de"); - locale_setstring(lang, parameters[P_NOT], "NICHT"); - locale_setstring(lang, parameters[P_GUARD], "BEWACHE"); - init_parameters(lang); - - ord = create_order(K_ALLY, lang, "%s", itoa36(f->no)); + ord = create_order(K_ALLY, f->locale, "%s", itoa36(f->no)); ally_cmd(u, ord); CuAssertPtrEquals(tc, 0, u->faction->msgs); CuAssertIntEquals(tc, HELP_ALL, alliedfaction(0, u->faction, f, HELP_ALL)); free_order(ord); - ord = create_order(K_ALLY, lang, "%s NICHT", itoa36(f->no)); + ord = create_order(K_ALLY, f->locale, "%s %s", itoa36(f->no), LOC(f->locale, parameters[P_NOT])); ally_cmd(u, ord); CuAssertPtrEquals(tc, 0, u->faction->msgs); CuAssertIntEquals(tc, 0, alliedfaction(0, u->faction, f, HELP_ALL)); free_order(ord); - ord = create_order(K_ALLY, lang, "%s BEWACHE", itoa36(f->no)); + ord = create_order(K_ALLY, f->locale, "%s %s", itoa36(f->no), LOC(f->locale, parameters[P_GUARD])); ally_cmd(u, ord); CuAssertPtrEquals(tc, 0, u->faction->msgs); CuAssertIntEquals(tc, HELP_GUARD, alliedfaction(0, u->faction, f, HELP_ALL)); free_order(ord); - ord = create_order(K_ALLY, lang, "%s BEWACHE NICHT", itoa36(f->no)); + ord = create_order(K_ALLY, f->locale, "%s %s %s", itoa36(f->no), LOC(f->locale, parameters[P_GUARD]), LOC(f->locale, parameters[P_NOT])); ally_cmd(u, ord); CuAssertPtrEquals(tc, 0, u->faction->msgs); CuAssertIntEquals(tc, 0, alliedfaction(0, u->faction, f, HELP_ALL)); @@ -1116,26 +1097,22 @@ static void test_nmr_warnings(CuTest *tc) { static unit * setup_mail_cmd(void) { faction *f; - struct locale *lang; test_cleanup(); f = test_create_faction(0); - f->locale = lang = get_or_create_locale("de"); - locale_setstring(lang, parameters[P_UNIT], "EINHEIT"); - locale_setstring(lang, parameters[P_REGION], "REGION"); - locale_setstring(lang, parameters[P_FACTION], "PARTEI"); - init_parameters(lang); return test_create_unit(f, test_create_region(0, 0, 0)); } static void test_mail_unit(CuTest *tc) { order *ord; unit *u; + faction *f; u = setup_mail_cmd(); - ord = create_order(K_MAIL, u->faction->locale, "EINHEIT %s 'Hodor!'", itoa36(u->no)); + f = u->faction; + ord = create_order(K_MAIL, f->locale, "%s %s 'Hodor!'", LOC(f->locale, parameters[P_UNIT]), itoa36(u->no)); mail_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "unitmessage")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "unitmessage")); free_order(ord); test_cleanup(); } @@ -1143,11 +1120,13 @@ static void test_mail_unit(CuTest *tc) { static void test_mail_faction(CuTest *tc) { order *ord; unit *u; + faction *f; u = setup_mail_cmd(); - ord = create_order(K_MAIL, u->faction->locale, "PARTEI %s 'Hodor!'", itoa36(u->faction->no)); + f = u->faction; + ord = create_order(K_MAIL, f->locale, "%s %s 'Hodor!'", LOC(f->locale, parameters[P_FACTION]), itoa36(u->faction->no)); mail_cmd(u, ord); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "regionmessage")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "regionmessage")); free_order(ord); test_cleanup(); } @@ -1155,9 +1134,11 @@ static void test_mail_faction(CuTest *tc) { static void test_mail_region(CuTest *tc) { order *ord; unit *u; + faction *f; u = setup_mail_cmd(); - ord = create_order(K_MAIL, u->faction->locale, "REGION 'Hodor!'", itoa36(u->no)); + f = u->faction; + ord = create_order(K_MAIL, f->locale, "%s 'Hodor!'", LOC(f->locale, parameters[P_REGION]), itoa36(u->no)); mail_cmd(u, ord); CuAssertPtrNotNull(tc, test_find_messagetype(u->region->msgs, "mail_result")); free_order(ord); @@ -1166,52 +1147,60 @@ static void test_mail_region(CuTest *tc) { static void test_mail_unit_no_msg(CuTest *tc) { unit *u; + faction *f; order *ord; u = setup_mail_cmd(); - ord = create_order(K_MAIL, u->faction->locale, "EINHEIT %s", itoa36(u->no)); + f = u->faction; + ord = create_order(K_MAIL, f->locale, "%s %s", LOC(f->locale, parameters[P_UNIT]), itoa36(u->no)); mail_cmd(u, ord); - CuAssertPtrEquals(tc, 0, test_find_messagetype(u->faction->msgs, "unitmessage")); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error30")); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "unitmessage")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error30")); free_order(ord); test_cleanup(); } static void test_mail_faction_no_msg(CuTest *tc) { unit *u; + faction *f; order *ord; u = setup_mail_cmd(); - ord = create_order(K_MAIL, u->faction->locale, "PARTEI %s", itoa36(u->faction->no)); + f = u->faction; + ord = create_order(K_MAIL, f->locale, "%s %s", LOC(f->locale, parameters[P_FACTION]), itoa36(f->no)); mail_cmd(u, ord); - CuAssertPtrEquals(tc, 0, test_find_messagetype(u->faction->msgs, "regionmessage")); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error30")); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "regionmessage")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error30")); free_order(ord); test_cleanup(); } static void test_mail_faction_no_target(CuTest *tc) { unit *u; + faction *f; order *ord; u = setup_mail_cmd(); - ord = create_order(K_MAIL, u->faction->locale, "PARTEI %s", itoa36(u->faction->no+1)); + f = u->faction; + ord = create_order(K_MAIL, f->locale, "%s %s", LOC(f->locale, parameters[P_FACTION]), itoa36(f->no+1)); mail_cmd(u, ord); - CuAssertPtrEquals(tc, 0, test_find_messagetype(u->faction->msgs, "regionmessage")); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error66")); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "regionmessage")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error66")); free_order(ord); test_cleanup(); } static void test_mail_region_no_msg(CuTest *tc) { unit *u; + faction *f; order *ord; u = setup_mail_cmd(); - ord = create_order(K_MAIL, u->faction->locale, "REGION"); + f = u->faction; + ord = create_order(K_MAIL, f->locale, LOC(f->locale, parameters[P_REGION])); mail_cmd(u, ord); CuAssertPtrEquals(tc, 0, test_find_messagetype(u->region->msgs, "mail_result")); - CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error30")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error30")); free_order(ord); test_cleanup(); } @@ -1236,27 +1225,27 @@ static void test_show_without_item(CuTest *tc) f = test_create_faction(test_create_race("human")); u = test_create_unit(f, r); - ord = create_order(K_RESHOW, u->faction->locale, "testname"); + ord = create_order(K_RESHOW, f->locale, "testname"); itype = it_get_or_create(rt_get_or_create("testitem")); i = i_new(itype, 1); reshow_cmd(u, ord); - CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error21") != NULL); - test_clear_messages(u->faction); + CuAssertTrue(tc, test_find_messagetype(f->msgs, "error21") != NULL); + test_clear_messages(f); locale_setstring(loc, "testitem", "testname"); locale_setstring(loc, "iteminfo::testitem", "testdescription"); reshow_cmd(u, ord); - CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error21") == NULL); - CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error36") != NULL); - test_clear_messages(u->faction); + CuAssertTrue(tc, test_find_messagetype(f->msgs, "error21") == NULL); + CuAssertTrue(tc, test_find_messagetype(f->msgs, "error36") != NULL); + test_clear_messages(f); i_add(&(u->items), i); reshow_cmd(u, ord); - CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error21") == NULL); - CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error36") == NULL); - test_clear_messages(u->faction); + CuAssertTrue(tc, test_find_messagetype(f->msgs, "error21") == NULL); + CuAssertTrue(tc, test_find_messagetype(f->msgs, "error36") == NULL); + test_clear_messages(f); free_order(ord); test_cleanup(); diff --git a/src/tests.c b/src/tests.c index 4efa71240..f6a798b7d 100644 --- a/src/tests.c +++ b/src/tests.c @@ -73,6 +73,7 @@ struct locale * test_create_locale(void) { if (!loc) { int i; loc = get_or_create_locale("test"); + locale_setstring(loc, "factiondefault", parameters[P_FACTION]); for (i = 0; i < MAXSKILLS; ++i) { if (!locale_getstring(loc, mkname("skill", skillnames[i]))) locale_setstring(loc, mkname("skill", skillnames[i]), skillnames[i]); @@ -85,7 +86,10 @@ struct locale * test_create_locale(void) { for (i = 0; i <= ST_FLEE; ++i) { locale_setstring(loc, combatstatus[i], combatstatus[i]+7); } - locale_setstring(loc, parameters[P_ANY], "ALLE"); + for (i = 0; i != MAXPARAMS; ++i) { + locale_setstring(loc, parameters[i], parameters[i]); + test_translate_param(loc, i, parameters[i]); + } init_parameters(loc); init_skills(loc); }