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 */
|
||||
sf = visible_faction(NULL, u);
|
||||
prefix = raceprefix(u);
|
||||
if (u->faction == f || omniscient(f)) {
|
||||
/* my own faction, full info */
|
||||
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) {
|
||||
prefix = mkname("prefix", prefix);
|
||||
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);
|
||||
}
|
||||
|
||||
static void get_addresses(report_context * ctx)
|
||||
void get_addresses(report_context * ctx)
|
||||
{
|
||||
/* "TODO: travelthru" */
|
||||
region *r;
|
||||
|
|
|
@ -81,6 +81,7 @@ extern "C" {
|
|||
|
||||
void prepare_report(report_context *ctx, struct faction *f);
|
||||
void finish_reports(report_context *ctx);
|
||||
void get_addresses(report_context * ctx);
|
||||
|
||||
typedef int(*report_fun) (const char *filename, report_context * ctx,
|
||||
const char *charset);
|
||||
|
|
|
@ -279,6 +279,32 @@ static void test_prepare_travelthru(CuTest *tc) {
|
|||
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) {
|
||||
building *b;
|
||||
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_capacity);
|
||||
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_seen_faction);
|
||||
SUITE_ADD_TEST(suite, test_regionid);
|
||||
|
|
Loading…
Reference in New Issue