BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TestXml.cpp File Reference
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <string>
#include "XmlRpcUtil.h"

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN

Functions

int main (int argc, char *argv[])

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 4 of file TestXml.cpp.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 17 of file TestXml.cpp.

17 {
18 // Basic tests
19 std::string empty;
20 assert( empty == XmlRpcUtil::xmlEncode( empty ) );
21 assert( empty == XmlRpcUtil::xmlDecode( empty ) );
22 assert( empty == XmlRpcUtil::xmlEncode( "" ) );
23 assert( empty == XmlRpcUtil::xmlDecode( "" ) );
24
25 std::string raw( "<>&'\"" );
26 assert( XmlRpcUtil::xmlDecode( XmlRpcUtil::xmlEncode( raw ) ) == raw );
27
28 std::cout << "Basic tests passed.\n";
29
30 // Interactive tests
31 std::string s;
32 for ( ;; )
33 {
34 std::cout << "\nEnter line of raw text to encode:\n";
35 std::getline( std::cin, s );
36 if ( s.empty() ) break;
37
38 std::cout << XmlRpcUtil::xmlEncode( s ) << std::endl;
39 }
40
41 for ( ;; )
42 {
43 std::cout << "\nEnter line of xml-encoded text to decode:\n";
44 std::getline( std::cin, s );
45 if ( s.empty() ) break;
46
47 std::cout << XmlRpcUtil::xmlDecode( s ) << std::endl;
48 }
49
50 return 0;
51}
XmlRpcServer s
static std::string xmlEncode(const std::string &raw)
Convert raw text to encoded xml.
static std::string xmlDecode(const std::string &encoded)
Convert encoded xml to raw text.