test undead name generation.

This commit is contained in:
Enno Rehling 2016-08-28 18:08:52 +01:00
parent 020ab942ec
commit eb8db3bfb9
2 changed files with 12 additions and 2 deletions

View file

@ -21,7 +21,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #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); const char *abkz(const char *s, char *buf, size_t size, size_t maxchars);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -2,6 +2,7 @@
#include "names.h" #include "names.h"
#include <util/language.h>
#include <util/functions.h> #include <util/functions.h>
#include <CuTest.h> #include <CuTest.h>
@ -9,9 +10,15 @@
static void test_names(CuTest * tc) static void test_names(CuTest * tc)
{ {
name_func foo;
test_cleanup(); test_cleanup();
register_names(); 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("nameskeleton"));
CuAssertPtrNotNull(tc, get_function("namezombie")); CuAssertPtrNotNull(tc, get_function("namezombie"));
CuAssertPtrNotNull(tc, get_function("nameghoul")); CuAssertPtrNotNull(tc, get_function("nameghoul"));