Merge pull request #290 from ennorehling/develop

cleanup: disabled tests, findunitr compexity
This commit is contained in:
Enno Rehling 2015-09-09 13:35:05 +02:00
commit 91edb95bca
5 changed files with 15 additions and 24 deletions

View File

@ -57,15 +57,13 @@ static void test_get_direction_default(CuTest *tc) {
CuAssertIntEquals(tc, D_EAST, get_direction("east", lang)); CuAssertIntEquals(tc, D_EAST, get_direction("east", lang));
} }
#define SUITE_DISABLE_TEST(suite, test) (void)test
CuSuite *get_direction_suite(void) CuSuite *get_direction_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_init_direction); SUITE_ADD_TEST(suite, test_init_direction);
SUITE_ADD_TEST(suite, test_init_directions); SUITE_ADD_TEST(suite, test_init_directions);
SUITE_ADD_TEST(suite, test_finddirection); SUITE_ADD_TEST(suite, test_finddirection);
SUITE_DISABLE_TEST(suite, test_get_direction_default); DISABLE_TEST(suite, test_get_direction_default);
return suite; return suite;
} }

View File

@ -2640,8 +2640,9 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
return; return;
} }
id = read_unitid(u->faction, r); id = read_unitid(u->faction, r);
u2 = findunitr(r, id); if (id>0) {
u2 = findunitr(r, id);
}
if (u2 && u2->region == u->region) { if (u2 && u2->region == u->region) {
f = u2->faction; f = u2->faction;
} }

View File

@ -97,19 +97,6 @@ attrib_type at_creator = {
/* Rest ist NULL; temporaeres, nicht alterndes Attribut */ /* Rest ist NULL; temporaeres, nicht alterndes Attribut */
}; };
unit *findunitr(const region * r, int n)
{
unit *u;
/* findunit regional! */
for (u = r->units; u; u = u->next)
if (u->no == n)
return u;
return 0;
}
unit *findunit(int n) unit *findunit(int n)
{ {
if (n <= 0) { if (n <= 0) {
@ -118,6 +105,15 @@ unit *findunit(int n)
return ufindhash(n); return ufindhash(n);
} }
unit *findunitr(const region * r, int n)
{
unit *u;
/* findunit regional! */
assert(n>0);
u = ufindhash(n);
return (u && u->region==r)?u:0;
}
unit *findunitg(int n, const region * hint) unit *findunitg(int n, const region * hint)
{ {

View File

@ -93,8 +93,6 @@ static void test_get_shortest_match(CuTest *tc) {
test_cleanup(); test_cleanup();
} }
#define SUITE_DISABLE_TEST(suite, test) (void)test
CuSuite *get_keyword_suite(void) CuSuite *get_keyword_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
@ -103,6 +101,6 @@ CuSuite *get_keyword_suite(void)
SUITE_ADD_TEST(suite, test_init_keywords); SUITE_ADD_TEST(suite, test_init_keywords);
SUITE_ADD_TEST(suite, test_findkeyword); SUITE_ADD_TEST(suite, test_findkeyword);
SUITE_ADD_TEST(suite, test_get_shortest_match); SUITE_ADD_TEST(suite, test_get_shortest_match);
SUITE_DISABLE_TEST(suite, test_get_keyword_default); DISABLE_TEST(suite, test_get_keyword_default);
return suite; return suite;
} }

View File

@ -43,15 +43,13 @@ static void test_get_skill_default(CuTest *tc) {
CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("crossbow", lang)); CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("crossbow", lang));
} }
#define SUITE_DISABLE_TEST(suite, test) (void)test
CuSuite *get_skill_suite(void) CuSuite *get_skill_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_init_skill); SUITE_ADD_TEST(suite, test_init_skill);
SUITE_ADD_TEST(suite, test_init_skills); SUITE_ADD_TEST(suite, test_init_skills);
SUITE_ADD_TEST(suite, test_get_skill); SUITE_ADD_TEST(suite, test_get_skill);
SUITE_DISABLE_TEST(suite, test_get_skill_default); DISABLE_TEST(suite, test_get_skill_default);
return suite; return suite;
} }