forked from github/server
test renumbering units and factions.
This commit is contained in:
parent
251c7bb559
commit
264fc0cb6f
|
@ -219,6 +219,7 @@ set(TESTS_SRC
|
||||||
move.test.c
|
move.test.c
|
||||||
piracy.test.c
|
piracy.test.c
|
||||||
prefix.test.c
|
prefix.test.c
|
||||||
|
renumber.test.c
|
||||||
skill.test.c
|
skill.test.c
|
||||||
spells.test.c
|
spells.test.c
|
||||||
spy.test.c
|
spy.test.c
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include "renumber.h"
|
||||||
|
|
||||||
|
#include <tests.h>
|
||||||
|
#include <kernel/unit.h>
|
||||||
|
#include <kernel/faction.h>
|
||||||
|
#include <kernel/order.h>
|
||||||
|
#include <util/base36.h>
|
||||||
|
#include <util/language.h>
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <CuTest.h>
|
||||||
|
|
||||||
|
static void test_renumber_faction(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
int uno, no;
|
||||||
|
const struct locale *lang;
|
||||||
|
|
||||||
|
test_setup_ex(tc);
|
||||||
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
no = u->faction->no;
|
||||||
|
uno = (no > 1) ? no - 1 : no + 1;
|
||||||
|
lang = u->faction->locale;
|
||||||
|
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_FACTION]), itoa36(uno));
|
||||||
|
renumber_cmd(u, u->thisorder);
|
||||||
|
renumber_factions();
|
||||||
|
CuAssertIntEquals(tc, uno, u->faction->no);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_renumber_unit(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
int uno, no;
|
||||||
|
const struct locale *lang;
|
||||||
|
|
||||||
|
test_setup_ex(tc);
|
||||||
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
no = u->no;
|
||||||
|
uno = (no > 1) ? no - 1 : no + 1;
|
||||||
|
lang = u->faction->locale;
|
||||||
|
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_UNIT]), itoa36(uno));
|
||||||
|
renumber_cmd(u, u->thisorder);
|
||||||
|
CuAssertIntEquals(tc, uno, u->no);
|
||||||
|
CuAssertIntEquals(tc, -no, ualias(u)); // TODO: why is ualias negative?
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
CuSuite *get_renumber_suite(void)
|
||||||
|
{
|
||||||
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
SUITE_ADD_TEST(suite, test_renumber_unit);
|
||||||
|
SUITE_ADD_TEST(suite, test_renumber_faction);
|
||||||
|
return suite;
|
||||||
|
}
|
|
@ -114,7 +114,6 @@ int RunAllTests(int argc, char *argv[])
|
||||||
ADD_SUITE(guard);
|
ADD_SUITE(guard);
|
||||||
ADD_SUITE(report);
|
ADD_SUITE(report);
|
||||||
ADD_SUITE(creport);
|
ADD_SUITE(creport);
|
||||||
ADD_SUITE(prefix);
|
|
||||||
ADD_SUITE(summary);
|
ADD_SUITE(summary);
|
||||||
ADD_SUITE(names);
|
ADD_SUITE(names);
|
||||||
ADD_SUITE(battle);
|
ADD_SUITE(battle);
|
||||||
|
@ -130,6 +129,8 @@ int RunAllTests(int argc, char *argv[])
|
||||||
ADD_SUITE(monsters);
|
ADD_SUITE(monsters);
|
||||||
ADD_SUITE(move);
|
ADD_SUITE(move);
|
||||||
ADD_SUITE(piracy);
|
ADD_SUITE(piracy);
|
||||||
|
ADD_SUITE(prefix);
|
||||||
|
ADD_SUITE(renumber);
|
||||||
ADD_SUITE(key);
|
ADD_SUITE(key);
|
||||||
ADD_SUITE(stealth);
|
ADD_SUITE(stealth);
|
||||||
ADD_SUITE(otherfaction);
|
ADD_SUITE(otherfaction);
|
||||||
|
|
Loading…
Reference in New Issue