diff options
Diffstat (limited to 'Swiften/Compress')
-rw-r--r-- | Swiften/Compress/UnitTest/ZLibCompressorTest.cpp | 12 | ||||
-rw-r--r-- | Swiften/Compress/UnitTest/ZLibDecompressorTest.cpp | 24 | ||||
-rw-r--r-- | Swiften/Compress/ZLibCodecompressor.cpp | 4 | ||||
-rw-r--r-- | Swiften/Compress/ZLibCodecompressor.h | 4 |
4 files changed, 22 insertions, 22 deletions
diff --git a/Swiften/Compress/UnitTest/ZLibCompressorTest.cpp b/Swiften/Compress/UnitTest/ZLibCompressorTest.cpp index 9320ae1..3f22690 100644 --- a/Swiften/Compress/UnitTest/ZLibCompressorTest.cpp +++ b/Swiften/Compress/UnitTest/ZLibCompressorTest.cpp @@ -4,7 +4,7 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#include <Swiften/Base/ByteArray.h> +#include <Swiften/Base/SafeByteArray.h> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> @@ -27,17 +27,17 @@ class ZLibCompressorTest : public CppUnit::TestFixture void testProcess() { ZLibCompressor testling; - ByteArray result = testling.process(createByteArray("foo")); + SafeByteArray result = testling.process(createSafeByteArray("foo")); - CPPUNIT_ASSERT_EQUAL(createByteArray("\x78\xda\x4a\xcb\xcf\x07\x00\x00\x00\xff\xff", 11), result); + CPPUNIT_ASSERT_EQUAL(createSafeByteArray("\x78\xda\x4a\xcb\xcf\x07\x00\x00\x00\xff\xff", 11), result); } void testProcess_Twice() { ZLibCompressor testling; - testling.process(createByteArray("foo")); - ByteArray result = testling.process(createByteArray("bar")); + testling.process(createSafeByteArray("foo")); + SafeByteArray result = testling.process(createSafeByteArray("bar")); - CPPUNIT_ASSERT_EQUAL(createByteArray("\x4a\x4a\x2c\x02\x00\x00\x00\xff\xff",9), result); + CPPUNIT_ASSERT_EQUAL(createSafeByteArray("\x4a\x4a\x2c\x02\x00\x00\x00\xff\xff",9), result); } }; diff --git a/Swiften/Compress/UnitTest/ZLibDecompressorTest.cpp b/Swiften/Compress/UnitTest/ZLibDecompressorTest.cpp index 00aae6e..5dd8630 100644 --- a/Swiften/Compress/UnitTest/ZLibDecompressorTest.cpp +++ b/Swiften/Compress/UnitTest/ZLibDecompressorTest.cpp @@ -32,22 +32,22 @@ class ZLibDecompressorTest : public CppUnit::TestFixture void testProcess() { ZLibDecompressor testling; - ByteArray result = testling.process(createByteArray("\x78\xda\x4a\xcb\xcf\x07\x00\x00\x00\xff\xff", 11)); + SafeByteArray result = testling.process(createSafeByteArray("\x78\xda\x4a\xcb\xcf\x07\x00\x00\x00\xff\xff", 11)); - CPPUNIT_ASSERT_EQUAL(createByteArray("foo"), result); + CPPUNIT_ASSERT_EQUAL(createSafeByteArray("foo"), result); } void testProcess_Twice() { ZLibDecompressor testling; - testling.process(createByteArray("\x78\xda\x4a\xcb\xcf\x07\x00\x00\x00\xff\xff", 11)); - ByteArray result = testling.process(createByteArray("\x4a\x4a\x2c\x02\x00\x00\x00\xff\xff", 9)); + testling.process(createSafeByteArray("\x78\xda\x4a\xcb\xcf\x07\x00\x00\x00\xff\xff", 11)); + SafeByteArray result = testling.process(createSafeByteArray("\x4a\x4a\x2c\x02\x00\x00\x00\xff\xff", 9)); - CPPUNIT_ASSERT_EQUAL(createByteArray("bar"), result); + CPPUNIT_ASSERT_EQUAL(createSafeByteArray("bar"), result); } void testProcess_Invalid() { ZLibDecompressor testling; - CPPUNIT_ASSERT_THROW(testling.process(createByteArray("invalid")), ZLibException); + CPPUNIT_ASSERT_THROW(testling.process(createSafeByteArray("invalid")), ZLibException); } void testProcess_Huge() { @@ -56,9 +56,9 @@ class ZLibDecompressorTest : public CppUnit::TestFixture for (unsigned int i = 0; i < 2048; ++i) { data.push_back(static_cast<char>(i)); } - ByteArray original(createByteArray(&data[0], data.size())); - ByteArray compressed = ZLibCompressor().process(original); - ByteArray decompressed = ZLibDecompressor().process(compressed); + SafeByteArray original(createSafeByteArray(&data[0], data.size())); + SafeByteArray compressed = ZLibCompressor().process(original); + SafeByteArray decompressed = ZLibDecompressor().process(compressed); CPPUNIT_ASSERT_EQUAL(original, decompressed); } @@ -69,9 +69,9 @@ class ZLibDecompressorTest : public CppUnit::TestFixture for (unsigned int i = 0; i < 1024; ++i) { data.push_back(static_cast<char>(i)); } - ByteArray original(createByteArray(&data[0], data.size())); - ByteArray compressed = ZLibCompressor().process(original); - ByteArray decompressed = ZLibDecompressor().process(compressed); + SafeByteArray original(createSafeByteArray(&data[0], data.size())); + SafeByteArray compressed = ZLibCompressor().process(original); + SafeByteArray decompressed = ZLibDecompressor().process(compressed); CPPUNIT_ASSERT_EQUAL(original, decompressed); } diff --git a/Swiften/Compress/ZLibCodecompressor.cpp b/Swiften/Compress/ZLibCodecompressor.cpp index 872c154..0869d6b 100644 --- a/Swiften/Compress/ZLibCodecompressor.cpp +++ b/Swiften/Compress/ZLibCodecompressor.cpp @@ -25,8 +25,8 @@ ZLibCodecompressor::ZLibCodecompressor() { ZLibCodecompressor::~ZLibCodecompressor() { } -ByteArray ZLibCodecompressor::process(const ByteArray& input) { - ByteArray output; +SafeByteArray ZLibCodecompressor::process(const SafeByteArray& input) { + SafeByteArray output; stream_.avail_in = input.size(); stream_.next_in = reinterpret_cast<Bytef*>(const_cast<unsigned char*>(vecptr(input))); int outputPosition = 0; diff --git a/Swiften/Compress/ZLibCodecompressor.h b/Swiften/Compress/ZLibCodecompressor.h index c23f2d2..93babf0 100644 --- a/Swiften/Compress/ZLibCodecompressor.h +++ b/Swiften/Compress/ZLibCodecompressor.h @@ -8,7 +8,7 @@ #include <zlib.h> -#include <Swiften/Base/ByteArray.h> +#include <Swiften/Base/SafeByteArray.h> namespace Swift { class ZLibCodecompressor { @@ -16,7 +16,7 @@ namespace Swift { ZLibCodecompressor(); virtual ~ZLibCodecompressor(); - ByteArray process(const ByteArray& data); + SafeByteArray process(const SafeByteArray& data); virtual int processZStream() = 0; protected: |