From 5c63d20ff7e7897ec0b358cf0ae139790447c24b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 30 Sep 2017 19:35:40 +0200 Subject: [PATCH] fix remaining bugs --- src/kernel/messages.test.c | 2 +- src/kernel/order.test.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/kernel/messages.test.c b/src/kernel/messages.test.c index 997abc704..a26530895 100644 --- a/src/kernel/messages.test.c +++ b/src/kernel/messages.test.c @@ -80,7 +80,7 @@ static void test_noerror(CuTest *tc) { u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL)); u->thisorder = parse_order("!@move", lang); CuAssertIntEquals(tc, K_MOVE | CMD_QUIET | CMD_PERSIST, u->thisorder->command); - CuAssertTrue(tc, is_persistent(u->thisorder)); + CuAssertTrue(tc, !is_persistent(u->thisorder)); CuAssertPtrEquals(tc, NULL, msg_error(u, u->thisorder, 100)); CuAssertPtrEquals(tc, NULL, msg_feedback(u, u->thisorder, "error_unit_not_found", NULL)); test_cleanup(); diff --git a/src/kernel/order.test.c b/src/kernel/order.test.c index d813542d2..b42c7bf74 100644 --- a/src/kernel/order.test.c +++ b/src/kernel/order.test.c @@ -224,6 +224,29 @@ static void test_get_command(CuTest *tc) { test_cleanup(); } +static void test_is_persistent(CuTest *tc) { + order *ord; + struct locale *lang; + + test_setup(); + lang = test_create_locale(); + + ord = parse_order("@move", lang); + CuAssertIntEquals(tc, K_MOVE | CMD_PERSIST, ord->command); + CuAssertTrue(tc, !is_persistent(ord)); + free_order(ord); + + ord = parse_order("@invalid", lang); + CuAssertPtrEquals(tc, NULL, ord); + + ord = parse_order("// comment", lang); + CuAssertTrue(tc, is_persistent(ord)); + CuAssertIntEquals(tc, K_KOMMENTAR, ord->command); + free_order(ord); + + test_cleanup(); +} + CuSuite *get_order_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -237,5 +260,6 @@ CuSuite *get_order_suite(void) SUITE_ADD_TEST(suite, test_skip_token); SUITE_ADD_TEST(suite, test_getstrtoken); SUITE_ADD_TEST(suite, test_get_command); + SUITE_ADD_TEST(suite, test_is_persistent); return suite; }