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 _);
        }
Exemple #2
0
        protected void TryDecompress()
        {
            ReadFill(_chunkCompressedBytes, 0, _chunkLength);
            if (!_compression.TryDecompress(
                    _chunkCompressedBytes, 0, _chunkLength,
                    _chunkBytes, 0, ChunkSize, out var written))
            {
                throw new SyncException("Chunk decompress failed");
            }

            _chunkLength = written;
        }
Exemple #3
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);
        }