diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-05-03 20:39:27 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-05-05 19:43:14 (GMT) |
commit | 772b2ec0243d7b55d91e4027d828881d18093ed0 (patch) | |
tree | 83a58b2b97f3992165ee20c05e0630452eb50457 /Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp | |
parent | 0b3db8fd68abee7269d5a38aabd8a816e099eae5 (diff) | |
download | swift-contrib-772b2ec0243d7b55d91e4027d828881d18093ed0.zip swift-contrib-772b2ec0243d7b55d91e4027d828881d18093ed0.tar.bz2 |
Replace ByteArray by typedef.
Diffstat (limited to 'Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp')
-rw-r--r-- | Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp index d1f7000..d4c31c5 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp @@ -10,6 +10,7 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include <boost/bind.hpp> +#include <Swiften/Base/Concat.h> #include <Swiften/FileTransfer/SOCKS5BytestreamServerSession.h> #include <Swiften/FileTransfer/ByteArrayReadBytestream.h> #include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h> @@ -35,7 +36,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { eventLoop = new DummyEventLoop(); connection = boost::shared_ptr<DummyConnection>(new DummyConnection(eventLoop)); connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1)); - stream1 = boost::shared_ptr<ByteArrayReadBytestream>(new ByteArrayReadBytestream(ByteArray::create("abcdefg"))); + stream1 = boost::shared_ptr<ByteArrayReadBytestream>(new ByteArrayReadBytestream(createByteArray("abcdefg"))); } void tearDown() { @@ -47,20 +48,20 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); - receive(ByteArray::create("\x05\x02\x01\x02")); + receive(createByteArray("\x05\x02\x01\x02")); - CPPUNIT_ASSERT(ByteArray::create("\x05\x00", 2) == receivedData); + CPPUNIT_ASSERT(createByteArray("\x05\x00", 2) == receivedData); } void testAuthenticate_Chunked() { boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession()); StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); - receive(ByteArray::create("\x05\x02\x01")); + receive(createByteArray("\x05\x02\x01")); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(receivedData.size())); - receive(ByteArray::create("\x01")); - CPPUNIT_ASSERT(ByteArray::create("\x05\x00", 2) == receivedData); + receive(createByteArray("\x01")); + CPPUNIT_ASSERT(createByteArray("\x05\x00", 2) == receivedData); } void testRequest() { @@ -69,9 +70,9 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { bytestreams.addBytestream("abcdef", stream1); authenticate(); - ByteArray hostname("abcdef"); - receive(ByteArray(ByteArray::create("\x05\x01\x00\x03", 4)) + hostname.getSize() + hostname + ByteArray::create("\x00\x00", 2)); - CPPUNIT_ASSERT(ByteArray::create("\x05\x00\x00\x03\x06\x61\x62\x63\x64\x65\x66\x00\x00", 13) == ByteArray::create(&receivedData[0], 13)); + ByteArray hostname(createByteArray("abcdef")); + receive(concat(createByteArray("\x05\x01\x00\x03", 4), createByteArray(hostname.size()), hostname, createByteArray("\x00\x00", 2))); + CPPUNIT_ASSERT(createByteArray("\x05\x00\x00\x03\x06\x61\x62\x63\x64\x65\x66\x00\x00", 13) == createByteArray(&receivedData[0], 13)); } void testRequest_UnknownBytestream() { @@ -79,9 +80,9 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get()); authenticate(); - ByteArray hostname("abcdef"); - receive(ByteArray(ByteArray::create("\x05\x01\x00\x03", 4)) + hostname.getSize() + hostname + ByteArray::create("\x00\x00", 2)); - CPPUNIT_ASSERT(ByteArray::create("\x05\x04\x00\x03\x06\x61\x62\x63\x64\x65\x66\x00\x00", 13) == receivedData); + ByteArray hostname(createByteArray("abcdef")); + receive(concat(createByteArray("\x05\x01\x00\x03", 4), createByteArray(hostname.size()), hostname, createByteArray("\x00\x00", 2))); + CPPUNIT_ASSERT(createByteArray("\x05\x04\x00\x03\x06\x61\x62\x63\x64\x65\x66\x00\x00", 13) == receivedData); } void testReceiveData() { @@ -93,7 +94,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { eventLoop->processEvents(); skipHeader("abcdef"); - CPPUNIT_ASSERT(ByteArray::create("abcdefg") == receivedData); + CPPUNIT_ASSERT(createByteArray("abcdefg") == receivedData); CPPUNIT_ASSERT_EQUAL(2, receivedDataChunks); } @@ -107,7 +108,7 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { eventLoop->processEvents(); skipHeader("abcdef"); - CPPUNIT_ASSERT(ByteArray::create("abcdefg") == receivedData); + CPPUNIT_ASSERT(createByteArray("abcdefg") == receivedData); CPPUNIT_ASSERT_EQUAL(4, receivedDataChunks); } @@ -118,18 +119,18 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { } void authenticate() { - receive(ByteArray::create("\x05\x02\x01\x02")); + receive(createByteArray("\x05\x02\x01\x02")); receivedData.clear(); receivedDataChunks = 0; } void request(const std::string& hostname) { - receive(ByteArray(ByteArray::create("\x05\x01\x00\x03", 4)) + hostname.size() + hostname + ByteArray::create("\x00\x00", 2)); + receive(concat(createByteArray("\x05\x01\x00\x03", 4), createByteArray(hostname.size()), createByteArray(hostname), createByteArray("\x00\x00", 2))); } void skipHeader(const std::string& hostname) { int headerSize = 7 + hostname.size(); - receivedData = ByteArray::create(&receivedData[headerSize], receivedData.size() - headerSize); + receivedData = createByteArray(&receivedData[headerSize], receivedData.size() - headerSize); } |