2016-04-08 21:44:06 +02:00
|
|
|
/*
|
|
|
|
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
|
|
| | Enno Rehling <enno@eressea.de>
|
|
|
|
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
|
|
|
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
|
|
|
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
|
|
|
+-------------------+ Stefan Reich <reich@halbling.de>
|
|
|
|
|
|
|
|
This program may not be used, modified or distributed
|
|
|
|
without prior permission by the authors of Eressea.
|
|
|
|
|
|
|
|
*/
|
2017-01-10 18:20:47 +01:00
|
|
|
#include <platform.h>
|
2016-04-08 21:44:06 +02:00
|
|
|
#include "command.h"
|
2017-01-10 18:20:47 +01:00
|
|
|
|
2016-04-08 21:44:06 +02:00
|
|
|
#include "unit.h"
|
|
|
|
#include "order.h"
|
|
|
|
|
|
|
|
#include <CuTest.h>
|
|
|
|
#include <tests.h>
|
|
|
|
|
2016-04-08 21:46:08 +02:00
|
|
|
static void parser_two(const void *nodes, struct unit * u, struct order *ord) {
|
2016-04-08 21:44:06 +02:00
|
|
|
scale_number(u, 2);
|
|
|
|
}
|
|
|
|
|
2016-04-08 21:46:08 +02:00
|
|
|
static void parser_six(const void *nodes, struct unit * u, struct order *ord) {
|
|
|
|
scale_number(u, 6);
|
|
|
|
}
|
|
|
|
|
2016-04-08 21:44:06 +02:00
|
|
|
static void test_command(CuTest * tc) {
|
|
|
|
struct syntaxtree *st;
|
|
|
|
struct locale * loc;
|
|
|
|
unit *u;
|
|
|
|
|
2017-11-09 20:17:06 +01:00
|
|
|
test_setup();
|
2016-04-08 21:44:06 +02:00
|
|
|
loc = test_create_locale();
|
|
|
|
st = stree_create();
|
|
|
|
CuAssertPtrNotNull(tc, st);
|
|
|
|
CuAssertPtrEquals(tc, loc, (struct locale *)st->lang);
|
2018-10-14 11:48:21 +02:00
|
|
|
CuAssertPtrEquals(tc, NULL, st->root);
|
|
|
|
CuAssertPtrEquals(tc, NULL, st->next);
|
2016-09-07 17:39:54 +02:00
|
|
|
stree_add(st, "two", parser_two);
|
|
|
|
stree_add(st, "six", parser_six);
|
2016-04-08 21:44:06 +02:00
|
|
|
CuAssertPtrNotNull(tc, st->root);
|
|
|
|
CuAssertPtrEquals(tc, st->root, stree_find(st, loc));
|
2018-01-14 09:38:26 +01:00
|
|
|
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
2016-04-08 21:46:08 +02:00
|
|
|
u->thisorder = create_order(K_ALLIANCE, loc, "two");
|
2016-04-08 21:44:06 +02:00
|
|
|
do_command(st->root, u, u->thisorder);
|
|
|
|
CuAssertIntEquals(tc, u->number, 2);
|
|
|
|
stree_free(st);
|
2017-12-27 19:58:39 +01:00
|
|
|
test_teardown();
|
2016-04-08 21:44:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CuSuite *get_command_suite(void)
|
|
|
|
{
|
|
|
|
CuSuite *suite = CuSuiteNew();
|
|
|
|
SUITE_ADD_TEST(suite, test_command);
|
|
|
|
return suite;
|
2016-09-07 15:43:04 +02:00
|
|
|
}
|