More scenario reading test cases
This commit is contained in:
@@ -47,7 +47,13 @@
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="keyword" minOccurs="1" maxOccurs="2" type="xs:string"/>
|
||||
<xs:element name="type" type="xs:token"/>
|
||||
<xs:element name="type">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[a-z-]+"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="param" minOccurs="0" maxOccurs="4" type="xs:integer"/>
|
||||
<xs:element name="text" minOccurs="1" maxOccurs="2" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
|
||||
45
test/files/scenario/special_item-bad_attr.xml
Normal file
45
test/files/scenario/special_item-bad_attr.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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/>
|
||||
<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" />
|
||||
<special-item type='42'>
|
||||
<name>My Special Item</name>
|
||||
<description><![CDATA[Special Item -- Description!]]></description>
|
||||
</special-item>
|
||||
</game>
|
||||
<editor>
|
||||
<default-ground>2</default-ground>
|
||||
<last-out-section x="0" y="0" />
|
||||
<last-town>0</last-town>
|
||||
</editor>
|
||||
</scenario>
|
||||
45
test/files/scenario/special_item-bad_elem.xml
Normal file
45
test/files/scenario/special_item-bad_elem.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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/>
|
||||
<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" />
|
||||
<special-item>
|
||||
<title>My Special Item</title>
|
||||
<description><![CDATA[Special Item -- Description!]]></description>
|
||||
</special-item>
|
||||
</game>
|
||||
<editor>
|
||||
<default-ground>2</default-ground>
|
||||
<last-out-section x="0" y="0" />
|
||||
<last-town>0</last-town>
|
||||
</editor>
|
||||
</scenario>
|
||||
44
test/files/scenario/special_item-missing_elem.xml
Normal file
44
test/files/scenario/special_item-missing_elem.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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/>
|
||||
<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" />
|
||||
<special-item>
|
||||
<description><![CDATA[Special Item -- Description!]]></description>
|
||||
</special-item>
|
||||
</game>
|
||||
<editor>
|
||||
<default-ground>2</default-ground>
|
||||
<last-out-section x="0" y="0" />
|
||||
<last-town>0</last-town>
|
||||
</editor>
|
||||
</scenario>
|
||||
@@ -157,13 +157,30 @@ TEST_CASE("Loading a new-format scenario record") {
|
||||
CHECK(scen.last_town_edited == 0);
|
||||
}
|
||||
SECTION("With a special item") {
|
||||
fin.open("files/scenario/special_item.xml");
|
||||
doc = xmlDocFromStream(fin, "special_item.xml");
|
||||
REQUIRE_NOTHROW(readScenarioFromXml(move(doc), scen));
|
||||
CHECK(scen.special_items.size() == 1);
|
||||
CHECK(scen.special_items[0].name == "My Special Item");
|
||||
CHECK(scen.special_items[0].descr == "Special Item -- Description!");
|
||||
CHECK(scen.special_items[0].flags == 0);
|
||||
CHECK(scen.special_items[0].special == -1);
|
||||
SECTION("Valid") {
|
||||
fin.open("files/scenario/special_item.xml");
|
||||
doc = xmlDocFromStream(fin, "special_item.xml");
|
||||
REQUIRE_NOTHROW(readScenarioFromXml(move(doc), scen));
|
||||
CHECK(scen.special_items.size() == 1);
|
||||
CHECK(scen.special_items[0].name == "My Special Item");
|
||||
CHECK(scen.special_items[0].descr == "Special Item -- Description!");
|
||||
CHECK(scen.special_items[0].flags == 0);
|
||||
CHECK(scen.special_items[0].special == -1);
|
||||
}
|
||||
SECTION("Invalid attribute") {
|
||||
fin.open("files/scenario/special_item-bad_attr.xml");
|
||||
doc = xmlDocFromStream(fin, "special_item-bad_attr.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadAttr);
|
||||
}
|
||||
SECTION("Invalid element") {
|
||||
fin.open("files/scenario/special_item-bad_elem.xml");
|
||||
doc = xmlDocFromStream(fin, "special_item-bad_elem.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xBadNode);
|
||||
}
|
||||
SECTION("Missing name") {
|
||||
fin.open("files/scenario/special_item-missing_elem.xml");
|
||||
doc = xmlDocFromStream(fin, "special_item-missing_elem.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), xMissingElem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user