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