Added a test that fails for Bug 1909 (findresourcetype is borken)

This commit is contained in:
Enno Rehling 2012-05-21 21:39:18 -07:00
parent 6c51013e14
commit 2872dfa772
2 changed files with 36 additions and 18 deletions

View File

@ -32,38 +32,40 @@ void test_resource_type(CuTest * tc)
void test_finditemtype(CuTest * tc) void test_finditemtype(CuTest * tc)
{ {
const item_type *itype, *iresult; const item_type *itype, *iresult;
const char *names[] = { "herp" , "herp_p" }; struct locale * lang;
struct locale * lang = make_locale("de");
test_cleanup(); test_cleanup();
test_create_world();
locale_setstring(lang, names[0], "Foo"); lang = find_locale("de");
itype = test_create_itemtype(names); locale_setstring(lang, "horse", "Pferd");
CuAssertPtrNotNull(tc, itype); itype = it_find("horse");
iresult = finditemtype("Foo", lang); iresult = finditemtype("Pferd", lang);
CuAssertPtrNotNull(tc, iresult);
CuAssertPtrEquals(tc, (void*)itype, (void*)iresult); CuAssertPtrEquals(tc, (void*)itype, (void*)iresult);
} }
#if 0 void test_findresourcetype(CuTest * tc)
locale_setstring(lang, names[1], "Foos"); {
CuAssertPtrEquals(tc, (void*)itype, (void*)finditemtype("Foo", lang)); const resource_type *rtype, *rresult;
CuAssertPtrEquals(tc, (void*)itype, (void*)finditemtype("Foos", lang)); struct locale * lang;
test_cleanup(); test_cleanup();
itype = test_create_itemtype(names+2); test_create_world();
CuAssertPtrNotNull(tc, itype);
locale_setstring(lang, names[2], "Bar");
locale_setstring(lang, names[3], "Bars");
CuAssertPtrEquals(tc, (void*)0, (void*)finditemtype("Foo", lang)); lang = find_locale("de");
CuAssertPtrEquals(tc, (void*)itype, (void*)finditemtype("Bar", lang)); locale_setstring(lang, "horse", "Pferd");
rtype = rt_find("horse");
rresult = findresourcetype("Pferd", lang);
CuAssertPtrNotNull(tc, rresult);
CuAssertPtrEquals(tc, (void*)rtype, (void*)rresult);
} }
#endif
CuSuite *get_item_suite(void) CuSuite *get_item_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_resource_type); SUITE_ADD_TEST(suite, test_resource_type);
SUITE_ADD_TEST(suite, test_finditemtype); SUITE_ADD_TEST(suite, test_finditemtype);
SUITE_ADD_TEST(suite, test_findresourcetype);
return suite; return suite;
} }

View File

@ -9,16 +9,32 @@ static void test_recreate_world(CuTest * tc)
CuAssertPtrEquals(tc, 0, find_locale("de")); 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")); CuAssertPtrEquals(tc, default_locale, find_locale("de"));
CuAssertPtrNotNull(tc, default_locale); CuAssertPtrNotNull(tc, default_locale);
CuAssertPtrNotNull(tc, findregion(0, 0));
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, rt_find("horse"));
CuAssertPtrNotNull(tc, rt_find("hp"));
CuAssertPtrNotNull(tc, rt_find("money"));
CuAssertPtrNotNull(tc, rt_find("aura"));
CuAssertPtrNotNull(tc, rt_find("permaura"));
CuAssertPtrNotNull(tc, rt_find("peasant"));
CuAssertPtrNotNull(tc, rt_find("unit"));
test_cleanup(); test_cleanup();
CuAssertPtrEquals(tc, 0, find_locale("de")); 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, rt_find("horse"));
CuAssertPtrEquals(tc, 0, rt_find("hp"));
CuAssertPtrEquals(tc, 0, rt_find("money"));
CuAssertPtrEquals(tc, 0, rt_find("aura"));
CuAssertPtrEquals(tc, 0, rt_find("permaura"));
CuAssertPtrEquals(tc, 0, rt_find("peasant"));
CuAssertPtrEquals(tc, 0, rt_find("unit"));
CuAssertPtrEquals(tc, 0, findregion(0, 0)); CuAssertPtrEquals(tc, 0, findregion(0, 0));
} }