From 2f7637f953662ffebed58e9f53a01aebdc6eda0d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Apr 2018 18:08:56 +0100 Subject: [PATCH] add a unit test for make_movement_order, too. --- src/move.test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/move.test.c b/src/move.test.c index 58dbc496b..07fde591c 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -654,6 +654,26 @@ static void test_movement_speed_dragon(CuTest *tc) { test_teardown(); } +static void test_make_movement_order(CuTest *tc) { + order *ord; + char buffer[32]; + struct locale *lang; + direction_t steps[] = { D_EAST, D_WEST, D_EAST, D_WEST }; + + test_setup(); + lang = test_create_locale(); + + ord = make_movement_order(lang, steps, 2); + CuAssertStrEquals(tc, "move east west", get_command(ord, lang, buffer, sizeof(buffer))); + free_order(ord); + + ord = make_movement_order(lang, steps, 4); + CuAssertStrEquals(tc, "move east west east west", get_command(ord, lang, buffer, sizeof(buffer))); + free_order(ord); + + test_teardown(); +} + CuSuite *get_move_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -684,5 +704,6 @@ CuSuite *get_move_suite(void) SUITE_ADD_TEST(suite, test_route_cycle); SUITE_ADD_TEST(suite, test_cycle_route); SUITE_ADD_TEST(suite, test_route_pause); + SUITE_ADD_TEST(suite, test_make_movement_order); return suite; }