test/TestXml.cpp
Go to the documentation of this file.
1 /*
2  * Unit tests for XmlRpc++
3  *
4  * Copyright (C) 2017, Zoox Inc
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Author: Austin Hendrix <austin@zoox.com>
21  * Loosely based on the original TestXml.cpp by Chris Morley
22  *
23  */
24 
25 // TestXml.cpp : Test XML encoding and decoding.
26 // The characters <>&'" are illegal in xml and must be encoded.
27 
28 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
29 
30 #include <iostream>
31 // If you are using MSVC++6, you should update <string> to fix
32 // BUG: getline Template Function Reads Extra Character
33 #include <string>
34 #include <stdlib.h>
35 
36 #include "xmlrpcpp/XmlRpcUtil.h"
37 
38 #include <gtest/gtest.h>
39 
40 using namespace XmlRpc;
41 
42 TEST(XmlRpc, BasicXml) {
43  // Basic tests
44  std::string empty;
45  EXPECT_EQ(empty, XmlRpcUtil::xmlEncode(empty));
46  EXPECT_EQ(empty, XmlRpcUtil::xmlDecode(empty));
47  EXPECT_EQ(empty, XmlRpcUtil::xmlEncode(""));
48  EXPECT_EQ(empty, XmlRpcUtil::xmlDecode(""));
49 
50  std::string raw("<>&'\"");
51  EXPECT_EQ(XmlRpcUtil::xmlDecode(XmlRpcUtil::xmlEncode(raw)), raw);
52 }
53 
54 int main(int argc, char **argv)
55 {
56  ::testing::InitGoogleTest(&argc, argv);
57  return RUN_ALL_TESTS();
58 }
TEST(xmlrpcvalue_base64, empty_string)
int main(int argc, char **argv)
static std::string xmlEncode(const std::string &raw)
Convert raw text to encoded xml.
Definition: XmlRpcUtil.cpp:299
static std::string xmlDecode(const std::string &encoded)
Convert encoded xml to raw text.
Definition: XmlRpcUtil.cpp:262


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix, Dirk Thomas
autogenerated on Mon Feb 28 2022 23:33:22