mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-20 16:28:32 +00:00
FS-2746 --resolve large xmlrpc update thanks garmt
This commit is contained in:
1 parent
37ecad9903
commit
6b6c83a718
397 files changed
+41821
-33840
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
#include <time.h>
|
||||
|
||||
#include "xmlrpc-c/girerr.hpp"
|
||||
@@ -13,6 +14,9 @@ using girerr::error;
|
||||
#include "xmlrpc-c/oldcppwrapper.hpp"
|
||||
#include "xmlrpc-c/registry.hpp"
|
||||
|
||||
#include "base64.hpp"
|
||||
#include "xml.hpp"
|
||||
#include "value.hpp"
|
||||
#include "testclient.hpp"
|
||||
#include "registry.hpp"
|
||||
#include "server_abyss.hpp"
|
||||
@@ -189,7 +193,7 @@ void test_value (void) {
|
||||
XmlRpcValue::makeArray().getArray();
|
||||
XmlRpcValue::makeStruct().getStruct();
|
||||
|
||||
// Test Base64 values.
|
||||
// Test byte string values.
|
||||
const unsigned char *b64_data;
|
||||
size_t b64_len;
|
||||
XmlRpcValue val6 = XmlRpcValue::makeBase64((unsigned char*) "a\0\0b", 4);
|
||||
@@ -216,7 +220,7 @@ void test_value (void) {
|
||||
TEST(strct.structSize() == 2);
|
||||
TEST(strct.structHasKey("bar"));
|
||||
TEST(!strct.structHasKey("nosuch"));
|
||||
for (size_t i = 0; i < strct.structSize(); i++) {
|
||||
for (int i = 0; i < (int)strct.structSize(); ++i) {
|
||||
string key;
|
||||
XmlRpcValue value;
|
||||
strct.structGetKeyAndValue(i, key, value);
|
||||
@@ -240,285 +244,66 @@ testXmlRpcCpp() {
|
||||
|
||||
|
||||
|
||||
class intTestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "intTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
value_int int1(7);
|
||||
TEST(static_cast<int>(int1) == 7);
|
||||
value_int int2(-7);
|
||||
TEST(static_cast<int>(int2) == -7);
|
||||
value val1(int1);
|
||||
TEST(val1.type() == value::TYPE_INT);
|
||||
value_int int3(val1);
|
||||
TEST(static_cast<int>(int3) == 7);
|
||||
try {
|
||||
value_int int4(value_double(3.7));
|
||||
TEST_FAILED("invalid cast double-int suceeded");
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
static void
|
||||
buildParamListWithAdd(paramList * const paramListP,
|
||||
time_t const timeFuture) {
|
||||
|
||||
paramListP->add(value_int(7));
|
||||
paramListP->add(value_boolean(true)).add(value_double(3.14));
|
||||
time_t const timeZero(0);
|
||||
paramListP->add(value_datetime(timeZero));
|
||||
paramListP->add(value_datetime(timeFuture));
|
||||
paramListP->add(value_string("hello world"));
|
||||
unsigned char bytestringArray[] = {0x10, 0x11, 0x12, 0x13, 0x14};
|
||||
vector<unsigned char>
|
||||
bytestringData(&bytestringArray[0], &bytestringArray[4]);
|
||||
paramListP->add(value_bytestring(bytestringData));
|
||||
vector<value> arrayData;
|
||||
arrayData.push_back(value_int(7));
|
||||
arrayData.push_back(value_double(2.78));
|
||||
arrayData.push_back(value_string("hello world"));
|
||||
paramListP->add(value_array(arrayData));
|
||||
map<string, value> structData;
|
||||
pair<string, value> member("the_integer", value_int(9));
|
||||
structData.insert(member);
|
||||
paramListP->add(value_struct(structData));
|
||||
paramListP->add(value_nil());
|
||||
paramListP->add(value_i8((xmlrpc_int64)UINT_MAX + 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
class doubleTestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "doubleTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
value_double double1(3.14);
|
||||
TEST(static_cast<double>(double1) == 3.14);
|
||||
value val1(double1);
|
||||
TEST(val1.type() == value::TYPE_DOUBLE);
|
||||
value_double double2(val1);
|
||||
TEST(static_cast<double>(double2) == 3.14);
|
||||
try {
|
||||
value_double double4(value_int(4));
|
||||
TEST_FAILED("invalid cast int-double suceeded");
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
static void
|
||||
verifyParamList(paramList const& paramList,
|
||||
time_t const timeFuture) {
|
||||
|
||||
TEST(paramList.size() == 11);
|
||||
|
||||
TEST(paramList.getInt(0) == 7);
|
||||
TEST(paramList.getInt(0, 7) == 7);
|
||||
TEST(paramList.getInt(0, -5, 7) == 7);
|
||||
TEST(paramList.getBoolean(1) == true);
|
||||
TEST(paramList.getDouble(2) == 3.14);
|
||||
TEST(paramList.getDouble(2, 1) == 3.14);
|
||||
TEST(paramList.getDouble(2, 1, 4) == 3.14);
|
||||
time_t const timeZero(0);
|
||||
TEST(paramList.getDatetime_sec(3) == timeZero);
|
||||
TEST(paramList.getDatetime_sec(3, paramList::TC_ANY) == timeZero);
|
||||
TEST(paramList.getDatetime_sec(3, paramList::TC_NO_FUTURE)
|
||||
== timeZero);
|
||||
TEST(paramList.getDatetime_sec(4, paramList::TC_NO_PAST)
|
||||
== timeFuture);
|
||||
TEST(paramList.getString(5) == "hello world");
|
||||
TEST(paramList.getBytestring(6)[0] == 0x10);
|
||||
TEST(paramList.getArray(7).size() == 3);
|
||||
TEST(paramList.getArray(7, 3).size() == 3);
|
||||
TEST(paramList.getArray(7, 1, 3).size() == 3);
|
||||
paramList.getStruct(8)["the_integer"];
|
||||
paramList.getNil(9);
|
||||
TEST(paramList.getI8(10) == (xmlrpc_int64)UINT_MAX + 1);
|
||||
paramList.verifyEnd(11);
|
||||
}
|
||||
|
||||
class booleanTestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "booleanTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
value_boolean boolean1(true);
|
||||
TEST(static_cast<bool>(boolean1) == true);
|
||||
value_boolean boolean2(false);
|
||||
TEST(static_cast<bool>(boolean2) == false);
|
||||
value val1(boolean1);
|
||||
TEST(val1.type() == value::TYPE_BOOLEAN);
|
||||
value_boolean boolean3(val1);
|
||||
TEST(static_cast<bool>(boolean3) == true);
|
||||
try {
|
||||
value_boolean boolean4(value_int(4));
|
||||
TEST_FAILED("invalid cast int-boolean suceeded");
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class datetimeTestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "datetimeTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
time_t const testTime(900684535);
|
||||
value_datetime datetime1("19980717T14:08:55");
|
||||
TEST(static_cast<time_t>(datetime1) == testTime);
|
||||
value_datetime datetime2(testTime);
|
||||
TEST(static_cast<time_t>(datetime2) == testTime);
|
||||
value val1(datetime1);
|
||||
TEST(val1.type() == value::TYPE_DATETIME);
|
||||
value_datetime datetime3(val1);
|
||||
TEST(static_cast<time_t>(datetime3) == testTime);
|
||||
try {
|
||||
value_datetime datetime4(value_int(4));
|
||||
TEST_FAILED("invalid cast int-datetime suceeded");
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class stringTestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "stringTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
value_string string1("hello world");
|
||||
TEST(static_cast<string>(string1) == "hello world");
|
||||
value_string string2("embedded\0null");
|
||||
TEST(static_cast<string>(string2) == "embedded\0null");
|
||||
value val1(string1);
|
||||
TEST(val1.type() == value::TYPE_STRING);
|
||||
value_string string3(val1);
|
||||
TEST(static_cast<string>(string3) == "hello world");
|
||||
try {
|
||||
value_string string4(value_int(4));
|
||||
TEST_FAILED("invalid cast int-string succeeded");
|
||||
} catch (error) {}
|
||||
value_string string5("hello world", value_string::nlCode_all);
|
||||
TEST(static_cast<string>(string5) == "hello world");
|
||||
value_string string6("hello\nthere\rworld\r\n\n",
|
||||
value_string::nlCode_all);
|
||||
TEST(static_cast<string>(string6) == "hello\nthere\nworld\n\n");
|
||||
TEST(string6.crlfValue() == "hello\r\nthere\r\nworld\r\n\r\n");
|
||||
value_string string7("hello\nthere\rworld\r\n\n",
|
||||
value_string::nlCode_lf);
|
||||
TEST(static_cast<string>(string7) == "hello\nthere\rworld\r\n\n");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class bytestringTestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "bytestringTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
unsigned char bytestringArray[] = {0x10, 0x11, 0x12, 0x13, 0x14};
|
||||
vector<unsigned char>
|
||||
bytestringData(&bytestringArray[0], &bytestringArray[4]);
|
||||
value_bytestring bytestring1(bytestringData);
|
||||
|
||||
vector<unsigned char> const dataReadBack1(
|
||||
bytestring1.vectorUcharValue());
|
||||
TEST(dataReadBack1 == bytestringData);
|
||||
value val1(bytestring1);
|
||||
TEST(val1.type() == value::TYPE_BYTESTRING);
|
||||
value_bytestring bytestring2(val1);
|
||||
vector<unsigned char> const dataReadBack2(
|
||||
bytestring2.vectorUcharValue());
|
||||
TEST(dataReadBack2 == bytestringData);
|
||||
try {
|
||||
value_bytestring bytestring4(value_int(4));
|
||||
TEST_FAILED("invalid cast int-bytestring suceeded");
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class nilTestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "nilTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
value_nil nil1;
|
||||
value val1(nil1);
|
||||
TEST(val1.type() == value::TYPE_NIL);
|
||||
value_nil nil2(val1);
|
||||
try {
|
||||
value_nil nil4(value_int(4));
|
||||
TEST_FAILED("invalid cast int-nil suceeded");
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class i8TestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "i8TestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
value_i8 int1(7);
|
||||
TEST(static_cast<xmlrpc_int64>(int1) == 7);
|
||||
value_i8 int2(-7);
|
||||
TEST(static_cast<xmlrpc_int64>(int2) == -7);
|
||||
value_i8 int5(1ull << 40);
|
||||
TEST(static_cast<xmlrpc_int64>(int5) == (1ull << 40));
|
||||
value val1(int1);
|
||||
TEST(val1.type() == value::TYPE_I8);
|
||||
value_i8 int3(val1);
|
||||
TEST(static_cast<xmlrpc_int64>(int3) == 7);
|
||||
try {
|
||||
value_i8 int4(value_double(3.7));
|
||||
TEST_FAILED("invalid cast double-i8 suceeded");
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class structTestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "structTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
map<string, value> structData;
|
||||
pair<string, value> member("the_integer", value_int(9));
|
||||
structData.insert(member);
|
||||
|
||||
value_struct struct1(structData);
|
||||
|
||||
map<string, value> dataReadBack(struct1);
|
||||
|
||||
TEST(static_cast<int>(value_int(dataReadBack["the_integer"])) == 9);
|
||||
|
||||
value val1(struct1);
|
||||
TEST(val1.type() == value::TYPE_STRUCT);
|
||||
value_struct struct2(val1);
|
||||
try {
|
||||
value_struct struct4(value_int(4));
|
||||
TEST_FAILED("invalid cast int-struct suceeded");
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class arrayTestSuite : public testSuite {
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "arrayTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
vector<value> arrayData;
|
||||
arrayData.push_back(value_int(7));
|
||||
arrayData.push_back(value_double(2.78));
|
||||
arrayData.push_back(value_string("hello world"));
|
||||
value_array array1(arrayData);
|
||||
|
||||
TEST(array1.size() == 3);
|
||||
vector<value> dataReadBack1(array1.vectorValueValue());
|
||||
TEST(dataReadBack1[0].type() == value::TYPE_INT);
|
||||
TEST(static_cast<int>(value_int(dataReadBack1[0])) == 7);
|
||||
TEST(dataReadBack1[1].type() == value::TYPE_DOUBLE);
|
||||
TEST(static_cast<double>(value_double(dataReadBack1[1])) == 2.78);
|
||||
TEST(dataReadBack1[2].type() == value::TYPE_STRING);
|
||||
TEST(static_cast<string>(value_string(dataReadBack1[2])) ==
|
||||
"hello world");
|
||||
|
||||
value val1(array1);
|
||||
TEST(val1.type() == value::TYPE_ARRAY);
|
||||
value_array array2(val1);
|
||||
TEST(array2.size() == 3);
|
||||
try {
|
||||
value_array array4(value_int(4));
|
||||
TEST_FAILED("invalid cast int-array suceeded");
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class valueTestSuite : public testSuite {
|
||||
|
||||
public:
|
||||
virtual string suiteName() {
|
||||
return "valueTestSuite";
|
||||
}
|
||||
virtual void runtests(unsigned int const indentation) {
|
||||
|
||||
intTestSuite().run(indentation+1);
|
||||
doubleTestSuite().run(indentation+1);
|
||||
booleanTestSuite().run(indentation+1);
|
||||
datetimeTestSuite().run(indentation+1);
|
||||
stringTestSuite().run(indentation+1);
|
||||
bytestringTestSuite().run(indentation+1);
|
||||
nilTestSuite().run(indentation+1);
|
||||
i8TestSuite().run(indentation+1);
|
||||
structTestSuite().run(indentation+1);
|
||||
arrayTestSuite().run(indentation+1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class paramListTestSuite : public testSuite {
|
||||
@@ -529,60 +314,24 @@ public:
|
||||
}
|
||||
virtual void runtests(unsigned int const) {
|
||||
|
||||
time_t const timeFuture(time(NULL)+100);
|
||||
|
||||
paramList paramList1;
|
||||
TEST(paramList1.size() == 0);
|
||||
|
||||
paramList1.add(value_int(7));
|
||||
paramList1.add(value_boolean(true));
|
||||
paramList1.add(value_double(3.14));
|
||||
time_t const timeZero(0);
|
||||
paramList1.add(value_datetime(timeZero));
|
||||
time_t const timeFuture(time(NULL)+100);
|
||||
paramList1.add(value_datetime(timeFuture));
|
||||
paramList1.add(value_string("hello world"));
|
||||
unsigned char bytestringArray[] = {0x10, 0x11, 0x12, 0x13, 0x14};
|
||||
vector<unsigned char>
|
||||
bytestringData(&bytestringArray[0], &bytestringArray[4]);
|
||||
paramList1.add(value_bytestring(bytestringData));
|
||||
vector<value> arrayData;
|
||||
arrayData.push_back(value_int(7));
|
||||
arrayData.push_back(value_double(2.78));
|
||||
arrayData.push_back(value_string("hello world"));
|
||||
paramList1.add(value_array(arrayData));
|
||||
map<string, value> structData;
|
||||
pair<string, value> member("the_integer", value_int(9));
|
||||
structData.insert(member);
|
||||
paramList1.add(value_struct(structData));
|
||||
paramList1.add(value_nil());
|
||||
paramList1.add(value_i8((xmlrpc_int64)UINT_MAX + 1));
|
||||
buildParamListWithAdd(¶mList1, timeFuture);
|
||||
|
||||
TEST(paramList1.size() == 11);
|
||||
|
||||
TEST(paramList1.getInt(0) == 7);
|
||||
TEST(paramList1.getInt(0, 7) == 7);
|
||||
TEST(paramList1.getInt(0, -5, 7) == 7);
|
||||
TEST(paramList1.getBoolean(1) == true);
|
||||
TEST(paramList1.getDouble(2) == 3.14);
|
||||
TEST(paramList1.getDouble(2, 1) == 3.14);
|
||||
TEST(paramList1.getDouble(2, 1, 4) == 3.14);
|
||||
TEST(paramList1.getDatetime_sec(3) == 0);
|
||||
TEST(paramList1.getDatetime_sec(3, paramList::TC_ANY) == timeZero);
|
||||
TEST(paramList1.getDatetime_sec(3, paramList::TC_NO_FUTURE)
|
||||
== timeZero);
|
||||
TEST(paramList1.getDatetime_sec(4, paramList::TC_NO_PAST)
|
||||
== timeFuture);
|
||||
TEST(paramList1.getString(5) == "hello world");
|
||||
TEST(paramList1.getBytestring(6)[0] == 0x10);
|
||||
TEST(paramList1.getArray(7).size() == 3);
|
||||
TEST(paramList1.getArray(7, 3).size() == 3);
|
||||
TEST(paramList1.getArray(7, 1, 3).size() == 3);
|
||||
paramList1.getStruct(8)["the_integer"];
|
||||
paramList1.getNil(9);
|
||||
TEST(paramList1.getI8(10) == (xmlrpc_int64)UINT_MAX + 1);
|
||||
paramList1.verifyEnd(11);
|
||||
verifyParamList(paramList1, timeFuture);
|
||||
|
||||
paramList paramList2(5);
|
||||
TEST(paramList2.size() == 0);
|
||||
|
||||
paramList2.addc(7);
|
||||
paramList2.addc(true).addc(3.14);
|
||||
TEST(paramList2.size() == 3);
|
||||
TEST(paramList2.getInt(0) == 7);
|
||||
TEST(paramList2.getBoolean(1) == true);
|
||||
TEST(paramList2.getDouble(2) == 3.14);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -604,13 +353,13 @@ main(int argc, char**) {
|
||||
|
||||
try {
|
||||
// Add your test suites here.
|
||||
base64TestSuite().run(0);
|
||||
xmlTestSuite().run(0);
|
||||
valueTestSuite().run(0);
|
||||
paramListTestSuite().run(0);
|
||||
registryTestSuite().run(0);
|
||||
serverAbyssTestSuite().run(0);
|
||||
#ifndef WIN32
|
||||
serverPstreamTestSuite().run(0);
|
||||
#endif
|
||||
clientTestSuite().run(0);
|
||||
|
||||
testXmlRpcCpp();
|
||||
|
||||
Reference in new issue
Block a user