server/src/stealth.test.c
Enno Rehling a9a0455207 reorganized directory structure.
flattening the directory structure, moving some modules to the src/ directory.
making stealth a separate file, under test.
more tests for some stuff.
2014-08-27 06:40:35 +02:00

40 lines
1 KiB
C

#include <platform.h>
#include "stealth.h"
#include <kernel/unit.h>
#include <kernel/region.h>
#include <CuTest.h>
#include <tests.h>
#include <stdlib.h>
#include <assert.h>
void test_stealth(CuTest *tc) {
unit *u;
test_cleanup();
test_create_world();
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
set_level(u, SK_STEALTH, 2);
CuAssertIntEquals(tc, -1, u_geteffstealth(u));
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
u_seteffstealth(u, 3);
CuAssertIntEquals(tc, 3, u_geteffstealth(u));
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
u_seteffstealth(u, 1);
CuAssertIntEquals(tc, 1, u_geteffstealth(u));
CuAssertIntEquals(tc, 1, eff_stealth(u, u->region));
u_seteffstealth(u, -1);
CuAssertIntEquals(tc, -1, u_geteffstealth(u));
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
test_cleanup();
}
CuSuite *get_stealth_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_stealth);
return suite;
}