summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-09-28 17:42:54 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-09-28 17:43:38 (GMT)
commitbab047c1bef2936124db1346863a902e1064af12 (patch)
treec59de84a76581bd07713eb0591121e6a4aa04e7b /Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
parent7b8860c794419b63f827c9b87fbc469a1bcd58ef (diff)
downloadswift-contrib-bab047c1bef2936124db1346863a902e1064af12.zip
swift-contrib-bab047c1bef2936124db1346863a902e1064af12.tar.bz2
Pass read data from connection via shared_ptr.
This should avoid unnecessary copying of the received data while being processed by the event loop.
Diffstat (limited to 'Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp')
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
index 75b9faf..527e0ca 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -164,7 +164,7 @@ public:
clientSession->startReceiving(output);
ByteArray transferData = generateRandomByteArray(1024);
- connection->onDataRead(createSafeByteArray(transferData.data(), transferData.size()));
+ connection->onDataRead(createSafeByteArrayRef(transferData.data(), transferData.size()));
CPPUNIT_ASSERT_EQUAL(transferData, output->getData());
}
@@ -212,35 +212,35 @@ private:
// Server responses
void serverRespondHelloOK() {
- connection->onDataRead(createSafeByteArray("\x05\00", 2));
+ connection->onDataRead(createSafeByteArrayRef("\x05\00", 2));
}
void serverRespondHelloAuthFail() {
- connection->onDataRead(createSafeByteArray("\x05\xFF", 2));
+ connection->onDataRead(createSafeByteArrayRef("\x05\xFF", 2));
}
void serverRespondRequestOK() {
- SafeByteArray dataToSend = createSafeByteArray("\x05\x00\x00\x03", 4);
- append(dataToSend, createSafeByteArray(destination.size()));
- append(dataToSend, createSafeByteArray(destination));
- append(dataToSend, createSafeByteArray("\x00", 1));
+ boost::shared_ptr<SafeByteArray> dataToSend = createSafeByteArrayRef("\x05\x00\x00\x03", 4);
+ append(*dataToSend, createSafeByteArray(destination.size()));
+ append(*dataToSend, createSafeByteArray(destination));
+ append(*dataToSend, createSafeByteArray("\x00", 1));
connection->onDataRead(dataToSend);
}
void serverRespondRequestFail() {
- SafeByteArray correctData = createSafeByteArray("\x05\x00\x00\x03", 4);
- append(correctData, createSafeByteArray(destination.size()));
- append(correctData, createSafeByteArray(destination));
- append(correctData, createSafeByteArray("\x00", 1));
+ boost::shared_ptr<SafeByteArray> correctData = createSafeByteArrayRef("\x05\x00\x00\x03", 4);
+ append(*correctData, createSafeByteArray(destination.size()));
+ append(*correctData, createSafeByteArray(destination));
+ append(*correctData, createSafeByteArray("\x00", 1));
- SafeByteArray dataToSend;
+ boost::shared_ptr<SafeByteArray> dataToSend;
//ByteArray failingData = Hexify::unhexify("8417947d1d305c72c11520ea7d2c6e787396705e72c312c6ccc3f66613d7cae1b91b7ab48e8b59a17d559c15fb51");
//append(dataToSend, failingData);
//SWIFT_LOG(debug) << "hexed: " << Hexify::hexify(failingData) << std::endl;
do {
- ByteArray rndArray = generateRandomByteArray(correctData.size());
- dataToSend = createSafeByteArray(rndArray.data(), rndArray.size());
- } while (dataToSend == correctData);
+ ByteArray rndArray = generateRandomByteArray(correctData->size());
+ dataToSend = createSafeByteArrayRef(rndArray.data(), rndArray.size());
+ } while (*dataToSend == *correctData);
connection->onDataRead(dataToSend);
}