Better tests for Query???Text()

This commit is contained in:
Dmitry-Me 2017-08-02 18:05:23 +03:00
parent 02d2764fd7
commit 43c019d44e
1 changed files with 31 additions and 15 deletions

View File

@ -1442,25 +1442,41 @@ int main( int argc, const char ** argv )
const XMLElement* pointElement = doc.RootElement();
{
int intValue = 0;
unsigned unsignedValue = 0;
float floatValue = 0;
double doubleValue = 0;
bool boolValue = false;
pointElement->FirstChildElement( "y" )->QueryIntText( &intValue );
pointElement->FirstChildElement( "y" )->QueryUnsignedText( &unsignedValue );
pointElement->FirstChildElement( "x" )->QueryFloatText( &floatValue );
pointElement->FirstChildElement( "x" )->QueryDoubleText( &doubleValue );
pointElement->FirstChildElement( "valid" )->QueryBoolText( &boolValue );
XMLError queryResult = pointElement->FirstChildElement( "y" )->QueryIntText( &intValue );
XMLTest( "QueryIntText result", XML_SUCCESS, queryResult, false );
XMLTest( "QueryIntText", 1, intValue, false );
}
{
unsigned unsignedValue = 0;
XMLError queryResult = pointElement->FirstChildElement( "y" )->QueryUnsignedText( &unsignedValue );
XMLTest( "QueryUnsignedText result", XML_SUCCESS, queryResult, false );
XMLTest( "QueryUnsignedText", (unsigned)1, unsignedValue, false );
}
{
float floatValue = 0;
XMLError queryResult = pointElement->FirstChildElement( "x" )->QueryFloatText( &floatValue );
XMLTest( "QueryFloatText result", XML_SUCCESS, queryResult, false );
XMLTest( "QueryFloatText", 1.2f, floatValue, false );
}
{
double doubleValue = 0;
XMLError queryResult = pointElement->FirstChildElement( "x" )->QueryDoubleText( &doubleValue );
XMLTest( "QueryDoubleText result", XML_SUCCESS, queryResult, false );
XMLTest( "QueryDoubleText", 1.2, doubleValue, false );
}
{
bool boolValue = false;
XMLError queryResult = pointElement->FirstChildElement( "valid" )->QueryBoolText( &boolValue );
XMLTest( "QueryBoolText result", XML_SUCCESS, queryResult, false );
XMLTest( "QueryBoolText", true, boolValue, false );
}
}
{
const char* xml = "<element><_sub/><:sub/><sub:sub/><sub-sub/></element>";