add some flavor, make sure the correct command is executed when there's more than one.

This commit is contained in:
Enno Rehling 2016-04-08 21:46:08 +02:00
parent 3937cbc7b5
commit 8965edfacb
1 changed files with 8 additions and 3 deletions

View File

@ -17,10 +17,14 @@
#include <CuTest.h> #include <CuTest.h>
#include <tests.h> #include <tests.h>
static void parser_scale(const void *nodes, struct unit * u, struct order *ord) { static void parser_two(const void *nodes, struct unit * u, struct order *ord) {
scale_number(u, 2); scale_number(u, 2);
} }
static void parser_six(const void *nodes, struct unit * u, struct order *ord) {
scale_number(u, 6);
}
static void test_command(CuTest * tc) { static void test_command(CuTest * tc) {
struct syntaxtree *st; struct syntaxtree *st;
struct locale * loc; struct locale * loc;
@ -33,11 +37,12 @@ static void test_command(CuTest * tc) {
CuAssertPtrEquals(tc, loc, (struct locale *)st->lang); CuAssertPtrEquals(tc, loc, (struct locale *)st->lang);
CuAssertPtrEquals(tc, 0, st->root); CuAssertPtrEquals(tc, 0, st->root);
CuAssertPtrEquals(tc, 0, st->next); CuAssertPtrEquals(tc, 0, st->next);
add_command(&st->root, 0, "scale", parser_scale); add_command(&st->root, 0, "two", parser_two);
add_command(&st->root, 0, "six", parser_six);
CuAssertPtrNotNull(tc, st->root); CuAssertPtrNotNull(tc, st->root);
CuAssertPtrEquals(tc, st->root, stree_find(st, loc)); CuAssertPtrEquals(tc, st->root, stree_find(st, loc));
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0)); u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
u->thisorder = create_order(K_ALLIANCE, loc, "scale"); u->thisorder = create_order(K_ALLIANCE, loc, "two");
do_command(st->root, u, u->thisorder); do_command(st->root, u, u->thisorder);
CuAssertIntEquals(tc, u->number, 2); CuAssertIntEquals(tc, u->number, 2);
stree_free(st); stree_free(st);