private void TestCompression(ICompression compression)
        {
            var compressed   = new byte[65536];
            var uncompressed = new byte[65536];

            compression.TryCompress(_data, 0, _data.Length, compressed, 0, compressed.Length,
                                    out var writtenCompressed);
            compression.TryDecompress(compressed, 0, writtenCompressed, uncompressed, 0, uncompressed.Length,
                                      out _);
        }
Example #2
0
        private void TestCompression(ICompression compression)
        {
            var source       = new byte[65536];
            var compressed   = new byte[65536];
            var uncompressed = new byte[65536];

            var random = new Random();

            Array.Fill <byte>(source, 0xFF);
            random.NextBytes(new Span <byte>(source, 16384, 16384));

            Assert.True(compression.TryCompress(source, 0, source.Length, compressed, 0, compressed.Length, out var writtenCompressed));
            Assert.True(compression.TryDecompress(compressed, 0, writtenCompressed, uncompressed, 0, uncompressed.Length, out var writtenUncompressed));
            Assert.Equal(writtenUncompressed, source.Length);
            Assert.Equal(source, uncompressed);
        }
Example #3
0
 protected bool TryCompress(out int written)
 {
     return(_compression.TryCompress(_chunkBytes, LENGTH_SIZE, _chunkLength,
                                     _chunkCompressedBytes, LENGTH_SIZE, ChunkSize, out written));
 }