forked from github/server
bug 2303: correct the test.
we cannot reuse the memstream. need to recreate it for each test. need to rewrite the code in creport.c, it is crazy.
This commit is contained in:
parent
1c72b0f297
commit
4b246863c0
|
@ -796,14 +796,14 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
|
||||||
else {
|
else {
|
||||||
/* other unit. show visible faction, not u->faction */
|
/* other unit. show visible faction, not u->faction */
|
||||||
stream_printf(out, "%d;Partei\n", sf ? sf->no : f->no);
|
stream_printf(out, "%d;Partei\n", sf ? sf->no : f->no);
|
||||||
if (sf == f) {
|
|
||||||
stream_printf(out, "1;Verraeter\n");
|
|
||||||
}
|
|
||||||
if (sf && sf != u->faction) {
|
|
||||||
if (alliedunit(u, f, HELP_FSTEALTH)) {
|
if (alliedunit(u, f, HELP_FSTEALTH)) {
|
||||||
|
if (sf && sf != u->faction) {
|
||||||
stream_printf(out, "%d;Anderepartei\n", sf->no);
|
stream_printf(out, "%d;Anderepartei\n", sf->no);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (sf == f) {
|
||||||
|
stream_printf(out, "1;Verraeter\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prefix = raceprefix(u);
|
prefix = raceprefix(u);
|
||||||
|
|
|
@ -71,39 +71,44 @@ static void test_cr_factionstealth(CuTest *tc) {
|
||||||
ally *al;
|
ally *al;
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
mstream_init(&strm);
|
|
||||||
f1 = test_create_faction(0);
|
f1 = test_create_faction(0);
|
||||||
f2 = test_create_faction(0);
|
f2 = test_create_faction(0);
|
||||||
r = test_create_region(0, 0, 0);
|
r = test_create_region(0, 0, 0);
|
||||||
u = test_create_unit(f1, r);
|
u = test_create_unit(f1, r);
|
||||||
|
|
||||||
|
mstream_init(&strm);
|
||||||
cr_output_unit(&strm, u->region, f1, u, seen_unit);
|
cr_output_unit(&strm, u->region, f1, u, seen_unit);
|
||||||
CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1));
|
CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1));
|
||||||
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1));
|
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1));
|
||||||
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1));
|
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1));
|
||||||
|
mstream_done(&strm);
|
||||||
|
|
||||||
set_factionstealth(u, f2);
|
set_factionstealth(u, f2);
|
||||||
CuAssertPtrNotNull(tc, u->attribs);
|
CuAssertPtrNotNull(tc, u->attribs);
|
||||||
|
|
||||||
|
mstream_init(&strm);
|
||||||
cr_output_unit(&strm, u->region, f1, u, seen_unit);
|
cr_output_unit(&strm, u->region, f1, u, seen_unit);
|
||||||
CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1));
|
CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1));
|
||||||
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1));
|
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1));
|
||||||
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1));
|
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1));
|
||||||
|
mstream_done(&strm);
|
||||||
|
|
||||||
|
mstream_init(&strm);
|
||||||
cr_output_unit(&strm, u->region, f2, u, seen_unit);
|
cr_output_unit(&strm, u->region, f2, u, seen_unit);
|
||||||
CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1));
|
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Partei", -1));
|
||||||
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1));
|
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Anderepartei", -1));
|
||||||
CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1));
|
CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1));
|
||||||
|
mstream_done(&strm);
|
||||||
|
|
||||||
al = ally_add(&f1->allies, f2);
|
al = ally_add(&f1->allies, f2);
|
||||||
al->status = HELP_FSTEALTH;
|
al->status = HELP_FSTEALTH;
|
||||||
|
mstream_init(&strm);
|
||||||
cr_output_unit(&strm, u->region, f2, u, seen_unit);
|
cr_output_unit(&strm, u->region, f2, u, seen_unit);
|
||||||
CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1));
|
CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1));
|
||||||
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1));
|
CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1));
|
||||||
CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1));
|
CuAssertIntEquals(tc, -1, cr_get_int(&strm, ";Verraeter", -1));
|
||||||
|
|
||||||
mstream_done(&strm);
|
mstream_done(&strm);
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue