forked from github/server
oh, I get it. reduceproduction signals that this volcano recently exploded.
added a test for outbreak and message
This commit is contained in:
parent
68f619cb90
commit
c3119e4c4a
|
@ -269,7 +269,7 @@ void volcano_update(void)
|
|||
rsetterrain(r, T_VOLCANO);
|
||||
}
|
||||
else {
|
||||
// TODO: this code path is inactive. are we only keeping it for old data? fix data instead.
|
||||
// TODO: is this code path inactive? are we only keeping it for old data? fix data instead.
|
||||
if (rng_int() % 100 < 12) {
|
||||
ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r));
|
||||
rsetterrain(r, T_VOLCANO);
|
||||
|
|
|
@ -15,14 +15,33 @@ static void test_volcano_update(CuTest *tc) {
|
|||
region *r;
|
||||
const struct terrain_type *t_volcano, *t_active;
|
||||
|
||||
test_cleanup();
|
||||
t_volcano = test_create_terrain("volcano", LAND_REGION);
|
||||
t_active = test_create_terrain("activevolcano", LAND_REGION);
|
||||
test_cleanup();
|
||||
r = test_create_region(0, 0, t_active);
|
||||
a_add(&r->attribs, make_reduceproduction(25, 10));
|
||||
|
||||
volcano_update();
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "volcanostopsmoke"));
|
||||
CuAssertPtrEquals(tc, (void *)t_volcano, (void *)r->terrain);
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_volcano_outbreak(CuTest *tc) {
|
||||
region *r;
|
||||
const struct terrain_type *t_volcano, *t_active;
|
||||
|
||||
test_cleanup();
|
||||
t_volcano = test_create_terrain("volcano", LAND_REGION);
|
||||
t_active = test_create_terrain("activevolcano", LAND_REGION);
|
||||
r = test_create_region(0, 0, t_active);
|
||||
|
||||
volcano_outbreak(r);
|
||||
CuAssertPtrEquals(tc, (void *)t_volcano, (void *)r->terrain);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(r->msgs, "volcanooutbreak"));
|
||||
CuAssertPtrNotNull(tc, a_find(r->attribs, &at_reduceproduction));
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
|
@ -30,5 +49,6 @@ CuSuite *get_volcano_suite(void)
|
|||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_volcano_update);
|
||||
SUITE_ADD_TEST(suite, test_volcano_outbreak);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue