forked from github/server
additional tests for cansee, to support fixing bug 2374
This commit is contained in:
parent
018f217e4d
commit
a0a39124f0
2
clibs
2
clibs
|
@ -1 +1 @@
|
||||||
Subproject commit d286006a28c8aa7cd70ed7fd4cd172b50ade9727
|
Subproject commit 147584ad70b220abf6a4e97ca76e785729b9ac32
|
|
@ -1552,6 +1552,90 @@ static void test_armedmen(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_cansee(CuTest *tc) {
|
||||||
|
unit *u, *u2;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
u2 = test_create_unit(test_create_faction(0), u->region);
|
||||||
|
|
||||||
|
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
set_level(u2, SK_STEALTH, 1);
|
||||||
|
CuAssertTrue(tc, !cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
set_level(u, SK_PERCEPTION, 1);
|
||||||
|
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_cansee_ring(CuTest *tc) {
|
||||||
|
unit *u, *u2;
|
||||||
|
item_type *itype[2];
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
u2 = test_create_unit(test_create_faction(0), u->region);
|
||||||
|
scale_number(u2, 2);
|
||||||
|
|
||||||
|
itype[0] = test_create_itemtype("roi");
|
||||||
|
itype[1] = test_create_itemtype("aots");
|
||||||
|
CuAssertPtrNotNull(tc, get_resourcetype(R_RING_OF_INVISIBILITY));
|
||||||
|
CuAssertPtrEquals(tc, itype[0]->rtype, (void *)get_resourcetype(R_RING_OF_INVISIBILITY));
|
||||||
|
CuAssertPtrNotNull(tc, get_resourcetype(R_AMULET_OF_TRUE_SEEING));
|
||||||
|
CuAssertPtrEquals(tc, itype[1]->rtype, (void *)get_resourcetype(R_AMULET_OF_TRUE_SEEING));
|
||||||
|
|
||||||
|
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
/* a single ring is not enough to hide two people */
|
||||||
|
i_change(&u2->items, itype[0], 1);
|
||||||
|
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
/* two rings can hide two people */
|
||||||
|
i_change(&u2->items, itype[0], 1);
|
||||||
|
CuAssertTrue(tc, !cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
/* one amulet negates one of the two rings */
|
||||||
|
i_change(&u->items, itype[1], 1);
|
||||||
|
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_cansee_sphere(CuTest *tc) {
|
||||||
|
unit *u, *u2;
|
||||||
|
item_type *itype[2];
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
u2 = test_create_unit(test_create_faction(0), u->region);
|
||||||
|
|
||||||
|
itype[0] = test_create_itemtype("sphereofinv");
|
||||||
|
itype[1] = test_create_itemtype("aots");
|
||||||
|
CuAssertPtrNotNull(tc, get_resourcetype(R_SPHERE_OF_INVISIBILITY));
|
||||||
|
CuAssertPtrEquals(tc, itype[0]->rtype, (void *)get_resourcetype(R_SPHERE_OF_INVISIBILITY));
|
||||||
|
CuAssertPtrNotNull(tc, get_resourcetype(R_AMULET_OF_TRUE_SEEING));
|
||||||
|
CuAssertPtrEquals(tc, itype[1]->rtype, (void *)get_resourcetype(R_AMULET_OF_TRUE_SEEING));
|
||||||
|
|
||||||
|
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
/* a single sphere can hide 100 people */
|
||||||
|
scale_number(u2, 100);
|
||||||
|
i_change(&u2->items, itype[0], 1);
|
||||||
|
CuAssertTrue(tc, !cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
/* one single amulet negates it? */
|
||||||
|
i_change(&u->items, itype[1], 1);
|
||||||
|
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
/* number of people inside the sphere does not matter? */
|
||||||
|
scale_number(u2, 99);
|
||||||
|
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_laws_suite(void)
|
CuSuite *get_laws_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -1618,6 +1702,9 @@ CuSuite *get_laws_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_immigration);
|
SUITE_ADD_TEST(suite, test_immigration);
|
||||||
SUITE_ADD_TEST(suite, test_demon_hunger);
|
SUITE_ADD_TEST(suite, test_demon_hunger);
|
||||||
SUITE_ADD_TEST(suite, test_armedmen);
|
SUITE_ADD_TEST(suite, test_armedmen);
|
||||||
|
SUITE_ADD_TEST(suite, test_cansee);
|
||||||
|
SUITE_ADD_TEST(suite, test_cansee_ring);
|
||||||
|
SUITE_ADD_TEST(suite, test_cansee_sphere);
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue