public void CheckCompressDecompress(CompressionAlgorithm algorithm) { if (!TestRuntime.CheckXcodeVersion(7, 0)) { Assert.Ignore("Requires iOS 9.0+ or macOS 10.11+"); } byte [] data = new byte[100000]; for (int i = 0; i < 100000; i++) { data[i] = (byte)i; } MemoryStream dataStream = new MemoryStream(data); MemoryStream backing = new MemoryStream(); DeflateStream compressing = new DeflateStream(backing, CompressionMode.Compress, algorithm, true); CopyStream(dataStream, compressing); dataStream.Close(); compressing.Close(); backing.Seek(0, SeekOrigin.Begin); DeflateStream decompressing = new DeflateStream(backing, CompressionMode.Decompress, algorithm); MemoryStream output = new MemoryStream(); CopyStream(decompressing, output); Assert.AreNotEqual(0, output.Length, "Length should be more than 0."); Assert.IsTrue(compare_buffers(data, output.GetBuffer(), (int)output.Length), "Buffers are not equal."); decompressing.Close(); output.Close(); }
public void CheckClosedFlush() { MemoryStream backing = new MemoryStream(); DeflateStream compressing = new DeflateStream(backing, CompressionMode.Compress, CompressionAlgorithm.Zlib); compressing.Close(); compressing.Flush(); }
[Test] // Not passing the algorithm because the compressed data is Zlib compressed. public void CheckDecompress() { MemoryStream backing = new MemoryStream(compressed_data); DeflateStream decompressing = new DeflateStream(backing, CompressionMode.Decompress, CompressionAlgorithm.Zlib); StreamReader reader = new StreamReader(decompressing); Assert.AreEqual("Hello", reader.ReadLine()); decompressing.Close(); }
public void CheckClosedRead() { byte [] dummy = new byte[20]; MemoryStream backing = new MemoryStream(compressed_data); DeflateStream decompressing = new DeflateStream(backing, CompressionMode.Decompress, CompressionAlgorithm.Zlib); decompressing.Close(); decompressing.Read(dummy, 0, 20); }
public void CheckClosedFlush() { if (!TestRuntime.CheckXcodeVersion(7, 0)) { Assert.Ignore("Requires iOS 9.0+ or macOS 10.11+"); } MemoryStream backing = new MemoryStream(); DeflateStream compressing = new DeflateStream(backing, CompressionMode.Compress, CompressionAlgorithm.Zlib); compressing.Close(); compressing.Flush(); }
public void CheckClosedRead() { if (!TestRuntime.CheckXcodeVersion(7, 0)) { Assert.Ignore("Requires iOS 9.0+ or macOS 10.11+"); } byte [] dummy = new byte[20]; MemoryStream backing = new MemoryStream(compressed_data); DeflateStream decompressing = new DeflateStream(backing, CompressionMode.Decompress, CompressionAlgorithm.Zlib); decompressing.Close(); decompressing.Read(dummy, 0, 20); }
[Test] // Not passing the algorithm because the compressed data is Zlib compressed. public void CheckDecompress() { if (!TestRuntime.CheckXcodeVersion(7, 0)) { Assert.Ignore("Requires iOS 9.0+ or macOS 10.11+"); } MemoryStream backing = new MemoryStream(compressed_data); DeflateStream decompressing = new DeflateStream(backing, CompressionMode.Decompress, CompressionAlgorithm.Zlib); StreamReader reader = new StreamReader(decompressing); Assert.AreEqual("Hello", reader.ReadLine()); decompressing.Close(); }