From 3937cbc7b582ac3554acb5bb30d7eb85252ffca5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 8 Apr 2016 21:44:06 +0200 Subject: [PATCH] add missing file, test that command.c does what it's meant to do. --- src/kernel/command.test.c | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/kernel/command.test.c diff --git a/src/kernel/command.test.c b/src/kernel/command.test.c new file mode 100644 index 000000000..af1015ea4 --- /dev/null +++ b/src/kernel/command.test.c @@ -0,0 +1,52 @@ +/* + +-------------------+ Christian Schlittchen + | | Enno Rehling + | Eressea PBEM host | Katja Zedel + | (c) 1998 - 2003 | Henning Peters + | | Ingo Wilken + +-------------------+ Stefan Reich + + This program may not be used, modified or distributed + without prior permission by the authors of Eressea. + + */ +#include "command.h" +#include "unit.h" +#include "order.h" + +#include +#include + +static void parser_scale(const void *nodes, struct unit * u, struct order *ord) { + scale_number(u, 2); +} + +static void test_command(CuTest * tc) { + struct syntaxtree *st; + struct locale * loc; + unit *u; + + test_cleanup(); + loc = test_create_locale(); + st = stree_create(); + CuAssertPtrNotNull(tc, st); + CuAssertPtrEquals(tc, loc, (struct locale *)st->lang); + CuAssertPtrEquals(tc, 0, st->root); + CuAssertPtrEquals(tc, 0, st->next); + add_command(&st->root, 0, "scale", parser_scale); + CuAssertPtrNotNull(tc, st->root); + CuAssertPtrEquals(tc, st->root, stree_find(st, loc)); + u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); + u->thisorder = create_order(K_ALLIANCE, loc, "scale"); + do_command(st->root, u, u->thisorder); + CuAssertIntEquals(tc, u->number, 2); + stree_free(st); + test_cleanup(); +} + +CuSuite *get_command_suite(void) +{ + CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_command); + return suite; +} \ No newline at end of file