From 43c019d44e79ea7490aace4c8ce9a7f5c9315604 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Wed, 2 Aug 2017 18:05:23 +0300 Subject: [PATCH] Better tests for Query???Text() --- xmltest.cpp | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/xmltest.cpp b/xmltest.cpp index 3fada04..6dd3b42 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -1442,24 +1442,40 @@ 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; + { + int intValue = 0; + XMLError queryResult = pointElement->FirstChildElement( "y" )->QueryIntText( &intValue ); + XMLTest( "QueryIntText result", XML_SUCCESS, queryResult, false ); + XMLTest( "QueryIntText", 1, intValue, 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 ); + { + 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 ); + } - XMLTest( "QueryIntText", 1, intValue, false ); - XMLTest( "QueryUnsignedText", (unsigned)1, unsignedValue, false ); - XMLTest( "QueryFloatText", 1.2f, floatValue, false ); - XMLTest( "QueryDoubleText", 1.2, doubleValue, false ); - XMLTest( "QueryBoolText", true, boolValue, 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 ); + } } {