Merge pull request #667 from Dmitry-Me/simplifyToUnknownTests
Simplify checks
diff --git a/xmltest.cpp b/xmltest.cpp
index 1711ee6..99ebc24 100644
--- a/xmltest.cpp
+++ b/xmltest.cpp
@@ -1957,7 +1957,7 @@
doc.Parse(xml1);
XMLTest("Test that the second declaration is allowed", false, doc.Error() );
doc.Parse(xml2);
- XMLTest("Test that declaration after a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() );
+ XMLTest("Test that declaration after self-closed child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() );
doc.Parse(xml3);
XMLTest("Test that declaration after a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() );
doc.Parse(xml4);
@@ -1984,8 +1984,14 @@
for( int i = 0; i < XML_ERROR_COUNT; i++ ) {
const XMLError error = static_cast<XMLError>(i);
const char* name = XMLDocument::ErrorIDToName(error);
- XMLTest( "ErrorName() after ClearError()", true, name != 0 );
- XMLTest( "ErrorName() after ClearError()", true, strlen(name) > 0 );
+ XMLTest( "ErrorName() not null after ClearError()", true, name != 0 );
+ if( name == 0 ) {
+ // passing null pointer into strlen() is undefined behavior, so
+ // compiler is allowed to optimise away the null test above if it's
+ // as reachable as the strlen() call
+ continue;
+ }
+ XMLTest( "ErrorName() not empty after ClearError()", true, strlen(name) > 0 );
}
}