forked from github/server
Merge pull request #373 from ennorehling/develop
clean up item tests so they don't use test_create_world
This commit is contained in:
commit
62262ebcac
|
@ -33,17 +33,17 @@ static void test_skillpotion(CuTest *tc) {
|
||||||
learn_skill(u, SK_ENTERTAINMENT, 1.0);
|
learn_skill(u, SK_ENTERTAINMENT, 1.0);
|
||||||
pSkill = unit_skill(u, SK_ENTERTAINMENT);
|
pSkill = unit_skill(u, SK_ENTERTAINMENT);
|
||||||
sk_set(pSkill, 5);
|
sk_set(pSkill, 5);
|
||||||
initialWeeks_Entertainment = pSkill->weeks;
|
initialWeeks_Entertainment = pSkill->weeks = 4;
|
||||||
|
|
||||||
learn_skill(u, SK_STAMINA, 1.0);
|
learn_skill(u, SK_STAMINA, 1.0);
|
||||||
pSkill = unit_skill(u, SK_STAMINA);
|
pSkill = unit_skill(u, SK_STAMINA);
|
||||||
sk_set(pSkill, 5);
|
sk_set(pSkill, 5);
|
||||||
initialWeeks_Stamina = pSkill->weeks;
|
initialWeeks_Stamina = pSkill->weeks = 4;
|
||||||
|
|
||||||
learn_skill(u, SK_MAGIC, 1.0);
|
learn_skill(u, SK_MAGIC, 1.0);
|
||||||
pSkill = unit_skill(u, SK_MAGIC);
|
pSkill = unit_skill(u, SK_MAGIC);
|
||||||
sk_set(pSkill, 5);
|
sk_set(pSkill, 5);
|
||||||
initialWeeks_Magic = pSkill->weeks;
|
initialWeeks_Magic = pSkill->weeks = 4;
|
||||||
|
|
||||||
CuAssertIntEquals(tc, 1, use_skillpotion(u, itype, 1, NULL));
|
CuAssertIntEquals(tc, 1, use_skillpotion(u, itype, 1, NULL));
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ static void test_resourcename_with_appearance(CuTest *tc) {
|
||||||
|
|
||||||
static void test_uchange(CuTest * tc, unit * u, const resource_type * rtype) {
|
static void test_uchange(CuTest * tc, unit * u, const resource_type * rtype) {
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
assert(rtype);
|
||||||
change_resource(u, rtype, 4);
|
change_resource(u, rtype, 4);
|
||||||
n = get_resource(u, rtype);
|
n = get_resource(u, rtype);
|
||||||
CuAssertPtrNotNull(tc, rtype->uchange);
|
CuAssertPtrNotNull(tc, rtype->uchange);
|
||||||
|
@ -59,8 +61,8 @@ void test_change_item(CuTest * tc)
|
||||||
unit * u;
|
unit * u;
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
test_create_itemtype("iron");
|
||||||
init_resources();
|
init_resources();
|
||||||
test_create_world();
|
|
||||||
|
|
||||||
u = test_create_unit(0, 0);
|
u = test_create_unit(0, 0);
|
||||||
test_uchange(tc, u, get_resourcetype(R_IRON));
|
test_uchange(tc, u, get_resourcetype(R_IRON));
|
||||||
|
@ -79,43 +81,41 @@ void test_resource_type(CuTest * tc)
|
||||||
itype = test_create_itemtype("herp");
|
itype = test_create_itemtype("herp");
|
||||||
|
|
||||||
CuAssertPtrEquals(tc, itype->rtype, rt_find("herp"));
|
CuAssertPtrEquals(tc, itype->rtype, rt_find("herp"));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_finditemtype(CuTest * tc)
|
void test_finditemtype(CuTest * tc)
|
||||||
{
|
{
|
||||||
const item_type *itype;
|
const item_type *itype;
|
||||||
const resource_type *rtype;
|
|
||||||
struct locale * lang;
|
struct locale * lang;
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
test_create_world();
|
|
||||||
|
|
||||||
lang = get_locale("de");
|
lang = get_or_create_locale("de");
|
||||||
locale_setstring(lang, "horse", "Pferd");
|
locale_setstring(lang, "horse", "Pferd");
|
||||||
rtype = get_resourcetype(R_HORSE);
|
itype = test_create_itemtype("horse");
|
||||||
itype = finditemtype("Pferd", lang);
|
CuAssertPtrEquals(tc, (void *)itype, (void *)finditemtype("Pferd", lang));
|
||||||
CuAssertPtrNotNull(tc, itype);
|
test_cleanup();
|
||||||
CuAssertPtrEquals(tc, (void*)rtype->itype, (void*)itype);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_findresourcetype(CuTest * tc)
|
void test_findresourcetype(CuTest * tc)
|
||||||
{
|
{
|
||||||
const resource_type *rtype, *rresult;
|
const item_type *itype;
|
||||||
struct locale * lang;
|
struct locale * lang;
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
test_create_world();
|
|
||||||
|
|
||||||
lang = get_locale("de");
|
lang = get_or_create_locale("de");
|
||||||
locale_setstring(lang, "horse", "Pferd");
|
locale_setstring(lang, "horse", "Pferd");
|
||||||
locale_setstring(lang, "peasant", "Bauer");
|
locale_setstring(lang, "peasant", "Bauer");
|
||||||
|
init_resources();
|
||||||
|
CuAssertPtrNotNull(tc, rt_find("peasant"));
|
||||||
|
CuAssertPtrEquals(tc, 0, rt_find("horse"));
|
||||||
|
itype = test_create_itemtype("horse");
|
||||||
|
|
||||||
rtype = get_resourcetype(R_HORSE);
|
CuAssertPtrEquals(tc, (void*)itype->rtype, (void*)findresourcetype("Pferd", lang));
|
||||||
rresult = findresourcetype("Pferd", lang);
|
CuAssertPtrEquals(tc, (void *)rt_find("peasant"), (void *)findresourcetype("Bauer", lang));
|
||||||
CuAssertPtrNotNull(tc, rresult);
|
test_cleanup();
|
||||||
CuAssertPtrEquals(tc, (void*)rtype, (void*)rresult);
|
|
||||||
|
|
||||||
CuAssertPtrNotNull(tc, findresourcetype("Bauer", lang));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <modules/autoseed.h>
|
#include <modules/autoseed.h>
|
||||||
|
|
|
@ -68,6 +68,8 @@ int change_resource(unit * u, const resource_type * rtype, int change)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
assert(rtype);
|
||||||
|
|
||||||
if (rtype->uchange)
|
if (rtype->uchange)
|
||||||
i = rtype->uchange(u, rtype, change);
|
i = rtype->uchange(u, rtype, change);
|
||||||
else if (rtype == get_resourcetype(R_AURA))
|
else if (rtype == get_resourcetype(R_AURA))
|
||||||
|
|
Loading…
Reference in New Issue