From f788f19f6c66c4ae4c10daf9ee7d994b227fea62 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 23 Oct 2014 16:14:01 +0200 Subject: [PATCH] fix tests that relied on translation structures being statically cached. clean up static cache, add test for German imperative (WIP) --- src/kernel/order.test.c | 1 + src/keyword.test.c | 14 +++++++++++++- src/skill.test.c | 4 ++-- src/util/language.c | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/kernel/order.test.c b/src/kernel/order.test.c index 1d556c622..0ae35d0bc 100644 --- a/src/kernel/order.test.c +++ b/src/kernel/order.test.c @@ -32,6 +32,7 @@ static void test_parse_order(CuTest *tc) { struct locale * lang = get_or_create_locale("en"); locale_setstring(lang, "keyword::move", "MOVE"); + init_keyword(lang, K_MOVE, "MOVE"); ord = parse_order("MOVE NORTH", lang); CuAssertPtrNotNull(tc, ord); CuAssertIntEquals(tc, K_MOVE, getkeyword(ord)); diff --git a/src/keyword.test.c b/src/keyword.test.c index f2cde5ab1..46e8fbfdd 100644 --- a/src/keyword.test.c +++ b/src/keyword.test.c @@ -19,6 +19,18 @@ static void test_init_keywords(CuTest *tc) { test_cleanup(); } +static void test_infinitive(CuTest *tc) { + struct locale *lang; + test_cleanup(); + + lang = get_or_create_locale("de"); + init_keyword(lang, K_STUDY, "LERNEN"); + CuAssertIntEquals(tc, K_STUDY, get_keyword("LERN", lang)); + CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNE", lang)); + CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNEN", lang)); + test_cleanup(); +} + static void test_init_keyword(CuTest *tc) { struct locale *lang; test_cleanup(); @@ -76,6 +88,7 @@ static void test_get_shortest_match(CuTest *tc) { CuSuite *get_keyword_suite(void) { CuSuite *suite = CuSuiteNew(); + SUITE_ADD_TEST(suite, test_infinitive); SUITE_ADD_TEST(suite, test_init_keyword); SUITE_ADD_TEST(suite, test_init_keywords); SUITE_ADD_TEST(suite, test_findkeyword); @@ -83,4 +96,3 @@ CuSuite *get_keyword_suite(void) SUITE_DISABLE_TEST(suite, test_get_keyword_default); return suite; } - diff --git a/src/skill.test.c b/src/skill.test.c index 00c884edc..48b293e04 100644 --- a/src/skill.test.c +++ b/src/skill.test.c @@ -11,8 +11,8 @@ static void test_init_skills(CuTest *tc) { test_cleanup(); lang = get_or_create_locale("de"); - locale_setstring(lang, "alchemy", "Alchemie"); - init_skills(lang); +// locale_setstring(lang, "alchemy", "Alchemie"); + init_skill(lang, SK_ALCHEMY, "Alchemie"); CuAssertIntEquals(tc, SK_ALCHEMY, get_skill("alchemie", lang)); test_cleanup(); } diff --git a/src/util/language.c b/src/util/language.c index e0384e9b6..c3e997553 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -261,4 +261,5 @@ void free_locales(void) free(locales); locales = next; } + memset(lstrs, 0, sizeof(lstrs)); // TODO: does this data need to be free'd? } \ No newline at end of file