TestXml.cpp
Go to the documentation of this file.
00001 // TestXml.cpp : Test XML encoding and decoding.
00002 // The characters <>&'" are illegal in xml and must be encoded.
00003 
00004 
00005 #define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
00006 
00007 #include <iostream>
00008 // If you are using MSVC++6, you should update <string> to fix
00009 // BUG: getline Template Function Reads Extra Character
00010 #include <string>
00011 #include <assert.h>
00012 #include <stdlib.h>
00013 
00014 #include "XmlRpcUtil.h"
00015 
00016 using namespace XmlRpc;
00017 
00018 
00019 int main(int argc, char* argv[])
00020 {
00021   // Basic tests
00022   std::string empty;
00023   assert(empty == XmlRpcUtil::xmlEncode(empty));
00024   assert(empty == XmlRpcUtil::xmlDecode(empty));
00025   assert(empty == XmlRpcUtil::xmlEncode(""));
00026   assert(empty == XmlRpcUtil::xmlDecode(""));
00027 
00028   std::string raw("<>&'\"");
00029   assert(XmlRpcUtil::xmlDecode(XmlRpcUtil::xmlEncode(raw)) == raw);
00030   
00031   std::cout << "Basic tests passed.\n";
00032 
00033   // Interactive tests
00034   std::string s;
00035   for (;;) {
00036     std::cout << "\nEnter line of raw text to encode:\n";
00037     std::getline(std::cin, s);
00038     if (s.empty()) break;
00039 
00040     std::cout << XmlRpcUtil::xmlEncode(s) << std::endl;
00041   }
00042 
00043   for (;;) {
00044     std::cout << "\nEnter line of xml-encoded text to decode:\n";
00045     std::getline(std::cin, s);
00046     if (s.empty()) break;
00047 
00048     std::cout << XmlRpcUtil::xmlDecode(s) << std::endl;
00049   }
00050 
00051   return 0;
00052 }
00053 


xmlrpcpp
Author(s): Chris Morley and Konstantin Pilipchuk, slight modifications and ROS wrapping by Morgan Quigley
autogenerated on Sat Dec 28 2013 17:42:59