From eb8db3bfb94fa4ce7bd060c4a4211636134d1653 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 28 Aug 2016 18:08:52 +0100 Subject: [PATCH] test undead name generation. --- src/names.h | 5 ++++- src/names.test.c | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/names.h b/src/names.h index 17bb9a0e9..76e7c9497 100644 --- a/src/names.h +++ b/src/names.h @@ -21,7 +21,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifdef __cplusplus extern "C" { #endif - extern void register_names(void); + + struct unit; + typedef const char *(*name_func)(const struct unit *); + void register_names(void); const char *abkz(const char *s, char *buf, size_t size, size_t maxchars); #ifdef __cplusplus diff --git a/src/names.test.c b/src/names.test.c index 234346172..99c1663ed 100644 --- a/src/names.test.c +++ b/src/names.test.c @@ -2,6 +2,7 @@ #include "names.h" +#include #include #include @@ -9,9 +10,15 @@ static void test_names(CuTest * tc) { + name_func foo; test_cleanup(); register_names(); - CuAssertPtrNotNull(tc, get_function("nameundead")); + default_locale = test_create_locale(); + locale_setstring(default_locale, "undead_prefix_0", "Kleine"); + locale_setstring(default_locale, "undead_name_0", "Graue"); + locale_setstring(default_locale, "undead_postfix_0", "Kobolde"); + CuAssertPtrNotNull(tc, foo = (name_func)get_function("nameundead")); + CuAssertStrEquals(tc, "Kleine Graue Kobolde", foo(NULL)); CuAssertPtrNotNull(tc, get_function("nameskeleton")); CuAssertPtrNotNull(tc, get_function("namezombie")); CuAssertPtrNotNull(tc, get_function("nameghoul"));