21 XmlRpcValue booleanFalseXml(
"<value><boolean>0</boolean></value>", &offset);
23 XmlRpcValue booleanTrueXml(
"<value><boolean>1</boolean></value>", &offset);
24 assert(booleanFalse != booleanTrue);
25 assert(booleanFalse == booleanFalseXml);
26 assert(booleanFalse != booleanTrueXml);
28 if (
bool(booleanFalse))
31 if ( !
bool(booleanTrue))
43 XmlRpcValue int0Xml(
"<value><int>0</int></value>", &offset);
45 XmlRpcValue int9Xml(
"<value><i4>9</i4></value>", &offset);
46 assert(int0 == int0Xml);
47 assert(
int(int10) -
int(int1) ==
int(int9Xml));
48 assert(9 ==
int(int9Xml));
49 assert(
int(int10) +
int(int_1) ==
int(int9Xml));
57 XmlRpcValue dXml(
"<value><double>56.3</double></value>", &offset);
58 assert(
double(d) +
double(dXml) == 100.0);
65 char csxml[] =
"<value><string>Now is the time <&</string></value>";
66 std::string ssxml = csxml;
78 std::string emptyStringXml(
"<value></value>");
80 XmlRpcValue emptyStringVal1(emptyStringXml, &offset);
82 assert(emptyStringVal1 == emptyStringVal2);
84 emptyStringXml =
"<value> </value>";
86 XmlRpcValue blankStringVal(emptyStringXml, &offset);
87 assert(std::string(blankStringVal) ==
" ");
93 std::string xml =
"<tag><nexttag>";
94 xml += std::string(__INT_MAX__,
'a');
95 xml +=
"a</nextag></tag>";
114 catch (std::bad_alloc& err) {
115 std::cerr <<
"[ SKIPPED ] XmlRpc.testOversizeString Unable to allocate memory to run test\n";
124 XmlRpcValue dateTime(
"<value><dateTime.iso8601>19040101T03:12:35</dateTime.iso8601></value>", &offset);
125 struct tm &t = dateTime;
126 assert(t.tm_year == 1904 && t.tm_min == 12);
136 a[1] = std::string(
"two");
139 assert(
int(a[0]) == 1);
145 " <value><i4>1</i4></value> \n" 146 " <value> <string>two</string></value>\n" 147 " <value><double>43.7</double></value>\n" 148 " <value>four</value>\n" 162 struct1[
"str"] =
"two";
168 a[1] = std::string(
"two");
172 assert(struct1[
"d"] == a[2]);
177 " <name>i4</name> \n" 178 " <value><i4>1</i4></value> \n" 182 " <value><double>43.7</double></value>\n" 185 " <name>str</name> \n" 186 " <value> <string>two</string></value>\n" 192 assert(struct1 == structXml);
195 astruct[
"array"] = a;
196 assert(astruct[
"array"][2] == struct1[
"d"]);
198 for (
int i=0; i<10; i++) {
200 Event[
"Name"] =
"string";
204 const int NELMTS = 100;
207 for (ii=0; ii< NELMTS; ++ii) {
209 sprintf(buf,
"%d", ii);
210 Event[std::string(buf)] = buf;
215 for (ii=0; ii< NELMTS; ++ii) {
217 sprintf(buf,
"%d", ii);
219 Event[std::string(buf)] = ii;
221 for (
int jj=0; jj< NELMTS; ++jj) {
223 sprintf(bufj,
"%d", jj);
224 Event[std::string(buf)][std::string(bufj)] = bufj;
228 for (ii=0; ii< NELMTS; ++ii) {
230 sprintf(buf,
"%d", ii);
232 assert(Event[std::string(buf)] ==
XmlRpcValue(ii));
234 assert(Event[std::string(buf)].size() == NELMTS);
241 int main(
int argc,
char* argv[])
RPC method arguments and results are represented by Values.
static std::string getNextTag(std::string const &xml, int *offset)
static std::string parseTag(const char *tag, std::string const &xml, int *offset)
Returns contents between <tag> and </tag>, updates offset to char after </tag>
static bool findTag(const char *tag, std::string const &xml, int *offset)
Returns true if the tag is found and updates offset to the char after the tag.
void clear()
Erase the current value.
void testArray(XmlRpcValue const &d)
std::string toXml() const
Encode the Value in xml.
void setSize(int size)
Specify the size for array values. Array values will grow beyond this size if needed.
int main(int argc, char *argv[])
static bool nextTagIs(const char *tag, std::string const &xml, int *offset)