diff --git a/src/alchemy.test.c b/src/alchemy.test.c index 32024ba1c..7510933fe 100644 --- a/src/alchemy.test.c +++ b/src/alchemy.test.c @@ -26,6 +26,7 @@ static void test_herbsearch(CuTest * tc) const item_type *itype; test_setup(); + test_inject_messagetypes(); r = test_create_region(0, 0, NULL); rc = rc_get_or_create("dragon"); rc->flags |= RCF_UNARMEDGUARD; diff --git a/src/items/xerewards.test.c b/src/items/xerewards.test.c index a027a8838..27c34b812 100644 --- a/src/items/xerewards.test.c +++ b/src/items/xerewards.test.c @@ -16,7 +16,9 @@ static void test_manacrystal(CuTest *tc) { struct item_type *itype; unit *u; + test_setup(); + test_inject_messagetypes(); u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL)); itype = test_create_itemtype("manacrystal"); @@ -47,6 +49,7 @@ static void test_skillpotion(CuTest *tc) { int initialWeeks_Magic = 0; test_setup(); + test_inject_messagetypes(); test_create_world(); u = test_create_unit(test_create_faction(NULL), findregion(0, 0)); itype = test_create_itemtype("skillpotion"); diff --git a/src/kernel/build.test.c b/src/kernel/build.test.c index 9d50fc9cc..eab2a6f00 100644 --- a/src/kernel/build.test.c +++ b/src/kernel/build.test.c @@ -30,6 +30,7 @@ typedef struct build_fixture { static unit * setup_build(build_fixture *bf) { test_setup(); + test_inject_messagetypes(); init_resources(); test_create_itemtype("stone"); @@ -309,6 +310,7 @@ static void test_build_destroy_road_guard(CuTest *tc) order *ord; test_setup(); + test_inject_messagetypes(); test_create_region(1, 0, 0); r = test_create_region(0, 0, NULL); rsetroad(r, D_EAST, 100); @@ -341,6 +343,7 @@ static void test_build_destroy_road_limit(CuTest *tc) order *ord; test_setup(); + test_inject_messagetypes(); test_create_region(1, 0, 0); r = test_create_region(0, 0, NULL); rsetroad(r, D_EAST, 100); diff --git a/src/kernel/curse.test.c b/src/kernel/curse.test.c index dc3603d50..9c74544e1 100644 --- a/src/kernel/curse.test.c +++ b/src/kernel/curse.test.c @@ -51,6 +51,7 @@ typedef struct { static void setup_curse(curse_fixture *fix, const char *name) { test_setup(); + test_inject_messagetypes(); fix->r = test_create_region(0, 0, NULL); fix->u = test_create_unit(test_create_faction(NULL), fix->r); fix->c = create_curse(fix->u, &fix->r->attribs, ct_find(name), 1.0, 1, 1.0, 0); diff --git a/src/kernel/spell.test.c b/src/kernel/spell.test.c index 7307e22a1..5502069d1 100644 --- a/src/kernel/spell.test.c +++ b/src/kernel/spell.test.c @@ -33,6 +33,7 @@ static void test_create_duplicate_spell(CuTest * tc) strlist *sl = 0; test_setup(); + test_inject_messagetypes(); test_log_stderr(0); /* suppress the "duplicate spell" error message */ log = test_log_start(LOG_CPERROR, &sl); diff --git a/src/reports.test.c b/src/reports.test.c index 05ef08d6a..ca0f98f57 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -788,6 +788,7 @@ static void test_insect_warnings(CuTest *tc) { /* OBS: in unit tests, get_gamedate always returns season = 0 */ test_setup(); + test_inject_messagetypes(); f = test_create_faction(test_create_race("insect")); gd.turn = 0; @@ -805,6 +806,7 @@ static void test_newbie_warning(CuTest *tc) { faction *f; test_setup(); + test_inject_messagetypes(); f = test_create_faction(test_create_race("insect")); config_set_int("NewbieImmunity", 3); diff --git a/src/spells.test.c b/src/spells.test.c index 426d82510..e151e7680 100644 --- a/src/spells.test.c +++ b/src/spells.test.c @@ -27,6 +27,10 @@ #include #include +static void setup_spells(void) { + test_inject_messagetypes(); +} + static void test_good_dreams(CuTest *tc) { struct region *r; struct faction *f1, *f2; @@ -36,6 +40,7 @@ static void test_good_dreams(CuTest *tc) { curse *curse; test_setup(); + setup_spells(); test_create_world(); r = findregion(0, 0); f1 = test_create_faction(NULL); @@ -65,6 +70,7 @@ static void test_dreams(CuTest *tc) { castorder co; test_setup(); + setup_spells(); r = test_create_region(0, 0, NULL); f1 = test_create_faction(NULL); f2 = test_create_faction(NULL); @@ -92,6 +98,7 @@ static void test_bad_dreams(CuTest *tc) { curse *curse; test_setup(); + setup_spells(); test_create_world(); r = findregion(0, 0); f1 = test_create_faction(NULL); @@ -122,6 +129,7 @@ static void test_view_reality(CuTest *tc) { castorder co; test_setup(); + setup_spells(); mt_register(mt_new_va("spell_astral_only", "unit:unit", "region:region", "command:order", NULL)); mt_register(mt_new_va("viewreality_effect", "unit:unit", NULL)); r = test_create_region(0, 0, NULL); @@ -155,6 +163,7 @@ static void test_watch_region(CuTest *tc) { region *r; faction *f; test_setup(); + setup_spells(); r = test_create_region(0, 0, NULL); f = test_create_faction(NULL); CuAssertIntEquals(tc, -1, get_observer(r, f)); diff --git a/src/tests.c b/src/tests.c index b6bed9bc4..18ecdef34 100644 --- a/src/tests.c +++ b/src/tests.c @@ -242,6 +242,11 @@ static void test_reset(void) { } } +void test_inject_messagetypes(void) +{ + message_handle_missing(MESSAGE_MISSING_REPLACE); +} + void test_setup_test(CuTest *tc, const char *file, int line) { test_log_stderr(LOG_CPERROR); test_reset(); diff --git a/src/tests.h b/src/tests.h index 61a896c3c..54764fd94 100644 --- a/src/tests.h +++ b/src/tests.h @@ -59,7 +59,6 @@ extern "C" { void test_create_castorder(struct castorder *co, struct unit *u, int level, float force, int range, struct spellparameter *par); struct spell * test_create_spell(void); - int RunAllTests(void); void test_translate_param(const struct locale *lang, param_t param, const char *text); const char * test_get_messagetype(const struct message *msg); struct message * test_find_messagetype_ex(struct message_list *msgs, const char *name, struct message *prev); @@ -74,6 +73,7 @@ extern "C" { void assert_string_parameter(struct CuTest * tc, struct message *msg, int index, const char *arg); void disabled_test(void *suite, void (*)(struct CuTest *), const char *name); + void test_inject_messagetypes(void); #define DISABLE_TEST(SUITE, TEST) disabled_test(SUITE, TEST, #TEST)