32 using namespace zlibNamespace;
37 8, strategy) ==
Z_OK);
43 zlibNamespace::deflateEnd (&stream);
61 const uint8* data =
nullptr;
69 enum { strategy = 0 };
71 zlibNamespace::z_stream stream;
73 bool isFirstDeflate =
true, streamIsValid =
false, finished =
false;
74 zlibNamespace::Bytef buffer[32768];
78 using namespace zlibNamespace;
82 stream.next_in =
const_cast<uint8*
> (data);
83 stream.next_out = buffer;
84 stream.avail_in = (
uInt) dataSize;
85 stream.avail_out = (
uInt)
sizeof (buffer);
87 auto result = isFirstDeflate ?
deflateParams (&stream, compLevel, strategy)
89 isFirstDeflate =
false;
98 data += dataSize - stream.avail_in;
99 dataSize = stream.avail_in;
125 jassert (
out !=
nullptr);
135 helper->finish (*destStream);
148 return destStream->getPosition();
164 void runTest()
override
167 Random
rng = getRandom();
169 for (
int i = 100; --i >= 0;)
176 for (
int j =
rng.nextInt (100); --
j >= 0;)
178 MemoryBlock
data ((
unsigned int) (
rng.nextInt (2000) + 1));
180 for (
int k = (
int)
data.getSize(); --
k >= 0;)
206static GZIPTests gzipTests;
Holds a resizable array of primitive or copy-by-value objects.
Array()=default
Creates an empty array.
ElementType * data() const noexcept
Returns a pointer to the first element in the array.
A stream which uses zlib to compress the data written into it.
GZIPCompressorOutputStream(OutputStream &destStream, int compressionLevel=-1, int windowBits=0)
Creates a compression stream.
bool setPosition(int64) override
Tries to move the stream's output position.
bool write(const void *, size_t) override
Writes a block of data to the stream.
~GZIPCompressorOutputStream() override
Destructor.
void flush() override
Flushes and closes the stream.
int64 getPosition() override
Returns the stream's current position.
The base class for streams that write data to some kind of destination.
This is a base class for classes that perform a unit test.