forked from github/server
write a test for get_addresses before modifying it.
This commit is contained in:
parent
295614643a
commit
e0085eac0c
|
@ -764,7 +764,6 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
|
||||||
}
|
}
|
||||||
/* print faction information */
|
/* print faction information */
|
||||||
sf = visible_faction(NULL, u);
|
sf = visible_faction(NULL, u);
|
||||||
prefix = raceprefix(u);
|
|
||||||
if (u->faction == f || omniscient(f)) {
|
if (u->faction == f || omniscient(f)) {
|
||||||
/* my own faction, full info */
|
/* my own faction, full info */
|
||||||
const attrib *a = NULL;
|
const attrib *a = NULL;
|
||||||
|
@ -807,6 +806,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
prefix = raceprefix(u);
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
prefix = mkname("prefix", prefix);
|
prefix = mkname("prefix", prefix);
|
||||||
stream_printf(out, "\"%s\";typprefix\n", translate(prefix, LOC(f->locale,
|
stream_printf(out, "\"%s\";typprefix\n", translate(prefix, LOC(f->locale,
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ static void add_travelthru_addresses(region *r, faction *f, selist **flist, int
|
||||||
travelthru_map(r, cb_add_address, &cbdata);
|
travelthru_map(r, cb_add_address, &cbdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_addresses(report_context * ctx)
|
void get_addresses(report_context * ctx)
|
||||||
{
|
{
|
||||||
/* "TODO: travelthru" */
|
/* "TODO: travelthru" */
|
||||||
region *r;
|
region *r;
|
||||||
|
|
|
@ -81,6 +81,7 @@ extern "C" {
|
||||||
|
|
||||||
void prepare_report(report_context *ctx, struct faction *f);
|
void prepare_report(report_context *ctx, struct faction *f);
|
||||||
void finish_reports(report_context *ctx);
|
void finish_reports(report_context *ctx);
|
||||||
|
void get_addresses(report_context * ctx);
|
||||||
|
|
||||||
typedef int(*report_fun) (const char *filename, report_context * ctx,
|
typedef int(*report_fun) (const char *filename, report_context * ctx,
|
||||||
const char *charset);
|
const char *charset);
|
||||||
|
|
|
@ -279,6 +279,32 @@ static void test_prepare_travelthru(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_get_addresses(CuTest *tc) {
|
||||||
|
report_context ctx;
|
||||||
|
faction *f, *f2, *f1;
|
||||||
|
region *r;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
f = test_create_faction(0);
|
||||||
|
f1 = test_create_faction(0);
|
||||||
|
f2 = test_create_faction(0);
|
||||||
|
r = test_create_region(0, 0, 0);
|
||||||
|
test_create_unit(f, r);
|
||||||
|
test_create_unit(f1, r);
|
||||||
|
test_create_unit(f2, r);
|
||||||
|
prepare_report(&ctx, f);
|
||||||
|
CuAssertPtrEquals(tc, r, ctx.first);
|
||||||
|
CuAssertPtrEquals(tc, NULL, ctx.last);
|
||||||
|
get_addresses(&ctx);
|
||||||
|
CuAssertPtrNotNull(tc, ctx.addresses);
|
||||||
|
CuAssertIntEquals(tc, 3, selist_length(ctx.addresses));
|
||||||
|
CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f1, NULL)));
|
||||||
|
CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f2, NULL)));
|
||||||
|
CuAssertIntEquals(tc, 1, (i=0, selist_find(&ctx.addresses, &i, f, NULL)));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
void test_prepare_lighthouse_capacity(CuTest *tc) {
|
void test_prepare_lighthouse_capacity(CuTest *tc) {
|
||||||
building *b;
|
building *b;
|
||||||
building_type *btype;
|
building_type *btype;
|
||||||
|
@ -490,6 +516,7 @@ CuSuite *get_reports_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_prepare_lighthouse_owners);
|
SUITE_ADD_TEST(suite, test_prepare_lighthouse_owners);
|
||||||
SUITE_ADD_TEST(suite, test_prepare_lighthouse_capacity);
|
SUITE_ADD_TEST(suite, test_prepare_lighthouse_capacity);
|
||||||
SUITE_ADD_TEST(suite, test_prepare_travelthru);
|
SUITE_ADD_TEST(suite, test_prepare_travelthru);
|
||||||
|
SUITE_ADD_TEST(suite, test_get_addresses);
|
||||||
SUITE_ADD_TEST(suite, test_reorder_units);
|
SUITE_ADD_TEST(suite, test_reorder_units);
|
||||||
SUITE_ADD_TEST(suite, test_seen_faction);
|
SUITE_ADD_TEST(suite, test_seen_faction);
|
||||||
SUITE_ADD_TEST(suite, test_regionid);
|
SUITE_ADD_TEST(suite, test_regionid);
|
||||||
|
|
Loading…
Reference in New Issue