Browse Source

Added test for parsing an empty element.


git-svn-id: https://svn.microneil.com/svn/CodeDweller-Tests/trunk@55 b3372362-9eaa-4a85-aa2b-6faa1ab7c995
master
adeniz 9 years ago
parent
commit
7874f5676f
1 changed files with 69 additions and 0 deletions
  1. 69
    0
      TestXMLReader/testXMLReader.cpp

+ 69
- 0
TestXMLReader/testXMLReader.cpp View File

@@ -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);

Loading…
Cancel
Save