From b725e9676a260ea092d76c0b6800447258e10794 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 2 Sep 2016 09:29:52 +0200 Subject: [PATCH] simple test for basic unit descriptions --- src/kernel/unit.test.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c index dc0484bf7..1af197e15 100644 --- a/src/kernel/unit.test.c +++ b/src/kernel/unit.test.c @@ -387,10 +387,25 @@ static void test_limited_skills(CuTest *tc) { test_cleanup(); } +static void test_unit_description(CuTest *tc) { + race *rc; + unit *u; + test_setup(); + rc = test_create_race("hodor"); + u = test_create_unit(test_create_faction(rc), test_create_region(0,0,0)); + CuAssertPtrEquals(tc, 0, u->display); + CuAssertStrEquals(tc, 0, u_description(u, u->faction->locale)); + u->display = _strdup("Hodor"); + CuAssertStrEquals(tc, "Hodor", u_description(u, NULL)); + CuAssertStrEquals(tc, "Hodor", u_description(u, u->faction->locale)); + test_cleanup(); +} + CuSuite *get_unit_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_scale_number); + SUITE_ADD_TEST(suite, test_unit_description); SUITE_ADD_TEST(suite, test_unit_name); SUITE_ADD_TEST(suite, test_unit_name_from_race); SUITE_ADD_TEST(suite, test_update_monster_name);