|
|
@@ -49,6 +49,74 @@ bool result; |
|
|
|
// Tests ///////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
bool testEmptyElement() {
|
|
|
|
|
|
|
|
std::string stageContent, stage1Content, stage2Content;
|
|
|
|
CodeDweller::XMLReaderElement reader("elem");
|
|
|
|
|
|
|
|
reader
|
|
|
|
.Element("stage", stageContent)
|
|
|
|
.End("stage")
|
|
|
|
.Element("stage1", stage1Content)
|
|
|
|
.End("stage1")
|
|
|
|
.Element("stage2", stage2Content)
|
|
|
|
.End("stage2")
|
|
|
|
.End("elem");
|
|
|
|
|
|
|
|
std::string xml;
|
|
|
|
|
|
|
|
xml = "<elem/>";
|
|
|
|
|
|
|
|
CodeDweller::XMLReaderData confData(xml.data(), xml.size());
|
|
|
|
|
|
|
|
reader.initialize();
|
|
|
|
|
|
|
|
if (0 == reader.interpret(confData)) {
|
|
|
|
RETURN_FALSE("Error parsing XML: " + confData.Log.str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(stageContent.empty() &&
|
|
|
|
stage1Content.empty() &&
|
|
|
|
stage2Content.empty())) {
|
|
|
|
RETURN_FALSE("empty element 1 read failure");
|
|
|
|
}
|
|
|
|
|
|
|
|
xml = "<elem></elem>";
|
|
|
|
|
|
|
|
CodeDweller::XMLReaderData confData1(xml.data(), xml.size());
|
|
|
|
|
|
|
|
reader.initialize();
|
|
|
|
|
|
|
|
if (0 == reader.interpret(confData1)) {
|
|
|
|
RETURN_FALSE("Error parsing XML: " + confData.Log.str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(stageContent.empty() &&
|
|
|
|
stage1Content.empty() &&
|
|
|
|
stage2Content.empty())) {
|
|
|
|
RETURN_FALSE("empty element 2 read failure");
|
|
|
|
}
|
|
|
|
|
|
|
|
xml = "<elem>Should be<xx> abc </xx> ignored<stage></elem>";
|
|
|
|
|
|
|
|
CodeDweller::XMLReaderData confData2(xml.data(), xml.size());
|
|
|
|
|
|
|
|
reader.initialize();
|
|
|
|
|
|
|
|
if (0 == reader.interpret(confData2)) {
|
|
|
|
RETURN_FALSE("Error parsing XML: " + confData.Log.str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(stageContent.empty() &&
|
|
|
|
stage1Content.empty() &&
|
|
|
|
stage2Content.empty())) {
|
|
|
|
RETURN_FALSE("empty element 3 read failure");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool testSimilarElementName() {
|
|
|
|
|
|
|
|
std::string stageContent, stage1Content, stage2Content;
|
|
|
@@ -388,6 +456,7 @@ int main() |
|
|
|
std::cout << "CodeDweller::XMLReader unit tests" << std::endl
|
|
|
|
<< std::endl;
|
|
|
|
|
|
|
|
RUN_TEST(testEmptyElement);
|
|
|
|
RUN_TEST(testSimilarElementName);
|
|
|
|
RUN_TEST(testSimilarAttributeName);
|
|
|
|
RUN_TEST(testNullAttributeValue);
|