Default to reporting missing message types during tests as an error, grandfather in some tests with test_inject_messagetypes();

This commit is contained in:
Enno Rehling 2018-01-14 17:08:46 +01:00
parent 787abc90cf
commit 42e7e98ccf
9 changed files with 26 additions and 1 deletions

View File

@ -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;

View File

@ -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");

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -27,6 +27,10 @@
#include <string.h>
#include <assert.h>
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));

View File

@ -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();

View File

@ -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)