mirror of https://github.com/AxioDL/tinyxml2.git
Added static method to convert arbitrary ErrorID to a string.
Updated tests to print ErrorID and bool values as strings.
This commit is contained in:
parent
f80d78d938
commit
5a70071241
11
tinyxml2.cpp
11
tinyxml2.cpp
|
@ -2226,14 +2226,19 @@ void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 )
|
|||
_errorStr2.SetStr(str2);
|
||||
}
|
||||
|
||||
const char* XMLDocument::ErrorName() const
|
||||
const char* XMLDocument::ErrorName(XMLError errorID)
|
||||
{
|
||||
TIXMLASSERT( _errorID >= 0 && _errorID < XML_ERROR_COUNT );
|
||||
const char* errorName = _errorNames[_errorID];
|
||||
TIXMLASSERT( errorID >= 0 && errorID < XML_ERROR_COUNT );
|
||||
const char* errorName = _errorNames[errorID];
|
||||
TIXMLASSERT( errorName && errorName[0] );
|
||||
return errorName;
|
||||
}
|
||||
|
||||
const char* XMLDocument::ErrorName() const
|
||||
{
|
||||
return ErrorName(_errorID);
|
||||
}
|
||||
|
||||
void XMLDocument::PrintError() const
|
||||
{
|
||||
if ( Error() ) {
|
||||
|
|
|
@ -1749,6 +1749,7 @@ public:
|
|||
return _errorID;
|
||||
}
|
||||
const char* ErrorName() const;
|
||||
static const char* ErrorName(XMLError errorID);
|
||||
|
||||
/// Return a possibly helpful diagnostic location or string.
|
||||
const char* GetErrorStr1() const {
|
||||
|
|
|
@ -63,6 +63,15 @@ bool XMLTest (const char* testString, const char* expected, const char* found, b
|
|||
return pass;
|
||||
}
|
||||
|
||||
bool XMLTest(const char* testString, XMLError expected, XMLError found, bool echo = true, bool extraNL = false)
|
||||
{
|
||||
return XMLTest(testString, XMLDocument::ErrorName(expected), XMLDocument::ErrorName(found), echo, extraNL);
|
||||
}
|
||||
|
||||
bool XMLTest(const char* testString, bool expected, bool found, bool echo = true, bool extraNL = false)
|
||||
{
|
||||
return XMLTest(testString, expected ? "true" : "false", found ? "true" : "false", echo, extraNL);
|
||||
}
|
||||
|
||||
template< class T > bool XMLTest( const char* testString, T expected, T found, bool echo=true )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue