forked from github/server
added a test that fails because of stupid static state in finditemtype
This commit is contained in:
parent
08adc91534
commit
52e323fef8
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <kernel/types.h>
|
#include <kernel/types.h>
|
||||||
#include <kernel/item.h>
|
#include <kernel/item.h>
|
||||||
|
#include <util/language.h>
|
||||||
|
|
||||||
#include <cutest/CuTest.h>
|
#include <cutest/CuTest.h>
|
||||||
#include <tests.h>
|
#include <tests.h>
|
||||||
|
@ -11,6 +12,8 @@ void test_resource_type(CuTest * tc)
|
||||||
struct item_type *itype;
|
struct item_type *itype;
|
||||||
const char *names[2] = { 0 , 0 };
|
const char *names[2] = { 0 , 0 };
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
|
||||||
CuAssertPtrEquals(tc, 0, rt_find("herpderp"));
|
CuAssertPtrEquals(tc, 0, rt_find("herpderp"));
|
||||||
|
|
||||||
names[0] = names[1] = "herpderp";
|
names[0] = names[1] = "herpderp";
|
||||||
|
@ -26,9 +29,35 @@ void test_resource_type(CuTest * tc)
|
||||||
CuAssertPtrEquals(tc, itype->rtype, rt_find("herp"));
|
CuAssertPtrEquals(tc, itype->rtype, rt_find("herp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_finditemtype(CuTest * tc)
|
||||||
|
{
|
||||||
|
struct item_type *itype;
|
||||||
|
const char *names[4] = { "herp" , "herp_p", "derp", "derp_p" };
|
||||||
|
struct locale * lang = make_locale("de");
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
|
||||||
|
itype = test_create_itemtype(names);
|
||||||
|
CuAssertPtrNotNull(tc, itype);
|
||||||
|
locale_setstring(lang, names[0], "Foo");
|
||||||
|
locale_setstring(lang, names[1], "Foos");
|
||||||
|
|
||||||
|
CuAssertPtrEquals(tc, (void*)itype, (void*)finditemtype("Foo", lang));
|
||||||
|
CuAssertPtrEquals(tc, (void*)itype, (void*)finditemtype("Foos", lang));
|
||||||
|
|
||||||
|
itype = test_create_itemtype(names+2);
|
||||||
|
CuAssertPtrNotNull(tc, itype);
|
||||||
|
locale_setstring(lang, names[2], "Bar");
|
||||||
|
locale_setstring(lang, names[3], "Bars");
|
||||||
|
|
||||||
|
CuAssertPtrEquals(tc, (void*)itype, (void*)finditemtype("Bar", lang));
|
||||||
|
CuAssertPtrEquals(tc, (void*)itype, (void*)finditemtype("Bars", lang));
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue