浏览代码

fix some casting

Lee Thomason 6 年之前
父节点
当前提交
37ccc71008
共有 1 个文件被更改,包括 102 次插入103 次删除
  1. 102 103
      xmltest.cpp

+ 102 - 103
xmltest.cpp

@@ -968,8 +968,8 @@ int main( int argc, const char ** argv )
 			printer.PushAttribute("attrib-int", int(1));
 			printer.PushAttribute("attrib-unsigned", unsigned(2));
 			printer.PushAttribute("attrib-int64", int64_t(3));
-            printer.PushAttribute("attrib-uint64", uint64_t(37));
-            printer.PushAttribute("attrib-bool", true);
+			printer.PushAttribute("attrib-uint64", uint64_t(37));
+			printer.PushAttribute("attrib-bool", true);
 			printer.PushAttribute("attrib-double", 4.0);
 			printer.CloseElement();
 			fclose(printerfp);
@@ -989,112 +989,111 @@ int main( int argc, const char ** argv )
 			XMLTest("attrib-unsigned", unsigned(2), attrib->UnsignedValue(), true);
 			attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-int64");
 			XMLTest("attrib-int64", int64_t(3), attrib->Int64Value(), true);
-            attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-uint64");
-            XMLTest("attrib-uint64", uint64_t(37), attrib->Unsigned64Value(), true);
-            attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-bool");
+			attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-uint64");
+			XMLTest("attrib-uint64", uint64_t(37), attrib->Unsigned64Value(), true);
+			attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-bool");
 			XMLTest("attrib-bool", true, attrib->BoolValue(), true);
 			attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-double");
 			XMLTest("attrib-double", 4.0, attrib->DoubleValue(), true);
 		}
-    // Add API_testcatse :PushDeclaration();PushText();PushComment()
-    {
-      FILE* fp = fopen("resources/out/printer_1.xml","w");
-      XMLPrinter printer(fp);
-  
-      printer.PushDeclaration("version = '1.0' enconding = 'utf-8'");
-  
-      printer.OpenElement("foo");  
-      printer.PushAttribute("attrib-text", "text");
-      
-      printer.OpenElement("text");
-      printer.PushText("Tinyxml2");
-      printer.CloseElement();
-      
-      printer.OpenElement("int");
-      printer.PushText(int(11));
-      printer.CloseElement();
-      
-      printer.OpenElement("unsigned");
-      printer.PushText(unsigned(12));
-      printer.CloseElement();
-      
-      printer.OpenElement("int64_t");
-      printer.PushText(int64_t(13));
-      printer.CloseElement();
-      
-      printer.OpenElement("uint64_t");
-      printer.PushText(uint64_t(14));
-      printer.CloseElement();
-      
-      printer.OpenElement("bool");
-      printer.PushText(true);
-      printer.CloseElement();
-      
-      printer.OpenElement("float");
-      printer.PushText("1.56");
-      printer.CloseElement();
-      
-      printer.OpenElement("double");
-      printer.PushText("12.12");
-      printer.CloseElement();
-      
-      printer.OpenElement("comment");
-      printer.PushComment("this is Tinyxml2");
-      printer.CloseElement();
-      
-      printer.CloseElement();
-      fclose(fp);
-    }
-    {
-      XMLDocument doc;
-      doc.LoadFile("resources/out/printer_1.xml");
-      XMLTest("XMLPrinter Stream mode: load", XML_SUCCESS, doc.ErrorID(), true);
-
-      const XMLDocument& cdoc = doc;
-
-      const  XMLElement* root = cdoc.FirstChildElement("foo");
-      
-      const char * text_value;
-      text_value = root->FirstChildElement("text")->GetText();
-      XMLTest("PushText( const char* text, bool cdata=false ) test","Tinyxml2",text_value);
-
-      int  int_value;
-      int_value = root->FirstChildElement("int")->IntText();
-      XMLTest("PushText( int value ) test",11,int_value);
-      
-      unsigned  unsigned_value;
-      unsigned_value = root->FirstChildElement("unsigned")->UnsignedText();
-      XMLTest("PushText( unsigned value ) test",12,unsigned_value);
-      
-      int64_t  int64_t_value;
-      int64_t_value = root->FirstChildElement("int64_t")->Int64Text();
-      XMLTest("PushText( int64_t value ) test",13,int64_t_value);
-      
-      uint64_t uint64_t_value;
-      uint64_t_value = root->FirstChildElement("uint64_t")->Unsigned64Text();
-      XMLTest("PushText( uint64_t value ) test",14,uint64_t_value);
-      
-      float  float_value;
-      float_value = root->FirstChildElement("float")->FloatText();
-      XMLTest("PushText( float value ) test",1.56,float_value);
-      
-      double double_value;
-      double_value = root->FirstChildElement("double")->DoubleText();
-      XMLTest("PushText( double value ) test",12.12,double_value);
-      
-      bool bool_value;
-      bool_value = root->FirstChildElement("bool")->BoolText();
-      XMLTest("PushText( bool value ) test",true,bool_value);
-      
-      const XMLComment * comment = root->FirstChildElement("comment")->FirstChild()->ToComment();
-      const char * comment_value = comment->Value();
-      XMLTest("PushComment() test","this is Tinyxml2",comment_value);
-      
-      const XMLDeclaration * declaration = cdoc.FirstChild()->ToDeclaration();
-      const char * declaration_value = declaration->Value();
-      XMLTest("PushDeclaration() test","version = '1.0' enconding = 'utf-8'",declaration_value);
+		// Add API_testcatse :PushDeclaration();PushText();PushComment()
+		{
+			FILE* fp1 = fopen("resources/out/printer_1.xml", "w");
+			XMLPrinter printer(fp1);
 
-    }
+			printer.PushDeclaration("version = '1.0' enconding = 'utf-8'");
+
+			printer.OpenElement("foo");
+			printer.PushAttribute("attrib-text", "text");
+
+			printer.OpenElement("text");
+			printer.PushText("Tinyxml2");
+			printer.CloseElement();
+
+			printer.OpenElement("int");
+			printer.PushText(int(11));
+			printer.CloseElement();
+
+			printer.OpenElement("unsigned");
+			printer.PushText(unsigned(12));
+			printer.CloseElement();
+
+			printer.OpenElement("int64_t");
+			printer.PushText(int64_t(13));
+			printer.CloseElement();
+
+			printer.OpenElement("uint64_t");
+			printer.PushText(uint64_t(14));
+			printer.CloseElement();
+
+			printer.OpenElement("bool");
+			printer.PushText(true);
+			printer.CloseElement();
+
+			printer.OpenElement("float");
+			printer.PushText("1.56");
+			printer.CloseElement();
+
+			printer.OpenElement("double");
+			printer.PushText("12.12");
+			printer.CloseElement();
+
+			printer.OpenElement("comment");
+			printer.PushComment("this is Tinyxml2");
+			printer.CloseElement();
+
+			printer.CloseElement();
+			fclose(fp1);
+		}
+		{
+			XMLDocument doc;
+			doc.LoadFile("resources/out/printer_1.xml");
+			XMLTest("XMLPrinter Stream mode: load", XML_SUCCESS, doc.ErrorID(), true);
+
+			const XMLDocument& cdoc = doc;
+
+			const  XMLElement* root = cdoc.FirstChildElement("foo");
+
+			const char* text_value;
+			text_value = root->FirstChildElement("text")->GetText();
+			XMLTest("PushText( const char* text, bool cdata=false ) test", "Tinyxml2", text_value);
+
+			int  int_value;
+			int_value = root->FirstChildElement("int")->IntText();
+			XMLTest("PushText( int value ) test", 11, int_value);
+
+			unsigned  unsigned_value;
+			unsigned_value = root->FirstChildElement("unsigned")->UnsignedText();
+			XMLTest("PushText( unsigned value ) test", (unsigned)12, unsigned_value);
+
+			int64_t  int64_t_value;
+			int64_t_value = root->FirstChildElement("int64_t")->Int64Text();
+			XMLTest("PushText( int64_t value ) test", (int64_t) 13, int64_t_value);
+
+			uint64_t uint64_t_value;
+			uint64_t_value = root->FirstChildElement("uint64_t")->Unsigned64Text();
+			XMLTest("PushText( uint64_t value ) test", (uint64_t) 14, uint64_t_value);
+
+			float  float_value;
+			float_value = root->FirstChildElement("float")->FloatText();
+			XMLTest("PushText( float value ) test", 1.56f, float_value);
+
+			double double_value;
+			double_value = root->FirstChildElement("double")->DoubleText();
+			XMLTest("PushText( double value ) test", 12.12, double_value);
+
+			bool bool_value;
+			bool_value = root->FirstChildElement("bool")->BoolText();
+			XMLTest("PushText( bool value ) test", true, bool_value);
+
+			const XMLComment* comment = root->FirstChildElement("comment")->FirstChild()->ToComment();
+			const char* comment_value = comment->Value();
+			XMLTest("PushComment() test", "this is Tinyxml2", comment_value);
+
+			const XMLDeclaration* declaration = cdoc.FirstChild()->ToDeclaration();
+			const char* declaration_value = declaration->Value();
+			XMLTest("PushDeclaration() test", "version = '1.0' enconding = 'utf-8'", declaration_value);
+		}
 	}