A few more scenario read tests
- Introduce enum for scenario content rating
This commit is contained in:
@@ -59,4 +59,5 @@ TEST_CASE("Enum text conversions") {
|
||||
test_enum(LIGHT_NORMAL, "lit", LIGHT_NONE, "none");
|
||||
test_enum(eTalkNode::REGULAR, "reg", eTalkNode::JOB_BANK, "jobs", eTalkNode::SELL_WEAPONS, "sell-weap", eTalkNode::CALL_SCEN_SPEC, "call-global");
|
||||
test_enum(eAttitude::DOCILE, "docile", eAttitude::HOSTILE_B, "hostile-b");
|
||||
test_enum(eContentRating::G, "G", eContentRating::NC17, "NC-17");
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
21
test/files/scenario/bad_rating.xml
Normal file
21
test/files/scenario/bad_rating.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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>Q</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
</scenario>
|
@@ -16,7 +16,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
@@ -21,7 +21,7 @@
|
||||
<intro-msg></intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
45
test/files/scenario/minimal.xml
Normal file
45
test/files/scenario/minimal.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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>
|
||||
</editor>
|
||||
</scenario>
|
@@ -15,7 +15,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags/>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
<intro-msg>Welcome to the test scenario!</intro-msg>
|
||||
</text>
|
||||
<ratings>
|
||||
<content>r</content>
|
||||
<content>R</content>
|
||||
<difficulty>3</difficulty>
|
||||
</ratings>
|
||||
<flags>
|
||||
|
45
test/files/scenario/special_item.xml
Normal file
45
test/files/scenario/special_item.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>
|
||||
<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>
|
@@ -63,6 +63,11 @@ TEST_CASE("Loading a new-format scenario record") {
|
||||
doc = xmlDocFromStream(fin, "missing_rating.xml");
|
||||
REQUIRE_THROWS_AS(readScenarioFromXml(move(doc), scen), Exception);
|
||||
}
|
||||
SECTION("When the scenario content rating is invalid") {
|
||||
fin.open("files/scenario/bad_rating.xml");
|
||||
doc = xmlDocFromStream(fin, "bad_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");
|
||||
@@ -115,4 +120,50 @@ TEST_CASE("Loading a new-format scenario record") {
|
||||
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");
|
||||
REQUIRE_NOTHROW(readScenarioFromXml(move(doc), scen));
|
||||
CHECK(scen.scen_name == "Test Scenario");
|
||||
CHECK(scen.intro_pic == 7);
|
||||
CHECK(scen.campaign_id == "campaign");
|
||||
CHECK(scen.format.prog_make_ver[0] == 2);
|
||||
CHECK(scen.format.prog_make_ver[1] == 5);
|
||||
CHECK(scen.format.prog_make_ver[2] == 3);
|
||||
CHECK(scen.format.ver[0] == 2);
|
||||
CHECK(scen.format.ver[1] == 6);
|
||||
CHECK(scen.format.ver[2] == 7);
|
||||
// TODO: Check language
|
||||
CHECK(scen.contact_info[0] == "BoE Test Suite");
|
||||
CHECK(scen.contact_info[1] == "nowhere@example.com");
|
||||
CHECK(scen.who_wrote[0] == "Teaser 1");
|
||||
CHECK(scen.who_wrote[1] == "Teaser 2");
|
||||
CHECK(scen.intro_mess_pic == 7);
|
||||
CHECK(scen.intro_strs[0] == "Welcome!!! To the test scenario!");
|
||||
CHECK(scen.rating == eContentRating::R);
|
||||
CHECK(scen.difficulty == 2); // Difficulty is 3, but it's stored as 2 (0-3 instead of 1-4)
|
||||
CHECK(scen.adjust_diff == true);
|
||||
CHECK(scen.is_legacy == false);
|
||||
CHECK(scen.uses_custom_graphics == false);
|
||||
CHECK(scen.towns.size() == 3);
|
||||
CHECK(scen.outdoors.width() == 2);
|
||||
CHECK(scen.outdoors.height() == 1);
|
||||
CHECK(scen.which_town_start == 7);
|
||||
CHECK(scen.where_start == loc(24,28));
|
||||
CHECK(scen.out_sec_start == loc(1,3));
|
||||
CHECK(scen.out_start == loc(12,21));
|
||||
CHECK(scen.default_ground == 2);
|
||||
CHECK(scen.last_out_edited == loc(0,0));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ TEST_CASE("Saving a scenario record") {
|
||||
scen.contact_info[0] = "BoE Test Suite";
|
||||
scen.contact_info[1] = "nowhere@example.com";
|
||||
scen.intro_strs[0] = "Welcome to the test scenario!";
|
||||
scen.rating = 2;
|
||||
scen.rating = eContentRating::R;
|
||||
scen.difficulty = 2;
|
||||
scen.which_town_start = 7;
|
||||
scen.where_start = {24,28};
|
||||
@@ -72,7 +72,7 @@ TEST_CASE("Saving a scenario record") {
|
||||
CHECK(scen.contact_info[0] == "BoE Test Suite");
|
||||
CHECK(scen.contact_info[1] == "nowhere@example.com");
|
||||
CHECK(scen.intro_strs[0] == "Welcome to the test scenario!");
|
||||
CHECK(scen.rating == 2);
|
||||
CHECK(scen.rating == eContentRating::R);
|
||||
CHECK(scen.difficulty == 2);
|
||||
CHECK(scen.which_town_start == 7);
|
||||
CHECK(scen.where_start == loc(24,28));
|
||||
|
Reference in New Issue
Block a user