Example #1
0
 public virtual void TestCompressorSetInputAIOBException()
 {
     try
     {
         Lz4Compressor compressor = new Lz4Compressor();
         compressor.SetInput(new byte[] {  }, -5, 10);
         NUnit.Framework.Assert.Fail("testCompressorSetInputAIOBException error !!!");
     }
     catch (IndexOutOfRangeException)
     {
     }
     catch (Exception)
     {
         // expected
         NUnit.Framework.Assert.Fail("testCompressorSetInputAIOBException ex error !!!");
     }
 }
Example #2
0
 public virtual void TestCompressorSetInputNullPointerException()
 {
     try
     {
         Lz4Compressor compressor = new Lz4Compressor();
         compressor.SetInput(null, 0, 10);
         NUnit.Framework.Assert.Fail("testCompressorSetInputNullPointerException error !!!"
                                     );
     }
     catch (ArgumentNullException)
     {
     }
     catch (Exception)
     {
         // expected
         NUnit.Framework.Assert.Fail("testCompressorSetInputNullPointerException ex error !!!"
                                     );
     }
 }
Example #3
0
 public virtual void TestCompressorCompressAIOBException()
 {
     try
     {
         Lz4Compressor compressor = new Lz4Compressor();
         byte[]        bytes      = Generate(1024 * 6);
         compressor.SetInput(bytes, 0, bytes.Length);
         compressor.Compress(new byte[] {  }, 0, -1);
         NUnit.Framework.Assert.Fail("testCompressorCompressAIOBException error !!!");
     }
     catch (IndexOutOfRangeException)
     {
     }
     catch (Exception)
     {
         // expected
         NUnit.Framework.Assert.Fail("testCompressorCompressAIOBException ex error !!!");
     }
 }
Example #4
0
 public virtual void TestCompressorCompressNullPointerException()
 {
     try
     {
         Lz4Compressor compressor = new Lz4Compressor();
         byte[]        bytes      = Generate(1024 * 6);
         compressor.SetInput(bytes, 0, bytes.Length);
         compressor.Compress(null, 0, 0);
         NUnit.Framework.Assert.Fail("testCompressorCompressNullPointerException error !!!"
                                     );
     }
     catch (ArgumentNullException)
     {
     }
     catch (Exception)
     {
         // expected
         NUnit.Framework.Assert.Fail("testCompressorCompressNullPointerException ex error !!!"
                                     );
     }
 }
Example #5
0
        public virtual void TestSetInputWithBytesSizeMoreThenDefaultLz4CompressorByfferSize
            ()
        {
            int BytesSize = 1024 * 64 + 1;

            try
            {
                Lz4Compressor compressor = new Lz4Compressor();
                byte[]        bytes      = Generate(BytesSize);
                Assert.True("needsInput error !!!", compressor.NeedsInput());
                compressor.SetInput(bytes, 0, bytes.Length);
                byte[] emptyBytes = new byte[BytesSize];
                int    csize      = compressor.Compress(emptyBytes, 0, bytes.Length);
                Assert.True("testSetInputWithBytesSizeMoreThenDefaultLz4CompressorByfferSize error !!!"
                            , csize != 0);
            }
            catch (Exception)
            {
                NUnit.Framework.Assert.Fail("testSetInputWithBytesSizeMoreThenDefaultLz4CompressorByfferSize ex error !!!"
                                            );
            }
        }
Example #6
0
        public virtual void TestCompressDecompress()
        {
            int ByteSize = 1024 * 54;

            byte[]        bytes      = Generate(ByteSize);
            Lz4Compressor compressor = new Lz4Compressor();

            try
            {
                compressor.SetInput(bytes, 0, bytes.Length);
                Assert.True("Lz4CompressDecompress getBytesRead error !!!", compressor
                            .GetBytesRead() > 0);
                Assert.True("Lz4CompressDecompress getBytesWritten before compress error !!!"
                            , compressor.GetBytesWritten() == 0);
                byte[] compressed = new byte[ByteSize];
                int    cSize      = compressor.Compress(compressed, 0, compressed.Length);
                Assert.True("Lz4CompressDecompress getBytesWritten after compress error !!!"
                            , compressor.GetBytesWritten() > 0);
                Lz4Decompressor decompressor = new Lz4Decompressor();
                // set as input for decompressor only compressed data indicated with cSize
                decompressor.SetInput(compressed, 0, cSize);
                byte[] decompressed = new byte[ByteSize];
                decompressor.Decompress(decompressed, 0, decompressed.Length);
                Assert.True("testLz4CompressDecompress finished error !!!", decompressor
                            .Finished());
                Assert.AssertArrayEquals(bytes, decompressed);
                compressor.Reset();
                decompressor.Reset();
                Assert.True("decompressor getRemaining error !!!", decompressor
                            .GetRemaining() == 0);
            }
            catch (Exception)
            {
                NUnit.Framework.Assert.Fail("testLz4CompressDecompress ex error!!!");
            }
        }