Example #1
0
        public void CompressTest1()
        {
            for (int i = 0; i < 1000; i++)
            {
                byte[] buffer = new byte[1000];

                var rnd = new Random();
                rnd.NextBytes(buffer);


                var deflated = BZip2.Compress(buffer);
                var inflated = BZip2.Decompress(deflated);

                Assert.AreEqual(buffer.Length, inflated.Length);

                //for (var i = 0; i < buffer.Length; i++)
                //{
                //    Assert.AreEqual(buffer[i], inflated[i]);
                //}

                if (i % 100 == 0)
                {
                    Console.WriteLine(MemInfo.GetCurProcessMem());
                }
            }
        }
Example #2
0
        public void CompressTest()
        {
            for (int i = 0; i < 1000; i++)
            {
                byte[] buf = new byte[10000];
                var    rnd = new Random();
                rnd.NextBytes(buf);

                var input_stream  = new MemoryStream(buf);
                var output_stream = new MemoryStream();
                BZip2.Compress(input_stream, output_stream, true, 9);

                input_stream = new MemoryStream(output_stream.ToArray());
                var decompressed_stream = new MemoryStream();
                BZip2.Decompress(input_stream, decompressed_stream, true);

                var decompressed_bytes = decompressed_stream.ToArray();
                Assert.AreEqual(buf.Length, decompressed_bytes.Length);

                //for (int i = 0; i < buf.Length; i++)
                //{
                //    Assert.AreEqual(buf[i], decompressed_bytes[i]);
                //}
                Thread.Sleep(1);
                Console.WriteLine(MemInfo.GetCurProcessMem());
            }
        }