File: xml.cpp

package info (click to toggle)
xmlrpc-c 1.60.05-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,132 kB
  • sloc: ansic: 55,332; cpp: 13,541; sh: 3,321; makefile: 2,556; perl: 593; xml: 134
file content (100 lines) | stat: -rw-r--r-- 2,078 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*=============================================================================
                                   xml
===============================================================================
  Test the XML generator and parser C++ facilities of XML-RPC for C/C++.
  
=============================================================================*/

#include <string>

#include "xmlrpc-c/girerr.hpp"
using girerr::error;
using girerr::throwf;
#include "xmlrpc-c/base.hpp"
#include "xmlrpc-c/xml.hpp"

#include "tools.hpp"
#include "xml.hpp"

using namespace xmlrpc_c;
using namespace std;


namespace  {

class callTestSuite : public testSuite {

public:
    virtual string suiteName() {
        return "callTestSuite";
    }
    virtual void runtests(unsigned int const) {

        string callXml;

        string const methodName0("myMethod");
        paramList const paramList0;

        xml::generateCall(methodName0, paramList(), &callXml);

        string methodName;
        paramList paramList;

        xml::parseCall(callXml, &methodName, &paramList);

        TEST(methodName == methodName0);
        TEST(paramList.size() == paramList0.size());
    }
};



class responseTestSuite : public testSuite {

public:
    virtual string suiteName() {
        return "responseTestSuite";
    }
    virtual void runtests(unsigned int const) {

        string respXml;

        rpcOutcome outcome0(value_int(7));

        xml::generateResponse(outcome0, &respXml);

        rpcOutcome outcome;

        xml::parseResponse(respXml, &outcome);
        
        TEST((int)value_int(outcome.getResult()) ==
             (int)value_int(outcome0.getResult()));

        value result;

        xml::parseSuccessfulResponse(respXml, &result);

        TEST((int)value_int(result) == (int)value_int(outcome0.getResult()));
    }
};



}  // unnamed namespace



string
xmlTestSuite::suiteName() {
    return "XMLTestSuite";
}



void
xmlTestSuite::runtests(unsigned int const indentation) {

    callTestSuite().run(indentation+1);

    responseTestSuite().run(indentation+1);
}