forked from github/server
fix broken tests and clear locales (badly) when clearing global stte
This commit is contained in:
parent
7f7c883583
commit
b44737387a
4 changed files with 17 additions and 4 deletions
|
@ -12,11 +12,11 @@ void test_resource_type(CuTest * tc)
|
||||||
|
|
||||||
CuAssertPtrEquals(tc, 0, rt_find("herpderp"));
|
CuAssertPtrEquals(tc, 0, rt_find("herpderp"));
|
||||||
|
|
||||||
names[0] = "herpderp";
|
names[0] = names[1] = "herpderp";
|
||||||
new_resourcetype(names, NULL, RTF_NONE);
|
new_resourcetype(names, NULL, RTF_NONE);
|
||||||
names[0] = "herp";
|
names[0] = names[1] = "herp";
|
||||||
rtype = new_resourcetype(names, NULL, RTF_NONE);
|
rtype = new_resourcetype(names, NULL, RTF_NONE);
|
||||||
names[0] = "herpes";
|
names[0] = names[1] = "herpes";
|
||||||
new_resourcetype(names, NULL, RTF_NONE);
|
new_resourcetype(names, NULL, RTF_NONE);
|
||||||
|
|
||||||
CuAssertPtrEquals(tc, rtype, rt_find("herp"));
|
CuAssertPtrEquals(tc, rtype, rt_find("herp"));
|
||||||
|
|
|
@ -107,6 +107,8 @@ void test_cleanup(void)
|
||||||
test_clear_resources();
|
test_clear_resources();
|
||||||
global.functions.maintenance = NULL;
|
global.functions.maintenance = NULL;
|
||||||
global.functions.wage = NULL;
|
global.functions.wage = NULL;
|
||||||
|
default_locale = 0;
|
||||||
|
locales = 0; /* TODO: this is evil and leaky */
|
||||||
free_gamedata();
|
free_gamedata();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +166,7 @@ void test_create_world(void)
|
||||||
item_type * itype;
|
item_type * itype;
|
||||||
const char * horses[2] = { "horse", "horse_p" };
|
const char * horses[2] = { "horse", "horse_p" };
|
||||||
|
|
||||||
|
make_locale("de");
|
||||||
init_resources();
|
init_resources();
|
||||||
assert(!olditemtype[I_HORSE]);
|
assert(!olditemtype[I_HORSE]);
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,17 @@
|
||||||
static void test_recreate_world(CuTest * tc)
|
static void test_recreate_world(CuTest * tc)
|
||||||
{
|
{
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
CuAssertPtrEquals(tc, 0, find_locale("de"));
|
||||||
CuAssertPtrEquals(tc, 0, it_find("money"));
|
CuAssertPtrEquals(tc, 0, it_find("money"));
|
||||||
CuAssertPtrEquals(tc, 0, it_find("horse"));
|
CuAssertPtrEquals(tc, 0, it_find("horse"));
|
||||||
test_create_world();
|
test_create_world();
|
||||||
|
CuAssertPtrEquals(tc, default_locale, find_locale("de"));
|
||||||
|
CuAssertPtrNotNull(tc, default_locale);
|
||||||
CuAssertPtrNotNull(tc, it_find("money"));
|
CuAssertPtrNotNull(tc, it_find("money"));
|
||||||
CuAssertPtrNotNull(tc, it_find("horse"));
|
CuAssertPtrNotNull(tc, it_find("horse"));
|
||||||
CuAssertPtrNotNull(tc, findregion(0, 0));
|
CuAssertPtrNotNull(tc, findregion(0, 0));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
CuAssertPtrEquals(tc, 0, find_locale("de"));
|
||||||
CuAssertPtrEquals(tc, 0, it_find("money"));
|
CuAssertPtrEquals(tc, 0, it_find("money"));
|
||||||
CuAssertPtrEquals(tc, 0, it_find("horse"));
|
CuAssertPtrEquals(tc, 0, it_find("horse"));
|
||||||
CuAssertPtrEquals(tc, 0, findregion(0, 0));
|
CuAssertPtrEquals(tc, 0, findregion(0, 0));
|
||||||
|
|
|
@ -57,6 +57,10 @@ locale *make_locale(const char *name)
|
||||||
locale *l = (locale *) calloc(sizeof(locale), 1);
|
locale *l = (locale *) calloc(sizeof(locale), 1);
|
||||||
locale **lp = &locales;
|
locale **lp = &locales;
|
||||||
|
|
||||||
|
if (!locales) {
|
||||||
|
nextlocaleindex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (*lp && (*lp)->hashkey != hkey)
|
while (*lp && (*lp)->hashkey != hkey)
|
||||||
lp = &(*lp)->next;
|
lp = &(*lp)->next;
|
||||||
if (*lp) {
|
if (*lp) {
|
||||||
|
@ -164,8 +168,10 @@ void locale_setstring(locale * lang, const char *key, const char *value)
|
||||||
unsigned int hkey = hashstring(key);
|
unsigned int hkey = hashstring(key);
|
||||||
unsigned int id = hkey & (SMAXHASH - 1);
|
unsigned int id = hkey & (SMAXHASH - 1);
|
||||||
struct locale_str *find;
|
struct locale_str *find;
|
||||||
if (lang == NULL)
|
if (!lang) {
|
||||||
lang = default_locale;
|
lang = default_locale;
|
||||||
|
}
|
||||||
|
assert(lang);
|
||||||
find = lang->strings[id];
|
find = lang->strings[id];
|
||||||
while (find) {
|
while (find) {
|
||||||
if (find->hashkey == hkey && strcmp(key, find->key) == 0)
|
if (find->hashkey == hkey && strcmp(key, find->key) == 0)
|
||||||
|
|
Loading…
Reference in a new issue