Some final scenario read tests

This commit is contained in:
2015-09-30 17:57:48 -04:00
parent 43e82281af
commit 5c37fa199e
22 changed files with 772 additions and 1 deletions

View File

@@ -828,7 +828,7 @@ void readScenarioFromXml(ticpp::Document&& data, cScenario& scenario) {
} else if(type == "editor") {
std::set<std::string> reqs = {"default-ground", "last-out-section", "last-town"};
Iterator<Element> edit;
int num_storage = 0, num_pics = 0, sndnum = 0;
int num_storage = 0, num_pics = 0;
for(edit = edit.begin(elem.Get()); edit != edit.end(); edit++) {
edit->GetValue(&type);
reqs.erase(type);
@@ -839,6 +839,7 @@ void readScenarioFromXml(ticpp::Document&& data, cScenario& scenario) {
} else if(type == "last-town") {
edit->GetText(&scenario.last_town_edited);
} else if(type == "sound") {
int sndnum = 0;
edit->GetAttribute("id", &sndnum);
if(sndnum < 100)
throw xBadVal(type, "id", std::to_string(sndnum), edit->Row(), edit->Column(), fname);

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>7</difficulty>
</ratings>
</scenario>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<num-towns>3</num-towns>
<out-width>2</out-width>
<out-height>1</out-height>
<start-town>7</start-town>
<town-start x="24" y="28" />
<outdoor-start x="1" y="3" />
<sector-start x="12" y="21" />
</game>
<editor>
<bad/>
</editor>
</scenario>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<bad/>
</flags>
</scenario>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<bad/>
</game>
</scenario>

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<num-towns>3</num-towns>
<out-width>2</out-width>
<out-height>1</out-height>
<start-town>7</start-town>
<town-start x="24" y="28" />
<outdoor-start x="1" y="3" />
<sector-start x="12" y="21" />
</game>
<editor>
<default-ground>2</default-ground>
<last-out-section x="0" y="0" />
<last-town>0</last-town>
<sound id='5'>Can't rename preset sounds</sound>
</editor>
</scenario>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<bad/>
</scenario>

View File

@@ -45,5 +45,6 @@
<default-ground>2</default-ground>
<last-out-section x="0" y="0" />
<last-town>0</last-town>
<sound id='100'>The name of my custom sound</sound>
</editor>
</scenario>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<store-items bad='0'/>
</game>
</scenario>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<store-items town='0' top='0' left='0' right='10'/>
</game>
</scenario>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<store-items town='0' top='0' bottom='10' right='10'/>
</game>
</scenario>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<store-items town='0' top='0' left='0' bottom='10'/>
</game>
</scenario>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<store-items town='0' left='0' bottom='10' right='10'/>
</game>
</scenario>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<store-items top='0' left='0' bottom='10' right='10'/>
</game>
</scenario>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.0.0">
<title>Test Scenario</title>
<icon>0</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg>Welcome to the test scenario!</intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.0.0</version>
<os></os>
</creator>
<game>
<num-towns>0</num-towns>
<out-width>0</out-width>
<out-height>0</out-height>
<start-town>7</start-town>
<town-start x="24" y="28" />
<outdoor-start x="1" y="3" />
<sector-start x="12" y="21" />
<shop>
<bad/>
</shop>
</game>
</scenario>

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.0.0">
<title>Test Scenario</title>
<icon>0</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg>Welcome to the test scenario!</intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.0.0</version>
<os></os>
</creator>
<game>
<num-towns>0</num-towns>
<out-width>0</out-width>
<out-height>0</out-height>
<start-town>7</start-town>
<town-start x="24" y="28" />
<outdoor-start x="1" y="3" />
<sector-start x="12" y="21" />
<shop>
<name>The Shop of Everything</name>
<type>live</type>
<prompt>shop</prompt>
<entries/>
</shop>
</game>
</scenario>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<timer bad="100">15</timer>
</game>
</scenario>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<timer>15</timer>
</game>
</scenario>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
<town-flag town="1" add-x="16" add-y="21"/>
</game>
</scenario>

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<store-items town="0" top="12" left="13" bottom="20" right="36"/>
<store-items town="0" top="12" left="13" bottom="20" right="36"/>
<store-items town="0" top="12" left="13" bottom="20" right="36"/>
<store-items town="0" top="12" left="13" bottom="20" right="36"/>
</game>
</scenario>

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<scenario boes="2.1.5">
<title>Test Scenario</title>
<icon>7</icon>
<id>campaign</id>
<version>2.6.7</version>
<language>en-US</language>
<author>
<name>BoE Test Suite</name>
<email>nowhere@example.com</email>
</author>
<text>
<teaser>Teaser 1</teaser>
<teaser>Teaser 2</teaser>
<intro-msg><![CDATA[Welcome!!! To the test scenario!]]></intro-msg>
</text>
<ratings>
<content>R</content>
<difficulty>3</difficulty>
</ratings>
<flags>
<adjust-difficulty>true</adjust-difficulty>
<legacy>false</legacy>
<custom-graphics>false</custom-graphics>
</flags>
<creator>
<type>oboe</type>
<version>2.5.3</version>
<os></os>
</creator>
<game>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
<timer freq="100">15</timer>
</game>
</scenario>

View File

@@ -39,6 +39,11 @@ TEST_CASE("Loading a new-format scenario record") {
doc = xmlDocFromStream(fin, "missing_toplevel.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingElem);
}
SECTION("When an invalid toplevel element is present") {
fin.open("files/scenario/bad_toplevel.xml");
doc = xmlDocFromStream(fin, "bad_toplevel.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
}
SECTION("When there are too many intro strings") {
fin.open("files/scenario/intro_overflow.xml");
doc = xmlDocFromStream(fin, "intro_overflow.xml");
@@ -69,6 +74,11 @@ TEST_CASE("Loading a new-format scenario record") {
doc = xmlDocFromStream(fin, "bad_rating.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), Exception);
}
SECTION("When the scenario difficulty is invalid") {
fin.open("files/scenario/bad_difficulty.xml");
doc = xmlDocFromStream(fin, "bad_difficulty.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadVal);
}
SECTION("When there are too many teaser strings") {
fin.open("files/scenario/extra_teaser.xml");
doc = xmlDocFromStream(fin, "extra_teaser.xml");
@@ -79,6 +89,11 @@ TEST_CASE("Loading a new-format scenario record") {
doc = xmlDocFromStream(fin, "missing_flags.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingElem);
}
SECTION("When a flag is invalid") {
fin.open("files/scenario/bad_flag.xml");
doc = xmlDocFromStream(fin, "bad_flag.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
}
SECTION("When it's not OBoE format") {
fin.open("files/scenario/bad_format.xml");
doc = xmlDocFromStream(fin, "bad_format.xml");
@@ -121,6 +136,21 @@ TEST_CASE("Loading a new-format scenario record") {
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadVal);
}
}
SECTION("With an invalid game subtag") {
fin.open("files/scenario/bad_game_node.xml");
doc = xmlDocFromStream(fin, "bad_game_node.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
}
SECTION("With an invalid editor subtag") {
fin.open("files/scenario/bad_editor_node.xml");
doc = xmlDocFromStream(fin, "bad_editor_node.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
}
SECTION("With a sound name for a preset sound") {
fin.open("files/scenario/bad_snd_name.xml");
doc = xmlDocFromStream(fin, "bad_snd_name.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadVal);
}
SECTION("With the minimal required data") {
fin.open("files/scenario/minimal.xml");
doc = xmlDocFromStream(fin, "minimal.xml");
@@ -181,6 +211,8 @@ TEST_CASE("Loading a new-format scenario record") {
CHECK(scen.scenario_timers[0].time == 100);
CHECK(scen.scenario_timers[0].node == 15);
CHECK(scen.scenario_timers[0].node_type == 0);
REQUIRE(scen.snd_names.size() >= 1);
CHECK(scen.snd_names[0] == "The name of my custom sound");
}
SECTION("With an invalid town mod flag") {
SECTION("Missing X") {
@@ -203,6 +235,65 @@ TEST_CASE("Loading a new-format scenario record") {
doc = xmlDocFromStream(fin, "bad_townmod4.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadAttr);
}
SECTION("Too many") {
fin.open("files/scenario/too_many_flags.xml");
doc = xmlDocFromStream(fin, "too_many_flags.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
}
}
SECTION("With an invalid save rectangle") {
SECTION("With invalid attribute") {
fin.open("files/scenario/rect_bad_attr.xml");
doc = xmlDocFromStream(fin, "rect_bad_attr.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadAttr);
}
SECTION("Missing top") {
fin.open("files/scenario/rect_missing_top.xml");
doc = xmlDocFromStream(fin, "rect_missing_top.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingAttr);
}
SECTION("Missing left") {
fin.open("files/scenario/rect_missing_left.xml");
doc = xmlDocFromStream(fin, "rect_missing_left.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingAttr);
}
SECTION("Missing bottom") {
fin.open("files/scenario/rect_missing_bottom.xml");
doc = xmlDocFromStream(fin, "rect_missing_bottom.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingAttr);
}
SECTION("Missing right") {
fin.open("files/scenario/rect_missing_right.xml");
doc = xmlDocFromStream(fin, "rect_missing_right.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingAttr);
}
SECTION("Missing town") {
fin.open("files/scenario/rect_missing_town.xml");
doc = xmlDocFromStream(fin, "rect_missing_town.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingAttr);
}
SECTION("Too many") {
fin.open("files/scenario/too_many_rects.xml");
doc = xmlDocFromStream(fin, "too_many_rects.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
}
}
SECTION("With an invalid timer") {
SECTION("With invalid attribute") {
fin.open("files/scenario/timer_bad_attr.xml");
doc = xmlDocFromStream(fin, "timer_bad_attr.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadAttr);
}
SECTION("Missing frequency") {
fin.open("files/scenario/timer_missing_freq.xml");
doc = xmlDocFromStream(fin, "timer_missing_freq.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingAttr);
}
SECTION("Too many") {
fin.open("files/scenario/too_many_timers.xml");
doc = xmlDocFromStream(fin, "too_many_timers.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
}
}
SECTION("With a special item") {
SECTION("Valid") {
@@ -376,6 +467,16 @@ TEST_CASE("Loading a new-format scenario record") {
doc = xmlDocFromStream(fin, "shop-bad_entry.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
}
SECTION("Invalid toplevel tag") {
fin.open("files/scenario/shop-bad_node.xml");
doc = xmlDocFromStream(fin, "shop-bad_node.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
}
SECTION("Missing required tag") {
fin.open("files/scenario/shop-missing_node.xml");
doc = xmlDocFromStream(fin, "shop-missing_node.xml");
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingElem);
}
ResMgr::popPath<StringRsrc>();
}
SECTION("With item storage shortcuts") {