- Involves a hack-mod of ticpp::Text to support it (for some reason, the support was there in TinyXML but not exposed by ticpp) - Don't save all the intro strings if most are empty - Don't save the init special if there isn't one - Fix not saving the "I don't know" response for dialogue personalities Strings that now preserve spaces: - Descriptions of items, special items, and quests - Descriptions of special shop items that call a special node when purchased - Scenario, town, and outdoor strings - Sign strings - Journal strings - All dialogue strings (both in personalities and in talk nodes)
47 lines
1.6 KiB
C++
47 lines
1.6 KiB
C++
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include "ticpp.h"
|
|
#include "dialog.hpp"
|
|
#include "catch.hpp"
|
|
#include "scenario.hpp"
|
|
|
|
using namespace std;
|
|
using namespace ticpp;
|
|
|
|
extern Document xmlDocFromStream(istream& stream, string name);
|
|
extern void readScenarioFromXml(Document&& data, cScenario& scenario);
|
|
|
|
TEST_CASE("Loading a new-format scenario record") {
|
|
ifstream fin;
|
|
cScenario scen;
|
|
Document doc;
|
|
fin.exceptions(ios::badbit);
|
|
|
|
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);
|
|
}
|
|
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);
|
|
}
|
|
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);
|
|
}
|
|
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);
|
|
}
|
|
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);
|
|
}
|
|
}
|