35 #include <gtest/gtest.h>
42 EXPECT_EQ(
"<value><boolean>0</boolean></value>", v.
toXml());
46 v2[1] = std::string();
48 EXPECT_EQ(
"<value><array><data><value><i4>1</i4></value><value></"
49 "value><value><boolean>0</boolean></value></data></array></value>",
57 XmlRpcValue booleanFalseXml(
"<value><boolean>0</boolean></value>", &offset);
59 XmlRpcValue booleanTrueXml(
"<value><boolean>1</boolean></value>", &offset);
60 EXPECT_NE(booleanFalse, booleanTrue);
61 EXPECT_EQ(booleanFalse, booleanFalseXml);
62 EXPECT_NE(booleanFalse, booleanTrueXml);
64 EXPECT_FALSE(
bool(booleanFalse));
66 EXPECT_TRUE(
bool(booleanTrue));
71 EXPECT_EQ(
"0", ss.str());
73 std::stringstream ss2;
75 EXPECT_EQ(
"1", ss2.str());
78 EXPECT_EQ(booleanFalse.toXml(), ::testing::PrintToString(booleanFalse));
96 XmlRpcValue int0Xml(
"<value><int>0</int></value>", &offset);
98 EXPECT_EQ(0,
int(int0Xml));
101 XmlRpcValue int9Xml(
"<value><i4>9</i4></value>", &offset);
103 EXPECT_EQ(9,
int(int9Xml));
105 EXPECT_EQ(int0, int0Xml);
106 EXPECT_EQ(
int(int10) -
int(int1),
int(int9Xml));
107 EXPECT_EQ(9,
int(int9Xml));
108 EXPECT_EQ(
int(int10) +
int(int_1),
int(int9Xml));
111 std::stringstream ss;
113 EXPECT_EQ(
"9", ss.str());
116 EXPECT_EQ(int0.
toXml(), ::testing::PrintToString(int0));
123 EXPECT_EQ(
"<value><double>43.700000000000003</double></value>", d.
toXml());
124 EXPECT_DOUBLE_EQ(43.7,
double(d));
127 XmlRpcValue dXml(
"<value><double>56.3</double></value>", &offset);
129 EXPECT_DOUBLE_EQ(56.3,
double(dXml));
131 EXPECT_DOUBLE_EQ(100.0,
double(d) +
double(dXml));
134 std::stringstream ss;
136 EXPECT_EQ(
"43.7", ss.str());
146 EXPECT_EQ(
" 2.0000000000", ss.str());
151 EXPECT_EQ(
"2.00000000000000000000000000000000", ss.str());
159 " 2.000000000", ss.str());
164 EXPECT_EQ(
"2.000000000000000000000000000000"
165 "00000000000000000000000000000000"
166 "00000000000000000000000000000000"
167 "000000000000000000000000000000000", ss.str());
173 EXPECT_EQ(d.toXml(), ::testing::PrintToString(d));
180 EXPECT_EQ(18,
s.size());
181 EXPECT_EQ(
"<value>Now is the time <&</value>",
s.toXml());
183 char csxml[] =
"<value><string>Now is the time <&</string></value>";
184 std::string ssxml = csxml;
188 EXPECT_EQ(
s, vscXml);
192 EXPECT_EQ(
s, vssXml);
199 std::string emptyStringXml(
"<value></value>");
201 XmlRpcValue emptyStringVal1(emptyStringXml, &offset);
203 EXPECT_EQ(emptyStringVal1, emptyStringVal2);
205 emptyStringXml =
"<value> </value>";
207 XmlRpcValue blankStringVal(emptyStringXml, &offset);
208 EXPECT_EQ(std::string(blankStringVal),
" ");
212 std::string tmp = s2;
214 EXPECT_EQ(
"", (std::string)s2);
217 std::stringstream ss;
219 EXPECT_EQ(
"Now is the time <&", ss.str());
222 EXPECT_EQ(
s.toXml(), ::testing::PrintToString(
s));
228 std::string xml =
"<tag><nexttag>";
229 xml += std::string(INT_MAX,
'a');
230 xml +=
"a</nexttag></tag>";
235 EXPECT_EQ(offset, 0);
239 EXPECT_EQ(offset, 0);
243 EXPECT_EQ(offset, 0);
247 EXPECT_EQ(offset, 0);
249 catch (std::bad_alloc& err) {
251 GTEST_SKIP() <<
"Unable to allocate memory to run test\n";
253 std::cerr <<
"[ SKIPPED ] XmlRpc.testOversizeString Unable to allocate memory to run test\n";
263 EXPECT_EQ(offset, 0);
267 EXPECT_EQ(offset, 0);
272 EXPECT_EQ(offset, 20);
277 EXPECT_EQ(offset, 0);
281 EXPECT_EQ(offset, 0);
285 EXPECT_EQ(offset, 14);
293 EXPECT_EQ(offset, 0);
297 EXPECT_EQ(offset, 0);
302 EXPECT_EQ(offset, 20);
307 EXPECT_EQ(offset, 13);
315 EXPECT_EQ(offset, 0);
319 EXPECT_EQ(offset, 0);
324 EXPECT_EQ(offset, 20);
329 EXPECT_EQ(offset, 5);
334 EXPECT_EQ(offset, 11);
339 EXPECT_EQ(offset, 0);
347 EXPECT_EQ(offset, 0);
352 EXPECT_EQ(offset, 20);
357 EXPECT_EQ(offset, 5);
362 EXPECT_EQ(offset, 11);
367 EXPECT_EQ(offset, 0);
373 EXPECT_EQ(offset, 4);
378 EXPECT_EQ(offset, 2);
387 EXPECT_EQ(offset, 0);
391 EXPECT_EQ(offset, 0);
396 EXPECT_EQ(offset, 20);
401 EXPECT_EQ(offset, 11);
406 EXPECT_EQ(offset, 14);
411 EXPECT_EQ(offset, 17);
416 EXPECT_EQ(offset, 0);
421 EXPECT_EQ(offset, 0);
426 EXPECT_EQ(offset, 0);
434 "<value><dateTime.iso8601>19040503T03:12:35</dateTime.iso8601></value>",
437 struct tm t = dateTime;
438 EXPECT_EQ(t.tm_year, 1904);
439 EXPECT_EQ(t.tm_min, 12);
440 EXPECT_EQ(t.tm_sec, 35);
441 EXPECT_EQ(t.tm_hour, 3);
442 EXPECT_EQ(t.tm_mday, 3);
443 EXPECT_EQ(t.tm_mon, 5);
446 "<value><dateTime.iso8601>19040503T03:12:35</dateTime.iso8601></value>",
453 EXPECT_EQ(t.tm_year, 1904);
454 EXPECT_EQ(t.tm_min, 12);
460 EXPECT_EQ(t.tm_year, 0);
461 EXPECT_EQ(t.tm_min, 0);
464 std::stringstream ss;
466 EXPECT_EQ(
"19040503T03:12:35", ss.str());
469 EXPECT_EQ(dateTime, dateTime2);
472 dateTime3 = dateTime;
473 EXPECT_EQ(dateTime, dateTime3);
478 struct tm& tm2 = dateTime2;
481 EXPECT_NE(dateTime, dateTime2);
483 ASSERT_EQ(dateTime, dateTime2);
487 EXPECT_NE(dateTime, dateTime2);
489 ASSERT_EQ(dateTime, dateTime2);
493 EXPECT_NE(dateTime, dateTime2);
495 ASSERT_EQ(dateTime, dateTime2);
499 EXPECT_NE(dateTime, dateTime2);
501 ASSERT_EQ(dateTime, dateTime2);
505 EXPECT_NE(dateTime, dateTime2);
507 ASSERT_EQ(dateTime, dateTime2);
511 EXPECT_NE(dateTime, dateTime2);
520 a[1] = std::string(
"two");
524 EXPECT_EQ(
int(a[0]), 1);
527 char csaXml[] =
"<value><array>\n"
529 " <value><i4>1</i4></value> \n"
530 " <value> <string>two</string></value>\n"
531 " <value><double>43.7</double></value>\n"
532 " <value>four</value>\n"
544 for (
int i = 0; i < 3; i++) {
545 EXPECT_EQ(a[i], copy[i]);
554 std::stringstream ss;
556 EXPECT_EQ(
"{1,two,43.7,four}", ss.str());
559 EXPECT_EQ(a.toXml(), ::testing::PrintToString(a));
566 struct1[
"str"] =
"two";
568 EXPECT_EQ(3, struct1.
size());
571 EXPECT_FALSE(struct1.
hasMember(
"nowhere"));
574 std::stringstream ss;
576 EXPECT_EQ(
"[d:43.7,i4:1,str:two]", ss.str());
581 a[1] = std::string(
"two");
585 EXPECT_EQ(struct1[
"d"], a[2]);
587 char csStructXml[] =
"<value><struct>\n"
589 " <name>i4</name> \n"
590 " <value><i4>1</i4></value> \n"
594 " <value><double>43.7</double></value>\n"
597 " <name>str</name> \n"
598 " <value> <string>two</string></value>\n"
604 EXPECT_EQ(struct1, structXml);
611 astruct[
"array"] = a;
612 EXPECT_EQ(astruct[
"array"][2], struct1[
"d"]);
614 for (
int i = 0; i < 10; i++) {
616 Event[
"Name"] =
"string";
620 const int NELMTS = 100;
623 for (ii = 0; ii < NELMTS; ++ii) {
625 sprintf(buf,
"%d", ii);
626 Event[std::string(buf)] = buf;
631 for (ii = 0; ii < NELMTS; ++ii) {
633 sprintf(buf,
"%d", ii);
634 if (ii != NELMTS / 2)
635 Event[std::string(buf)] = ii;
637 for (
int jj = 0; jj < NELMTS; ++jj) {
639 sprintf(bufj,
"%d", jj);
640 Event[std::string(buf)][std::string(bufj)] = bufj;
644 for (ii = 0; ii < NELMTS; ++ii) {
646 sprintf(buf,
"%d", ii);
647 if (ii != NELMTS / 2)
648 EXPECT_EQ(Event[std::string(buf)],
XmlRpcValue(ii));
650 EXPECT_EQ(Event[std::string(buf)].size(), NELMTS);
654 EXPECT_EQ(struct1.toXml(), ::testing::PrintToString(struct1));
658 char data[] = {1, 2};
662 EXPECT_EQ(2, bin.
size());
668 EXPECT_EQ(
"<value><base64>AQI=\n</base64></value>", bin.
toXml());
671 std::stringstream ss;
673 EXPECT_EQ(
"AQI=\n", ss.str());
677 XmlRpcValue bin2(
"<value><base64>AQI=</base64></value>", &offset);
679 EXPECT_EQ(2, bin2.
size());
685 EXPECT_EQ(bin, bin2);
691 EXPECT_EQ(0, bin3.
size());
692 EXPECT_EQ(0u, d.size());
699 EXPECT_EQ(2, bin4.
size());
706 EXPECT_EQ(bin.toXml(), ::testing::PrintToString(bin));
712 EXPECT_FALSE(value.
valid());
713 EXPECT_EQ(
"", value.
toXml());
716 bool v = (bool)value;
743 EXPECT_FALSE(value.valid());
751 EXPECT_EQ(0, (
int)value);
763 EXPECT_EQ(1, value.size());
766 EXPECT_EQ(0, (
int)value[1]);
767 EXPECT_EQ(2, value.size());
781 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
786 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
787 EXPECT_EQ(offset, 20);
792 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
793 EXPECT_EQ(offset, 0);
797 val.
fromXml(
"<value>", &offset);
798 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
799 EXPECT_EQ(offset, 0);
803 val.
fromXml(
"<value><invalid></invalid></value>", &offset);
804 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
805 EXPECT_EQ(offset, 0);
809 val.
fromXml(
"<value></value>", &offset);
810 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeString);
811 EXPECT_EQ(offset, 15);
812 EXPECT_EQ(
static_cast<std::string
>(val),
"");
821 val.
fromXml(
"<value><boolean></boolean></value>", &offset);
822 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
823 EXPECT_EQ(offset, 0);
827 val.
fromXml(
"<value><boolean></value>", &offset);
828 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
829 EXPECT_EQ(offset, 0);
833 val.
fromXml(
"<value><boolean>foo</boolean></value>", &offset);
834 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
835 EXPECT_EQ(offset, 0);
839 val.
fromXml(
"<value><boolean>25</boolean></value>", &offset);
840 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
841 EXPECT_EQ(offset, 0);
846 val.
fromXml(
"<value><boolean>1foo</boolean></value>", &offset);
847 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeBoolean);
848 EXPECT_EQ(offset, 38);
849 EXPECT_EQ(
static_cast<bool>(val),
true);
854 val.
fromXml(
"<value><boolean>1</value>", &offset);
855 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeBoolean);
856 EXPECT_EQ(offset, 25);
857 EXPECT_EQ(
static_cast<bool>(val),
true);
861 val.
fromXml(
"<value><boolean>0</boolean></value>", &offset);
862 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeBoolean);
863 EXPECT_EQ(offset, 35);
864 EXPECT_EQ(
static_cast<bool>(val),
false);
868 val.
fromXml(
"<value><boolean>1</boolean></value>", &offset);
869 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeBoolean);
870 EXPECT_EQ(offset, 35);
871 EXPECT_EQ(
static_cast<bool>(val),
true);
880 val.
fromXml(
"<value><i4></i4></value>", &offset);
881 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
882 EXPECT_EQ(offset, 0);
886 val.
fromXml(
"<value><i4></value>", &offset);
887 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
888 EXPECT_EQ(offset, 0);
892 val.
fromXml(
"<value><i4>foo</i4></value>", &offset);
893 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
894 EXPECT_EQ(offset, 0);
898 val.
fromXml(
"<value><i4>25</i4></value>", &offset);
899 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInt);
900 EXPECT_EQ(offset, 26);
901 EXPECT_EQ(
static_cast<int>(val), 25);
906 val.
fromXml(
"<value><i4>1foo</i4></value>", &offset);
907 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInt);
908 EXPECT_EQ(offset, 28);
909 EXPECT_EQ(
static_cast<int>(val), 1);
914 val.
fromXml(
"<value><i4>99</value>", &offset);
915 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInt);
916 EXPECT_EQ(offset, 21);
917 EXPECT_EQ(
static_cast<int>(val), 99);
926 val.
fromXml(
"<value><int></int></value>", &offset);
927 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
928 EXPECT_EQ(offset, 0);
932 val.
fromXml(
"<value><int></value>", &offset);
933 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
934 EXPECT_EQ(offset, 0);
938 val.
fromXml(
"<value><int>foo</int></value>", &offset);
939 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
940 EXPECT_EQ(offset, 0);
944 val.
fromXml(
"<value><int>25</int></value>", &offset);
945 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInt);
946 EXPECT_EQ(offset, 28);
947 EXPECT_EQ(
static_cast<int>(val), 25);
952 val.
fromXml(
"<value><int>1foo</int></value>", &offset);
953 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInt);
954 EXPECT_EQ(offset, 30);
955 EXPECT_EQ(
static_cast<int>(val), 1);
960 val.
fromXml(
"<value><int>99</value>", &offset);
961 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInt);
962 EXPECT_EQ(offset, 22);
963 EXPECT_EQ(
static_cast<int>(val), 99);
972 val.
fromXml(
"<value><double></double></value>", &offset);
973 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
974 EXPECT_EQ(offset, 0);
978 val.
fromXml(
"<value><double></value>", &offset);
979 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
980 EXPECT_EQ(offset, 0);
984 val.
fromXml(
"<value><double>foo</double></value>", &offset);
985 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
986 EXPECT_EQ(offset, 0);
990 val.
fromXml(
"<value><double>25</double></value>", &offset);
991 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeDouble);
992 EXPECT_EQ(offset, 34);
993 EXPECT_EQ(
static_cast<double>(val), 25.0);
997 val.
fromXml(
"<value><double>25.876</double></value>", &offset);
998 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeDouble);
999 EXPECT_EQ(offset, 38);
1000 EXPECT_NEAR(
static_cast<double>(val), 25.876, 0.01);
1005 val.
fromXml(
"<value><double>1foo</double></value>", &offset);
1006 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeDouble);
1007 EXPECT_EQ(offset, 36);
1008 EXPECT_EQ(
static_cast<double>(val), 1);
1017 val.
fromXml(
"<value><foo></foo></value>", &offset);
1018 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1019 EXPECT_EQ(offset, 0);
1023 val.
fromXml(
"<value>foo</value>", &offset);
1024 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeString);
1025 EXPECT_EQ(offset, 18);
1026 EXPECT_EQ(
static_cast<std::string
>(val),
"foo");
1027 EXPECT_EQ(val.
size(), 3);
1036 val.
fromXml(
"<value><string>", &offset);
1037 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1038 EXPECT_EQ(offset, 0);
1043 val.
fromXml(
"<value><string></value>", &offset);
1044 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeString);
1045 EXPECT_EQ(offset, 23);
1046 EXPECT_EQ(
static_cast<std::string
>(val),
"");
1047 EXPECT_EQ(val.
size(), 0);
1051 val.
fromXml(
"<value><string>foo</string></value>", &offset);
1052 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeString);
1053 EXPECT_EQ(offset, 35);
1054 EXPECT_EQ(
static_cast<std::string
>(val),
"foo");
1055 EXPECT_EQ(val.
size(), 3);
1061 struct tm expected{};
1066 val.
fromXml(
"<value><dateTime.iso8601></dateTime.iso8601></value>", &offset);
1067 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1068 EXPECT_EQ(offset, 0);
1072 val.
fromXml(
"<value><dateTime.iso8601>", &offset);
1073 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1074 EXPECT_EQ(offset, 0);
1078 val.
fromXml(
"<value><dateTime.iso8601></value>", &offset);
1079 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1080 EXPECT_EQ(offset, 0);
1084 val.
fromXml(
"<value><dateTime.iso8601>0000000T00:00<dateTime.iso8601></value>", &offset);
1085 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1086 EXPECT_EQ(offset, 0);
1090 val.
fromXml(
"<value><dateTime.iso8601>000000T00:00:00<dateTime.iso8601></value>", &offset);
1091 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1092 EXPECT_EQ(offset, 0);
1098 val.
fromXml(
"<value><dateTime.iso8601>0000000T00:00:00</value>", &offset);
1099 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeDateTime);
1100 EXPECT_EQ(offset, 49);
1101 returned =
static_cast<struct tm
>(val);
1102 EXPECT_EQ(returned.tm_sec, expected.tm_sec);
1103 EXPECT_EQ(returned.tm_min, expected.tm_min);
1104 EXPECT_EQ(returned.tm_hour, expected.tm_hour);
1105 EXPECT_EQ(returned.tm_mday, expected.tm_mday);
1106 EXPECT_EQ(returned.tm_mon, expected.tm_mon);
1107 EXPECT_EQ(returned.tm_year, expected.tm_year);
1108 EXPECT_EQ(returned.tm_isdst, -1);
1113 val.
fromXml(
"<value><dateTime.iso8601>0000000T00:00:0<dateTime.iso8601></value>", &offset);
1114 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeDateTime);
1115 EXPECT_EQ(offset, 66);
1116 returned =
static_cast<struct tm
>(val);
1117 EXPECT_EQ(returned.tm_sec, expected.tm_sec);
1118 EXPECT_EQ(returned.tm_min, expected.tm_min);
1119 EXPECT_EQ(returned.tm_hour, expected.tm_hour);
1120 EXPECT_EQ(returned.tm_mday, expected.tm_mday);
1121 EXPECT_EQ(returned.tm_mon, expected.tm_mon);
1122 EXPECT_EQ(returned.tm_year, expected.tm_year);
1123 EXPECT_EQ(returned.tm_isdst, -1);
1128 val.
fromXml(
"<value><dateTime.iso8601>0000000T00:00:00<dateTime.iso8601></value>", &offset);
1129 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeDateTime);
1130 EXPECT_EQ(offset, 67);
1131 returned =
static_cast<struct tm
>(val);
1132 EXPECT_EQ(returned.tm_sec, expected.tm_sec);
1133 EXPECT_EQ(returned.tm_min, expected.tm_min);
1134 EXPECT_EQ(returned.tm_hour, expected.tm_hour);
1135 EXPECT_EQ(returned.tm_mday, expected.tm_mday);
1136 EXPECT_EQ(returned.tm_mon, expected.tm_mon);
1137 EXPECT_EQ(returned.tm_year, expected.tm_year);
1138 EXPECT_EQ(returned.tm_isdst, -1);
1147 val.
fromXml(
"<value><base64>", &offset);
1148 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1149 EXPECT_EQ(offset, 0);
1153 val.
fromXml(
"<value><base64></base64></value>", &offset);
1154 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeBase64);
1155 EXPECT_EQ(offset, 32);
1157 EXPECT_EQ(val.
size(), 0);
1162 val.
fromXml(
"<value><base64>____</base64></value>", &offset);
1163 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeBase64);
1164 EXPECT_EQ(offset, 36);
1166 EXPECT_EQ(val.
size(), 0);
1171 val.
fromXml(
"<value><base64>aGVsbG8=</base64></value>", &offset);
1172 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeBase64);
1173 EXPECT_EQ(offset, 40);
1175 EXPECT_EQ(val.
size(), 5);
1184 val.
fromXml(
"<value><array>", &offset);
1185 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1186 EXPECT_EQ(offset, 0);
1190 val.
fromXml(
"<value><array></array></value>", &offset);
1191 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeInvalid);
1192 EXPECT_EQ(offset, 0);
1196 val.
fromXml(
"<value><array><data></data></array></value>", &offset);
1197 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeArray);
1198 EXPECT_EQ(offset, 43);
1199 EXPECT_EQ(val.
size(), 0);
1203 val.
fromXml(
"<value><array><data><value><boolean>1</boolean></value></data></array></value>", &offset);
1204 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeArray);
1205 EXPECT_EQ(offset, 78);
1206 EXPECT_EQ(val.
size(), 1);
1207 EXPECT_EQ(
static_cast<bool>(val[0]),
true);
1212 val.
fromXml(
"<value><array><data><value><boolean>1</boolean></value></array></value>", &offset);
1213 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeArray);
1214 EXPECT_EQ(offset, 71);
1215 EXPECT_EQ(val.
size(), 1);
1216 EXPECT_EQ(
static_cast<bool>(val[0]),
true);
1220 val.
fromXml(
"<value><array><data><value><boolean>1</boolean></value><value><double>23.4</double></value></data></array></value>", &offset);
1221 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeArray);
1222 EXPECT_EQ(offset, 114);
1223 EXPECT_EQ(val.
size(), 2);
1224 EXPECT_EQ(
static_cast<bool>(val[0]),
true);
1225 EXPECT_NEAR(
static_cast<double>(val[1]), 23.4, 0.01);
1235 val.
fromXml(
"<value><struct>", &offset);
1236 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeStruct);
1237 EXPECT_EQ(offset, 15);
1238 EXPECT_EQ(val.
size(), 0);
1243 val.
fromXml(
"<value><struct><member><value><boolean>1</value>", &offset);
1244 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeStruct);
1245 EXPECT_EQ(offset, 48);
1246 EXPECT_EQ(val.
size(), 1);
1247 EXPECT_EQ(
static_cast<bool>(val[
""]),
true);
1252 val.
fromXml(
"<value><struct><member><value><boolean>1</boolean></value></member></struct></value>", &offset);
1253 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeStruct);
1254 EXPECT_EQ(offset, 84);
1255 EXPECT_EQ(val.
size(), 1);
1256 EXPECT_EQ(
static_cast<bool>(val[
""]),
true);
1261 val.
fromXml(
"<value><struct><member><name></name><value><boolean>1</boolean></value></member></struct></value>", &offset);
1262 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeStruct);
1263 EXPECT_EQ(offset, 97);
1264 EXPECT_EQ(val.
size(), 1);
1265 EXPECT_EQ(
static_cast<bool>(val[
""]),
true);
1269 val.
fromXml(
"<value><struct><member><name>foo</name><value><boolean>1</boolean></value></member></struct></value>", &offset);
1270 EXPECT_EQ(val.
getType(), XmlRpcValue::Type::TypeStruct);
1271 EXPECT_EQ(offset, 100);
1272 EXPECT_EQ(val.
size(), 1);
1273 EXPECT_EQ(
static_cast<bool>(val[
"foo"]),
true);
1278 ::testing::InitGoogleTest(&argc, argv);
1279 return RUN_ALL_TESTS();