Exemplo n.º 1
0
        public void TestDecode()
        {
            var input = GetBytes("TestBrotli.Resource.BingCN_Compressed.bin");

            Byte[] output = null;
            using (System.IO.MemoryStream msInput = new System.IO.MemoryStream(input))
                using (BrotliStream bs = new BrotliStream(msInput, System.IO.Compression.CompressionMode.Decompress))
                    using (System.IO.MemoryStream msOutput = new System.IO.MemoryStream())
                    {
                        bs.CopyTo(msOutput);
                        msOutput.Seek(0, System.IO.SeekOrigin.Begin);
                        output = msOutput.ToArray();
                        Assert.True(ArrayEqual(output, GetBytes("TestBrotli.Resource.BingCN.bin")));
                    }
        }
Exemplo n.º 2
0
 public void TestEmptyStream()
 {
     using (var memoryStream = new MemoryStream())
     {
         using (var brotliStream = new BrotliStream(memoryStream, CompressionMode.Compress, true))
         {
             brotliStream.Flush();
         }
         memoryStream.Seek(0, SeekOrigin.Begin);
         var data = memoryStream.ToArray();
         using (var bs = new BrotliStream(memoryStream, CompressionMode.Decompress))
             using (var msOutput = new MemoryStream())
             {
                 bs.CopyTo(msOutput); // goes bang
                 msOutput.Seek(0, SeekOrigin.Begin);
                 var output = msOutput.ToArray();
                 Assert.True(output.Length == 0);
             }
     }
 }