[Test]         // zlib specific test
 public void Bug19313()
 {
     byte [] buffer = new byte [512];
     using (var backing = new Bug19313Stream(compressed_data))
         using (var decompressing = new DeflateStream(backing, CompressionMode.Decompress, CompressionAlgorithm.Zlib))
             decompressing.Read(buffer, 0, buffer.Length);
 }
        public void JunkAtTheEnd(CompressionAlgorithm algorithm)
        {
            if (!TestRuntime.CheckXcodeVersion(7, 0))
            {
                Assert.Ignore("Requires iOS 9.0+ or macOS 10.11+");
            }
            // Write a deflated stream, then some additional data...
            using (MemoryStream ms = new MemoryStream())
            {
                // The compressed stream
                using (DeflateStream stream = new DeflateStream(ms, CompressionMode.Compress, algorithm, true))
                {
                    stream.WriteByte(1);
                    stream.Flush();
                }
                // Junk
                ms.WriteByte(2);

                ms.Position = 0;
                // Reading: this should not hang
                using (DeflateStream stream = new DeflateStream(ms, CompressionMode.Decompress, algorithm))
                {
                    byte[] buffer = new byte[512];
                    int    len    = stream.Read(buffer, 0, buffer.Length);
                    Console.WriteLine(len == 1);
                }
            }
        }
        public void CheckNullRead()
        {
            MemoryStream  backing       = new MemoryStream(compressed_data);
            DeflateStream decompressing = new DeflateStream(backing, CompressionMode.Decompress, CompressionAlgorithm.Zlib);

            decompressing.Read(null, 0, 20);
        }
        public void CheckRangeRead()
        {
            byte []       dummy         = new byte[20];
            MemoryStream  backing       = new MemoryStream(compressed_data);
            DeflateStream decompressing = new DeflateStream(backing, CompressionMode.Decompress, CompressionAlgorithm.Zlib);

            decompressing.Read(dummy, 10, 20);
        }
        public void CheckCompressingRead()
        {
            byte []       dummy       = new byte[20];
            MemoryStream  backing     = new MemoryStream();
            DeflateStream compressing = new DeflateStream(backing, CompressionMode.Compress, CompressionAlgorithm.Zlib);

            compressing.Read(dummy, 0, 20);
        }
 [Test]         // zlib specific test
 public void Bug19313()
 {
     if (!TestRuntime.CheckXcodeVersion(7, 0))
     {
         Assert.Ignore("Requires iOS 9.0+ or macOS 10.11+");
     }
     byte [] buffer = new byte [512];
     using (var backing = new Bug19313Stream(compressed_data))
         using (var decompressing = new DeflateStream(backing, CompressionMode.Decompress, CompressionAlgorithm.Zlib))
             decompressing.Read(buffer, 0, buffer.Length);
 }
        public void CheckNullRead()
        {
            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);

            decompressing.Read(null, 0, 20);
        }
        public void CheckCompressingRead()
        {
            if (!TestRuntime.CheckXcodeVersion(7, 0))
            {
                Assert.Ignore("Requires iOS 9.0+ or macOS 10.11+");
            }
            byte []       dummy       = new byte[20];
            MemoryStream  backing     = new MemoryStream();
            DeflateStream compressing = new DeflateStream(backing, CompressionMode.Compress, CompressionAlgorithm.Zlib);

            compressing.Read(dummy, 0, 20);
        }
Exemplo n.º 9
0
        public void CheckRangeRead()
        {
            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);

            Assert.Throws <ArgumentException> (() => decompressing.Read(dummy, 10, 20));
        }
        public void JunkAtTheEnd(CompressionAlgorithm algorithm)
        {
            // Write a deflated stream, then some additional data...
            using (MemoryStream ms = new MemoryStream())
            {
                // The compressed stream
                using (DeflateStream stream = new DeflateStream(ms, CompressionMode.Compress, algorithm, true))
                {
                    stream.WriteByte(1);
                    stream.Flush();
                }
                // Junk
                ms.WriteByte(2);

                ms.Position = 0;
                // Reading: this should not hang
                using (DeflateStream stream = new DeflateStream(ms, CompressionMode.Decompress, algorithm))
                {
                    byte[] buffer = new byte[512];
                    int    len    = stream.Read(buffer, 0, buffer.Length);
                    Console.WriteLine(len == 1);
                }
            }
        }