forked from github/server
disable the missing_message replacement used in so many tests. fix some tests so they don't need it.
This commit is contained in:
parent
9dbe1d65b2
commit
98678d9fb2
|
@ -726,6 +726,7 @@ message *cinfo_simple(const void *obj, objtype_t typ, const struct curse * c,
|
|||
UNUSED_ARG(obj);
|
||||
|
||||
msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
|
||||
/* TODO: this is never NULL, because of the missing_message logic (used in many tests) */
|
||||
if (msg == NULL) {
|
||||
log_error("There is no curseinfo for %s.\n", c->type->cname);
|
||||
}
|
||||
|
|
|
@ -161,12 +161,14 @@ message *msg_message(const char *name, const char *sig, ...)
|
|||
|
||||
if (!mtype) {
|
||||
log_warning("trying to create message of unknown type \"%s\"\n", name);
|
||||
#if 0
|
||||
if (strcmp(name, "missing_message") != 0) {
|
||||
if (!mt_find("missing_message")) {
|
||||
mt_register(mt_new_va("missing_message", "name:string", 0));
|
||||
}
|
||||
return msg_message("missing_message", "name", name);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -255,9 +255,9 @@ static void test_force_leave_buildings(CuTest *tc) {
|
|||
region *r;
|
||||
unit *u1, *u2, *u3;
|
||||
building * b;
|
||||
message *msg;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("force_leave_building", "unit:unit", "owner:unit", "building:building", NULL));
|
||||
r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(u1->faction, r);
|
||||
|
@ -271,8 +271,7 @@ static void test_force_leave_buildings(CuTest *tc) {
|
|||
CuAssertPtrEquals_Msg(tc, "owner should not be forced to leave", b, u1->building);
|
||||
CuAssertPtrEquals_Msg(tc, "same faction should not be forced to leave", b, u2->building);
|
||||
CuAssertPtrEquals_Msg(tc, "non-allies should be forced to leave", NULL, u3->building);
|
||||
msg = test_get_last_message(u3->faction->msgs);
|
||||
CuAssertStrEquals(tc, "force_leave_building", test_get_messagetype(msg));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u3->faction->msgs, "force_leave_building"));
|
||||
|
||||
u_set_building(u3, b);
|
||||
al = ally_add(&u1->faction->allies, u3->faction);
|
||||
|
@ -286,9 +285,9 @@ static void test_force_leave_ships(CuTest *tc) {
|
|||
region *r;
|
||||
unit *u1, *u2;
|
||||
ship *sh;
|
||||
message *msg;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("force_leave_ship", "unit:unit", "owner:unit", "ship:ship", NULL));
|
||||
r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
|
@ -298,8 +297,7 @@ static void test_force_leave_ships(CuTest *tc) {
|
|||
ship_set_owner(u1);
|
||||
force_leave(r, NULL);
|
||||
CuAssertPtrEquals_Msg(tc, "non-allies should be forced to leave", NULL, u2->ship);
|
||||
msg = test_get_last_message(u2->faction->msgs);
|
||||
CuAssertStrEquals(tc, "force_leave_ship", test_get_messagetype(msg));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u2->faction->msgs, "force_leave_ship"));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
|
@ -1590,9 +1588,9 @@ static void test_demon_hunger(CuTest * tc)
|
|||
race *rc;
|
||||
faction *f;
|
||||
unit *u;
|
||||
message* msg;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("malnourish", "unit:unit", "region:region", NULL));
|
||||
init_resources();
|
||||
r = test_create_region(0, 0, 0);
|
||||
rc = test_create_race("demon");
|
||||
|
@ -1617,8 +1615,7 @@ static void test_demon_hunger(CuTest * tc)
|
|||
get_food(r);
|
||||
|
||||
CuAssertIntEquals(tc, 10, i_get(u->items, rtype->itype));
|
||||
msg = test_get_last_message(u->faction->msgs);
|
||||
CuAssertStrEquals(tc, "malnourish", test_get_messagetype(msg));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "malnourish"));
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
|
|
@ -279,6 +279,10 @@ void setup_drift (struct drift_fixture *fix) {
|
|||
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
|
||||
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
|
||||
assert(fix->sh);
|
||||
|
||||
mt_register(mt_new_va("ship_drift", "ship:ship", "dir:int", 0));
|
||||
mt_register(mt_new_va("shipsink", "ship:ship", 0));
|
||||
mt_register(mt_new_va("massive_overload", "ship:ship", 0));
|
||||
}
|
||||
|
||||
static void test_ship_no_overload(CuTest *tc) {
|
||||
|
|
|
@ -84,6 +84,9 @@ static void test_sabotage_self(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("sink_msg", "ship:ship", "region:region", 0));
|
||||
mt_register(mt_new_va("sink_lost_msg", "unit:unit", "region:region", "dead:int", 0));
|
||||
mt_register(mt_new_va("sink_saved_msg", "unit:unit", "region:region", 0));
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
|
@ -94,6 +97,7 @@ static void test_sabotage_self(CuTest *tc) {
|
|||
assert(ord);
|
||||
CuAssertIntEquals(tc, 0, sabotage_cmd(u, ord));
|
||||
CuAssertPtrEquals(tc, 0, r->ships);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "sink_msg"));
|
||||
free_order(ord);
|
||||
test_teardown();
|
||||
}
|
||||
|
@ -106,6 +110,11 @@ static void test_sabotage_other_fail(CuTest *tc) {
|
|||
message *msg;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("destroy_ship_0", "unit:unit", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_1", "unit:unit", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_2", "unit:unit", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_3", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_4", "ship:ship", 0));
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
|
@ -189,6 +198,9 @@ static void test_sabotage_other_success(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("sink_msg", "ship:ship", "region:region", 0));
|
||||
mt_register(mt_new_va("sink_lost_msg", "unit:unit", "region:region", "dead:int", 0));
|
||||
mt_register(mt_new_va("sink_saved_msg", "unit:unit", "region:region", 0));
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
|
|
|
@ -625,6 +625,8 @@ static void test_teach_message(CuTest *tc) {
|
|||
teaching_info *teach;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("teach_teacher", "teacher:unit", "student:unit", "skill:int", "level:int", 0));
|
||||
mt_register(mt_new_va("teach_student", "teacher:unit", "student:unit", "skill:int", 0));
|
||||
init_resources();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
scale_number(u, 20);
|
||||
|
|
|
@ -243,7 +243,7 @@ void msg_free(message * msg)
|
|||
|
||||
void msg_release(struct message *msg)
|
||||
{
|
||||
assert(msg->refcount > 0);
|
||||
assert(msg && msg->refcount > 0);
|
||||
if (--msg->refcount > 0)
|
||||
return;
|
||||
msg_free(msg);
|
||||
|
@ -251,7 +251,7 @@ void msg_release(struct message *msg)
|
|||
|
||||
struct message *msg_addref(struct message *msg)
|
||||
{
|
||||
assert(msg->refcount > 0);
|
||||
assert(msg && msg->refcount > 0);
|
||||
++msg->refcount;
|
||||
return msg;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue