Several more tests for scenario loading
This commit is contained in:
@@ -757,7 +757,6 @@ void readScenarioFromXml(ticpp::Document&& data, cScenario& scenario) {
|
||||
game->GetText(&scenario.init_spec);
|
||||
} else if(type == "start-town") {
|
||||
game->GetText(&scenario.which_town_start);
|
||||
// TODO: Make sure town is valid
|
||||
} else if(type == "town-start") {
|
||||
scenario.where_start = readLocFromXml(*game);
|
||||
} else if(type == "outdoor-start") {
|
||||
@@ -776,7 +775,6 @@ void readScenarioFromXml(ticpp::Document&& data, cScenario& scenario) {
|
||||
auto town_p = &scenario.town_mods[town_mods].spec;
|
||||
location& loc = scenario.town_mods[town_mods];
|
||||
loc = readLocFromXml(*game, "add-", "town", town_p);
|
||||
// TODO: Make sure town is valid
|
||||
town_mods++;
|
||||
} else if(type == "special-item") {
|
||||
scenario.special_items.emplace_back();
|
||||
|
31
test/files/scenario/bad_format.xml
Normal file
31
test/files/scenario/bad_format.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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>unknown</type>
|
||||
<version>2.0.0</version>
|
||||
<os></os>
|
||||
</creator>
|
||||
</scenario>
|
47
test/files/scenario/bad_graphics1.xml
Normal file
47
test/files/scenario/bad_graphics1.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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" />
|
||||
</game>
|
||||
<editor>
|
||||
<default-ground>2</default-ground>
|
||||
<last-out-section x="0" y="0" />
|
||||
<last-town>0</last-town>
|
||||
<graphics><pic index='0'>1</pic></graphics>
|
||||
<graphics/>
|
||||
</editor>
|
||||
</scenario>
|
46
test/files/scenario/bad_graphics2.xml
Normal file
46
test/files/scenario/bad_graphics2.xml
Normal 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" />
|
||||
</game>
|
||||
<editor>
|
||||
<default-ground>2</default-ground>
|
||||
<last-out-section x="0" y="0" />
|
||||
<last-town>0</last-town>
|
||||
<graphics><foo/></graphics>
|
||||
</editor>
|
||||
</scenario>
|
46
test/files/scenario/bad_graphics3.xml
Normal file
46
test/files/scenario/bad_graphics3.xml
Normal 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" />
|
||||
</game>
|
||||
<editor>
|
||||
<default-ground>2</default-ground>
|
||||
<last-out-section x="0" y="0" />
|
||||
<last-town>0</last-town>
|
||||
<graphics><pic>1</pic></graphics>
|
||||
</editor>
|
||||
</scenario>
|
46
test/files/scenario/bad_graphics4.xml
Normal file
46
test/files/scenario/bad_graphics4.xml
Normal 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" />
|
||||
</game>
|
||||
<editor>
|
||||
<default-ground>2</default-ground>
|
||||
<last-out-section x="0" y="0" />
|
||||
<last-town>0</last-town>
|
||||
<graphics><pic id='1'>1</pic></graphics>
|
||||
</editor>
|
||||
</scenario>
|
46
test/files/scenario/bad_graphics5.xml
Normal file
46
test/files/scenario/bad_graphics5.xml
Normal 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" />
|
||||
</game>
|
||||
<editor>
|
||||
<default-ground>2</default-ground>
|
||||
<last-out-section x="0" y="0" />
|
||||
<last-town>0</last-town>
|
||||
<graphics><pic index='1'>20</pic></graphics>
|
||||
</editor>
|
||||
</scenario>
|
7
test/files/scenario/bad_version.xml
Normal file
7
test/files/scenario/bad_version.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?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.7b2</version>
|
||||
</scenario>
|
46
test/files/scenario/extra_teaser.xml
Normal file
46
test/files/scenario/extra_teaser.xml
Normal 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>
|
||||
<teaser>Teaser 3</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" />
|
||||
</game>
|
||||
<editor>
|
||||
<default-ground>2</default-ground>
|
||||
<last-out-section x="0" y="0" />
|
||||
<last-town>0</last-town>
|
||||
</editor>
|
||||
</scenario>
|
41
test/files/scenario/missing_editor.xml
Normal file
41
test/files/scenario/missing_editor.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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" />
|
||||
</game>
|
||||
<editor/>
|
||||
</scenario>
|
11
test/files/scenario/missing_email.xml
Normal file
11
test/files/scenario/missing_email.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?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>
|
||||
</author>
|
||||
</scenario>
|
22
test/files/scenario/missing_flags.xml
Normal file
22
test/files/scenario/missing_flags.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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/>
|
||||
</scenario>
|
32
test/files/scenario/missing_game.xml
Normal file
32
test/files/scenario/missing_game.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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/>
|
||||
</scenario>
|
5
test/files/scenario/missing_pic.xml
Normal file
5
test/files/scenario/missing_pic.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<scenario boes="2.0.0">
|
||||
<title>Test Scenario</title>
|
||||
<icon></icon>
|
||||
</scenario>
|
20
test/files/scenario/missing_rating.xml
Normal file
20
test/files/scenario/missing_rating.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
</scenario>
|
@@ -21,26 +21,98 @@ TEST_CASE("Loading a new-format scenario record") {
|
||||
SECTION("When the version attribute is missing") {
|
||||
fin.open("files/scenario/bad_root.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_root.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(std::move(doc), scen), xBadNode);
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
|
||||
}
|
||||
SECTION("When the version attribute is missing") {
|
||||
fin.open("files/scenario/no_version.xml");
|
||||
doc = xmlDocFromStream(fin, "no_version.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(std::move(doc), scen), xMissingAttr);
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingAttr);
|
||||
}
|
||||
SECTION("When the root tag has a bad attribute") {
|
||||
fin.open("files/scenario/bad_root_attr.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_root_attr.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(std::move(doc), scen), xBadAttr);
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadAttr);
|
||||
}
|
||||
SECTION("When an essential toplevel element is missing") {
|
||||
fin.open("files/scenario/missing_toplevel.xml");
|
||||
doc = xmlDocFromStream(fin, "missing_toplevel.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(std::move(doc), scen), xMissingElem);
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingElem);
|
||||
}
|
||||
SECTION("When there are too many intro strings") {
|
||||
fin.open("files/scenario/intro_overflow.xml");
|
||||
doc = xmlDocFromStream(fin, "intro_overflow.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(std::move(doc), scen), xBadNode);
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
|
||||
}
|
||||
SECTION("When the scenario pic element is empty") {
|
||||
fin.open("files/scenario/missing_pic.xml");
|
||||
doc = xmlDocFromStream(fin, "missing_pic.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), Exception);
|
||||
}
|
||||
SECTION("When the scenario version is invalid") {
|
||||
fin.open("files/scenario/bad_version.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_version.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), string);
|
||||
}
|
||||
SECTION("When the author email is missing") {
|
||||
fin.open("files/scenario/missing_email.xml");
|
||||
doc = xmlDocFromStream(fin, "missing_email.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), Exception);
|
||||
}
|
||||
SECTION("When a scenario rating is missing") {
|
||||
fin.open("files/scenario/missing_rating.xml");
|
||||
doc = xmlDocFromStream(fin, "missing_rating.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), Exception);
|
||||
}
|
||||
SECTION("When there are too many teaser strings") {
|
||||
fin.open("files/scenario/extra_teaser.xml");
|
||||
doc = xmlDocFromStream(fin, "extra_teaser.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
|
||||
}
|
||||
SECTION("When some flags are missing") {
|
||||
fin.open("files/scenario/missing_flags.xml");
|
||||
doc = xmlDocFromStream(fin, "missing_flags.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingElem);
|
||||
}
|
||||
SECTION("When it's not OBoE format") {
|
||||
fin.open("files/scenario/bad_format.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_format.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadVal);
|
||||
}
|
||||
SECTION("When an essential <game> child element is missing") {
|
||||
fin.open("files/scenario/missing_game.xml");
|
||||
doc = xmlDocFromStream(fin, "missing_game.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingElem);
|
||||
}
|
||||
SECTION("When an essential <editor> child element is missing") {
|
||||
fin.open("files/scenario/missing_editor.xml");
|
||||
doc = xmlDocFromStream(fin, "missing_editor.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingElem);
|
||||
}
|
||||
SECTION("With an erroneous <graphics> section") {
|
||||
SECTION("Two of them") {
|
||||
fin.open("files/scenario/bad_graphics1.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_graphics1.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
|
||||
}
|
||||
SECTION("Invalid child element") {
|
||||
fin.open("files/scenario/bad_graphics2.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_graphics2.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
|
||||
}
|
||||
SECTION("Invalid attribute") {
|
||||
fin.open("files/scenario/bad_graphics4.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_graphics4.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadAttr);
|
||||
}
|
||||
SECTION("Missing index attribute") {
|
||||
fin.open("files/scenario/bad_graphics3.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_graphics3.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingAttr);
|
||||
}
|
||||
SECTION("Bad graphic type") {
|
||||
fin.open("files/scenario/bad_graphics5.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_graphics5.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user