test that regular guards need weapons and skills

This commit is contained in:
Enno Rehling 2016-10-26 11:55:31 +02:00
parent 7c827c0389
commit 29c5bd6f55
1 changed files with 41 additions and 0 deletions

View File

@ -15,6 +15,45 @@
#include <CuTest.h>
#include "tests.h"
static void test_guard_unskilled(CuTest * tc)
// TODO: it would be better to test armedmen()
{
unit *u, *ug;
region *r;
item_type *itype;
test_setup();
itype = it_get_or_create(rt_get_or_create("sword"));
new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2);
r = test_create_region(0, 0, 0);
u = test_create_unit(test_create_faction(0), r);
ug = test_create_unit(test_create_faction(0), r);
i_change(&ug->items, itype, 1);
set_level(ug, SK_MELEE, 1);
setguard(ug, GUARD_ALL);
CuAssertPtrEquals(tc, 0, is_guarded(r, u, GUARD_PRODUCE));
test_cleanup();
}
static void test_guard_armed(CuTest * tc)
{
unit *u, *ug;
region *r;
item_type *itype;
test_setup();
itype = it_get_or_create(rt_get_or_create("sword"));
new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2);
r = test_create_region(0, 0, 0);
u = test_create_unit(test_create_faction(0), r);
ug = test_create_unit(test_create_faction(0), r);
i_change(&ug->items, itype, 1);
set_level(ug, SK_MELEE, 2);
setguard(ug, GUARD_ALL);
CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE));
test_cleanup();
}
static void test_guard_unarmed(CuTest * tc)
{
unit *u, *ug;
@ -49,6 +88,8 @@ static void test_guard_monsters(CuTest * tc)
CuSuite *get_guard_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_guard_unskilled);
SUITE_ADD_TEST(suite, test_guard_armed);
SUITE_ADD_TEST(suite, test_guard_unarmed);
SUITE_ADD_TEST(suite, test_guard_monsters);
return suite;