forked from github/server
Testing util is no longer such an include-weirdness.
This commit is contained in:
parent
16d86413d5
commit
d479075c53
|
@ -17,6 +17,7 @@ without prior permission by the authors of Eressea.
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
|
#include <util/quicklist.h>
|
||||||
#include <util/rng.h>
|
#include <util/rng.h>
|
||||||
|
|
||||||
#include <kernel/building.h>
|
#include <kernel/building.h>
|
||||||
|
@ -89,7 +90,7 @@ static int rc_herb_trade(const struct race * rc)
|
||||||
|
|
||||||
void do_markets(void)
|
void do_markets(void)
|
||||||
{
|
{
|
||||||
unit_list * traders = 0;
|
quicklist * traders = 0;
|
||||||
unit * markets[MAX_MARKETS];
|
unit * markets[MAX_MARKETS];
|
||||||
region * r;
|
region * r;
|
||||||
for (r=regions;r;r=r->next) {
|
for (r=regions;r;r=r->next) {
|
||||||
|
@ -119,11 +120,8 @@ void do_markets(void)
|
||||||
item * items;
|
item * items;
|
||||||
attrib * a = a_find(u->attribs, &at_market);
|
attrib * a = a_find(u->attribs, &at_market);
|
||||||
if (a==NULL) {
|
if (a==NULL) {
|
||||||
unit_list * ulist = malloc(sizeof(unit_list));
|
|
||||||
a = a_add(&u->attribs, a_new(&at_market));
|
a = a_add(&u->attribs, a_new(&at_market));
|
||||||
ulist->next = traders;
|
ql_push(&traders, u);
|
||||||
ulist->data = u;
|
|
||||||
traders = ulist;
|
|
||||||
}
|
}
|
||||||
items = (item *)a->data.v;
|
items = (item *)a->data.v;
|
||||||
i_change(&items, lux, 1);
|
i_change(&items, lux, 1);
|
||||||
|
@ -136,11 +134,8 @@ void do_markets(void)
|
||||||
item * items;
|
item * items;
|
||||||
attrib * a = a_find(u->attribs, &at_market);
|
attrib * a = a_find(u->attribs, &at_market);
|
||||||
if (a==NULL) {
|
if (a==NULL) {
|
||||||
unit_list * ulist = malloc(sizeof(unit_list));
|
|
||||||
a = a_add(&u->attribs, a_new(&at_market));
|
a = a_add(&u->attribs, a_new(&at_market));
|
||||||
ulist->next = traders;
|
ql_push(&traders, u);
|
||||||
ulist->data = u;
|
|
||||||
traders = ulist;
|
|
||||||
}
|
}
|
||||||
items = (item *)a->data.v;
|
items = (item *)a->data.v;
|
||||||
i_change(&items, herb, 1);
|
i_change(&items, herb, 1);
|
||||||
|
@ -152,33 +147,35 @@ void do_markets(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (traders) {
|
if (traders) {
|
||||||
unit_list * trade = traders;
|
quicklist * qliter = traders;
|
||||||
unit * u = trade->data;
|
int qli = 0;
|
||||||
attrib * a = a_find(u->attribs, &at_market);
|
for (qli=0;qliter;ql_advance(&qliter, &qli, 1)) {
|
||||||
item * items = a->data.v;
|
unit * u = (unit *)ql_get(qliter, qli);
|
||||||
|
attrib * a = a_find(u->attribs, &at_market);
|
||||||
|
item * items = (item *)a->data.v;
|
||||||
|
|
||||||
a->data.v = NULL;
|
a->data.v = NULL;
|
||||||
while (items) {
|
while (items) {
|
||||||
item * itm = items;
|
item * itm = items;
|
||||||
items = itm->next;
|
items = itm->next;
|
||||||
|
|
||||||
if (itm->number) {
|
if (itm->number) {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("buyamount",
|
ADDMSG(&u->faction->msgs, msg_message("buyamount",
|
||||||
"unit amount resource", u, itm->number, itm->type->rtype));
|
"unit amount resource", u, itm->number, itm->type->rtype));
|
||||||
itm->next = NULL;
|
itm->next = NULL;
|
||||||
i_add(&u->items, itm);
|
i_add(&u->items, itm);
|
||||||
} else {
|
} else {
|
||||||
i_free(itm);
|
i_free(itm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a_remove(&u->attribs, a);
|
||||||
}
|
}
|
||||||
|
ql_free(traders);
|
||||||
traders = trade->next;
|
|
||||||
|
|
||||||
a_remove(&u->attribs, a);
|
|
||||||
free(trade);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_TESTS
|
#ifndef DISABLE_TESTS
|
||||||
#include "market_test.c"
|
#include "market_test.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
|
||||||
CuSuite* get_base36_suite(void);
|
#include <util/base36_test.c>
|
||||||
|
#include <util/quicklist_test.c>
|
||||||
|
|
||||||
CuSuite* get_curse_suite(void);
|
CuSuite* get_curse_suite(void);
|
||||||
CuSuite* get_market_suite(void);
|
CuSuite* get_market_suite(void);
|
||||||
CuSuite* get_laws_suite(void);
|
CuSuite* get_laws_suite(void);
|
||||||
|
@ -26,6 +28,7 @@ int RunAllTests(void) {
|
||||||
init_resources();
|
init_resources();
|
||||||
|
|
||||||
CuSuiteAddSuite(suite, get_base36_suite());
|
CuSuiteAddSuite(suite, get_base36_suite());
|
||||||
|
CuSuiteAddSuite(suite, get_quicklist_suite());
|
||||||
CuSuiteAddSuite(suite, get_curse_suite());
|
CuSuiteAddSuite(suite, get_curse_suite());
|
||||||
CuSuiteAddSuite(suite, get_market_suite());
|
CuSuiteAddSuite(suite, get_market_suite());
|
||||||
CuSuiteAddSuite(suite, get_laws_suite());
|
CuSuiteAddSuite(suite, get_laws_suite());
|
||||||
|
|
|
@ -125,9 +125,7 @@
|
||||||
<ClCompile Include="util\argstack.c" />
|
<ClCompile Include="util\argstack.c" />
|
||||||
<ClCompile Include="util\attrib.c" />
|
<ClCompile Include="util\attrib.c" />
|
||||||
<ClCompile Include="util\base36.c" />
|
<ClCompile Include="util\base36.c" />
|
||||||
<ClCompile Include="util\base36_test.c">
|
<ClCompile Include="util\base36_test.c" />
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="util\bsdstring.c" />
|
<ClCompile Include="util\bsdstring.c" />
|
||||||
<ClCompile Include="util\console.c" />
|
<ClCompile Include="util\console.c" />
|
||||||
<ClCompile Include="util\crmessage.c" />
|
<ClCompile Include="util\crmessage.c" />
|
||||||
|
@ -147,6 +145,7 @@
|
||||||
<ClCompile Include="util\parser.c" />
|
<ClCompile Include="util\parser.c" />
|
||||||
<ClCompile Include="util\patricia.c" />
|
<ClCompile Include="util\patricia.c" />
|
||||||
<ClCompile Include="util\quicklist.c" />
|
<ClCompile Include="util\quicklist.c" />
|
||||||
|
<ClCompile Include="util\quicklist_test.c" />
|
||||||
<ClCompile Include="util\rand.c" />
|
<ClCompile Include="util\rand.c" />
|
||||||
<ClCompile Include="util\resolve.c" />
|
<ClCompile Include="util\resolve.c" />
|
||||||
<ClCompile Include="util\sql.c" />
|
<ClCompile Include="util\sql.c" />
|
||||||
|
|
|
@ -205,5 +205,8 @@
|
||||||
<ClCompile Include="util\quicklist.c">
|
<ClCompile Include="util\quicklist.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="util\quicklist_test.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -109,7 +109,3 @@ i10toi36(int i)
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_TESTS
|
|
||||||
#include "base36_test.c"
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#include <cutest/CuTest.h>
|
#include <cutest/CuTest.h>
|
||||||
|
#include "base36.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
static void test_atoi36(CuTest * tc) {
|
static void test_atoi36(CuTest * tc) {
|
||||||
CuAssertIntEquals(tc, 0, atoi36("0"));
|
CuAssertIntEquals(tc, 0, atoi36("0"));
|
||||||
|
|
Loading…
Reference in New Issue