public void CompressInvalidArgumentsTest(int offset, int length, int compressedOffset, int compressedLength) { byte[] buffer = new byte[1024]; byte[] compressedBuffer = new byte[1024]; Assert.Throws <ArgumentOutOfRangeException>(() => LzfseCompressor.Compress(buffer, offset, length, compressedBuffer, compressedOffset, compressedLength)); }
public void CompressNullTest() { byte[] buffer = Array.Empty <byte>(); Assert.Throws <ArgumentNullException>(() => LzfseCompressor.Compress(buffer, null)); Assert.Throws <ArgumentNullException>(() => LzfseCompressor.Compress(null, buffer)); Assert.Throws <ArgumentNullException>(() => LzfseCompressor.Compress(buffer, 0, 0, null, 0, 0)); Assert.Throws <ArgumentNullException>(() => LzfseCompressor.Compress(null, 0, 0, buffer, 0, 0)); }
public void RoundtripTest() { byte[] buffer = Encoding.UTF8.GetBytes("Hello, World!"); byte[] compressedBuffer = new byte[1024]; byte[] decompressedBuffer = new byte[1024]; Assert.NotEqual(0, LzfseCompressor.Compress(buffer, compressedBuffer)); Assert.Equal(buffer.Length, LzfseCompressor.Decompress(compressedBuffer, decompressedBuffer)); Assert.Equal("Hello, World!", Encoding.UTF8.GetString(decompressedBuffer, 0, buffer.Length)); }
/// <summary> /// The main entrypoint. /// </summary> /// <param name="args"> /// Command-line arguments /// </param> public static void Main(string[] args) { byte[] buffer = Encoding.UTF8.GetBytes("Hello, World!"); byte[] compressedBuffer = new byte[1024]; byte[] decompressedBuffer = new byte[1024]; LzfseCompressor.Compress(buffer, compressedBuffer); int length = LzfseCompressor.Decompress(compressedBuffer, decompressedBuffer); Console.WriteLine(Encoding.UTF8.GetString(decompressedBuffer, 0, length)); }