2016-08-28 18:37:08 +02:00
|
|
|
#include <platform.h>
|
|
|
|
|
|
|
|
#include "names.h"
|
|
|
|
|
2016-08-28 19:15:00 +02:00
|
|
|
#include <kernel/race.h>
|
2016-08-28 21:27:40 +02:00
|
|
|
#include <kernel/unit.h>
|
2016-08-28 19:08:52 +02:00
|
|
|
#include <util/language.h>
|
2016-08-28 18:37:08 +02:00
|
|
|
#include <util/functions.h>
|
|
|
|
|
|
|
|
#include <CuTest.h>
|
|
|
|
#include "tests.h"
|
|
|
|
|
|
|
|
static void test_names(CuTest * tc)
|
|
|
|
{
|
2016-08-28 19:15:00 +02:00
|
|
|
race_name_func foo;
|
2016-08-28 21:27:40 +02:00
|
|
|
unit *u;
|
|
|
|
race *rc;
|
2016-08-28 18:37:08 +02:00
|
|
|
test_cleanup();
|
|
|
|
register_names();
|
2016-08-28 19:08:52 +02:00
|
|
|
default_locale = test_create_locale();
|
2016-08-28 21:27:40 +02:00
|
|
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
|
|
|
rc = test_create_race("undead");
|
2016-08-28 19:08:52 +02:00
|
|
|
locale_setstring(default_locale, "undead_name_0", "Graue");
|
|
|
|
locale_setstring(default_locale, "undead_postfix_0", "Kobolde");
|
2016-08-28 19:15:00 +02:00
|
|
|
CuAssertPtrNotNull(tc, foo = (race_name_func)get_function("nameundead"));
|
2016-08-28 21:27:40 +02:00
|
|
|
rc->generate_name = foo;
|
2016-12-31 20:03:50 +01:00
|
|
|
rc->generate_name(u);
|
2016-08-28 21:27:40 +02:00
|
|
|
CuAssertStrEquals(tc, "Graue Kobolde", u->_name);
|
2016-08-28 18:37:08 +02:00
|
|
|
CuAssertPtrNotNull(tc, get_function("nameskeleton"));
|
|
|
|
CuAssertPtrNotNull(tc, get_function("namezombie"));
|
|
|
|
CuAssertPtrNotNull(tc, get_function("nameghoul"));
|
|
|
|
CuAssertPtrNotNull(tc, get_function("namedragon"));
|
|
|
|
CuAssertPtrNotNull(tc, get_function("namedracoid"));
|
|
|
|
CuAssertPtrNotNull(tc, get_function("namegeneric"));
|
2016-08-28 21:44:09 +02:00
|
|
|
CuAssertPtrNotNull(tc, get_function("describe_race"));
|
2016-08-28 18:37:08 +02:00
|
|
|
test_cleanup();
|
|
|
|
}
|
|
|
|
|
2016-12-31 20:12:13 +01:00
|
|
|
static void test_monster_names(CuTest *tc) {
|
|
|
|
unit *u;
|
|
|
|
race *rc;
|
|
|
|
|
|
|
|
test_setup();
|
|
|
|
register_names();
|
|
|
|
rc = test_create_race("irongolem");
|
|
|
|
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
|
|
|
|
CuAssertPtrNotNull(tc, u->_name);
|
|
|
|
rc->generate_name = (race_name_func)get_function("namegeneric");
|
|
|
|
rc->generate_name(u);
|
|
|
|
CuAssertPtrEquals(tc, 0, u->_name);
|
|
|
|
test_cleanup();
|
|
|
|
}
|
|
|
|
|
2016-08-28 18:37:08 +02:00
|
|
|
CuSuite *get_names_suite(void)
|
|
|
|
{
|
|
|
|
CuSuite *suite = CuSuiteNew();
|
|
|
|
SUITE_ADD_TEST(suite, test_names);
|
2016-12-31 20:12:13 +01:00
|
|
|
SUITE_ADD_TEST(suite, test_monster_names);
|
2016-08-28 18:37:08 +02:00
|
|
|
return suite;
|
|
|
|
}
|