More read/write tests for town and outdoors, including maps/dialogue

Fixes:
- For towns, the "has tavern" flag was not saved or loaded
- Outdoor roads were not saved or loaded
- For outdoor encounters, the "can't flee" and "forced" flags were not loaded, and "forced" was not saved
--> These two flags have also been separated in the code
This commit is contained in:
2015-09-30 17:00:05 -04:00
parent 16a09988f3
commit 43e82281af
26 changed files with 576 additions and 20 deletions

View File

@@ -19,6 +19,9 @@ extern Document xmlDocFromStream(istream& stream, string name);
extern void readOutdoorsFromXml(Document&& data, cOutdoors& out);
extern void writeOutdoorsToXml(ticpp::Printer&& data, cOutdoors& sector);
extern bool operator==(const cOutdoors::cWandering& lhs, const cOutdoors::cWandering& rhs);
extern ostream& operator<<(ostream& out, const cOutdoors::cWandering& enc);
static void in_and_out(string name, cOutdoors& out, cScenario& scen) {
string fpath = "junk/out_";
fpath += name;
@@ -45,4 +48,47 @@ TEST_CASE("Saving an outdoors sector") {
in_and_out("basic", out, scen);
CHECK(out.out_name == "The Outdoors Test");
}
SECTION("With some optional information") {
out.comment = "Let's make a comment about comments.";
out.ambient_sound = AMBIENT_DRIP;
out.sign_locs.emplace_back(0,0,"Guantanamo - 14 mi.");
out.info_rect.emplace_back(0,0,1,1,"The heart of the wilderness");
out.spec_strs.emplace_back("Something happened!");
in_and_out("optional", out, scen);
CHECK(out.comment == "Let's make a comment about comments.");
CHECK(out.ambient_sound == AMBIENT_DRIP);
REQUIRE(out.sign_locs.size() >= 1);
CHECK(out.sign_locs[0].text == "Guantanamo - 14 mi.");
REQUIRE(out.info_rect.size() >= 1);
CHECK(out.info_rect[0].descr == "The heart of the wilderness");
REQUIRE(out.spec_strs.size() >= 1);
CHECK(out.spec_strs[0] == "Something happened!");
}
SECTION("With some encounters") {
cOutdoors::cWandering spec, wand;
spec.monst[3] = 42;
spec.monst[5] = 12;
spec.spec_on_meet = 15;
spec.spec_on_win = 12;
spec.spec_on_flee = 9;
spec.cant_flee = true;
spec.forced = true;
wand.monst[2] = 80;
wand.monst[6] = 90;
wand.friendly[1] = 12;
wand.end_spec1 = 210;
wand.end_spec2 = 22;
REQUIRE(out.special_enc.size() >= 1);
out.special_enc[0] = spec;
REQUIRE(out.wandering.size() >= 1);
out.wandering[0] = wand;
in_and_out("encounters", out, scen);
REQUIRE(out.special_enc.size() >= 1);
CHECK(out.special_enc[0] == spec);
REQUIRE(out.wandering.size() >= 1);
CHECK(out.wandering[0] == wand);
}
}