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 !!!"); } }
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 !!!" ); } }
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 !!!" ); } }
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!!!"); } }