diff --git a/src/economy.test.c b/src/economy.test.c index bbdd75df5..e7fb5e332 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -286,6 +286,9 @@ static void test_maintain_buildings(CuTest *tc) { maintain_buildings(r); CuAssertIntEquals(tc, BLD_MAINTAINED, fval(b, BLD_MAINTAINED)); CuAssertIntEquals(tc, 0, i_get(u->items, itype)); + CuAssertPtrEquals(tc, 0, r->msgs); + CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "maintenance_nowork")); + CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "maintenance")); test_clear_messages(f); // this building has no owner, it doesn't work: @@ -293,7 +296,7 @@ static void test_maintain_buildings(CuTest *tc) { b->flags = 0; maintain_buildings(r); CuAssertIntEquals(tc, 0, fval(b, BLD_MAINTAINED)); - CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "maintenance_nowork")); + CuAssertPtrEquals(tc, 0, f->msgs); CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "maintenance_noowner")); test_cleanup(); diff --git a/src/tests.c b/src/tests.c index 53f5ea470..177ad50fc 100644 --- a/src/tests.c +++ b/src/tests.c @@ -452,6 +452,14 @@ struct message * test_find_messagetype(struct message_list *msgs, const char *na return test_find_messagetype_ex(msgs, name, NULL); } +void test_clear_messagelist(message_list **msgs) { + if (*msgs) { + free_messagelist((*msgs)->begin); + free(*msgs); + *msgs = NULL; + } +} + void test_clear_messages(faction *f) { if (f->msgs) { free_messagelist(f->msgs->begin); diff --git a/src/tests.h b/src/tests.h index 10934c3d7..cbc2a2511 100644 --- a/src/tests.h +++ b/src/tests.h @@ -61,6 +61,7 @@ extern "C" { struct message * test_find_messagetype(struct message_list *msgs, const char *name); struct message * test_get_last_message(struct message_list *mlist); void test_clear_messages(struct faction *f); + void test_clear_messagelist(struct message_list **msgs); void assert_message(struct CuTest * tc, struct message *msg, char *name, int numpar); void assert_pointer_parameter(struct CuTest * tc, struct message *msg, int index, void *arg);