Exemple #1
0
 public virtual void TestDecompressorSetInputAIOUBException()
 {
     try
     {
         Lz4Decompressor decompressor = new Lz4Decompressor();
         decompressor.SetInput(new byte[] {  }, -5, 10);
         NUnit.Framework.Assert.Fail("testDecompressorSetInputAIOBException error !!!");
     }
     catch (IndexOutOfRangeException)
     {
     }
     catch (Exception)
     {
         // expected
         NUnit.Framework.Assert.Fail("testDecompressorSetInputAIOBException ex error !!!");
     }
 }
Exemple #2
0
 public virtual void TestDecompressorSetInputNullPointerException()
 {
     try
     {
         Lz4Decompressor decompressor = new Lz4Decompressor();
         decompressor.SetInput(null, 0, 10);
         NUnit.Framework.Assert.Fail("testDecompressorSetInputNullPointerException error !!!"
                                     );
     }
     catch (ArgumentNullException)
     {
     }
     catch (Exception)
     {
         // expected
         NUnit.Framework.Assert.Fail("testDecompressorSetInputNullPointerException ex error !!!"
                                     );
     }
 }
Exemple #3
0
 public virtual void TestDecompressorCompressAIOBException()
 {
     try
     {
         Lz4Decompressor decompressor = new Lz4Decompressor();
         byte[]          bytes        = Generate(1024 * 6);
         decompressor.SetInput(bytes, 0, bytes.Length);
         decompressor.Decompress(new byte[] {  }, 0, -1);
         NUnit.Framework.Assert.Fail("testDecompressorCompressAIOBException error !!!");
     }
     catch (IndexOutOfRangeException)
     {
     }
     catch (Exception)
     {
         // expected
         NUnit.Framework.Assert.Fail("testDecompressorCompressAIOBException ex error !!!");
     }
 }
Exemple #4
0
 public virtual void TestDecompressorCompressNullPointerException()
 {
     try
     {
         Lz4Decompressor decompressor = new Lz4Decompressor();
         byte[]          bytes        = Generate(1024 * 6);
         decompressor.SetInput(bytes, 0, bytes.Length);
         decompressor.Decompress(null, 0, 0);
         NUnit.Framework.Assert.Fail("testDecompressorCompressNullPointerException error !!!"
                                     );
     }
     catch (ArgumentNullException)
     {
     }
     catch (Exception)
     {
         // expected
         NUnit.Framework.Assert.Fail("testDecompressorCompressNullPointerException ex error !!!"
                                     );
     }
 }
Exemple #5
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!!!");
            }
        }