From 6bf2ac34e3b4d880f4d9ed5e0e93723107b57da0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 25 Sep 2017 22:04:16 +0200 Subject: [PATCH] test that whitespace is ignored when parsing orders --- src/kernel/order.h | 14 +++++++------- src/kernel/order.test.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/kernel/order.h b/src/kernel/order.h index bf4d02982..9ad3aabd8 100644 --- a/src/kernel/order.h +++ b/src/kernel/order.h @@ -41,17 +41,17 @@ extern "C" { } order; /* constructor */ - extern order *create_order(keyword_t kwd, const struct locale *lang, + order *create_order(keyword_t kwd, const struct locale *lang, const char *params, ...); - extern order *parse_order(const char *s, const struct locale *lang); - extern void replace_order(order ** dst, order * orig, const order * src); + order *parse_order(const char *s, const struct locale *lang); + void replace_order(order ** dst, order * orig, const order * src); /* reference counted copies of orders: */ - extern order *copy_order(const order * ord); - extern void free_order(order * ord); - extern void free_orders(order ** olist); + order *copy_order(const order * ord); + void free_order(order * ord); + void free_orders(order ** olist); - extern void push_order(struct order **olist, struct order *ord); + void push_order(struct order **olist, struct order *ord); /* access functions for orders */ keyword_t getkeyword(const order * ord); diff --git a/src/kernel/order.test.c b/src/kernel/order.test.c index 876d75b1e..124d0d889 100644 --- a/src/kernel/order.test.c +++ b/src/kernel/order.test.c @@ -49,24 +49,40 @@ static void test_parse_order(CuTest *tc) { ord = parse_order("!MOVE NORTH", lang); CuAssertPtrNotNull(tc, ord); + CuAssertPtrNotNull(tc, ord->data); + CuAssertIntEquals(tc, K_MOVE, getkeyword(ord)); CuAssertTrue(tc, ord->_noerror); CuAssertTrue(tc, !ord->_persistent); free_order(ord); ord = parse_order("@MOVE NORTH", lang); CuAssertPtrNotNull(tc, ord); + CuAssertPtrNotNull(tc, ord->data); + CuAssertIntEquals(tc, K_MOVE, getkeyword(ord)); CuAssertTrue(tc, !ord->_noerror); CuAssertTrue(tc, ord->_persistent); free_order(ord); ord = parse_order("@!MOVE NORTH", lang); CuAssertPtrNotNull(tc, ord); + CuAssertPtrNotNull(tc, ord->data); + CuAssertIntEquals(tc, K_MOVE, getkeyword(ord)); CuAssertTrue(tc, ord->_noerror); CuAssertTrue(tc, ord->_persistent); free_order(ord); ord = parse_order("!@MOVE NORTH", lang); CuAssertPtrNotNull(tc, ord); + CuAssertPtrNotNull(tc, ord->data); + CuAssertIntEquals(tc, K_MOVE, getkeyword(ord)); + CuAssertTrue(tc, ord->_noerror); + CuAssertTrue(tc, ord->_persistent); + free_order(ord); + + ord = parse_order(" !@MOVE NORTH", lang); + CuAssertPtrNotNull(tc, ord); + CuAssertPtrNotNull(tc, ord->data); + CuAssertIntEquals(tc, K_MOVE, getkeyword(ord)); CuAssertTrue(tc, ord->_noerror); CuAssertTrue(tc, ord->_persistent); free_order(ord);