public void TestErrorDetection() { byte[] invalidInput = new byte[] { 0x1, 0x2, 0x3, 0x4 }; byte[] output = new byte[64 * 1024]; using (BrotliNET bc = new BrotliNET(CompressionMode.Decompress)) { // No Assert.Throws(ยทยทยท) in Microsoft.VisualStudio.TestTools.UnitTesting.Assert ?? AssertThrows( () => { bc.Decompress(invalidInput, 0, 4, output); }, "No error was thrown for an invalid input."); } }
public void TestDecode() { byte[] input = TestResource.BingCN_Compressed; byte[] output = new byte[input.Length * 4]; int outputLength = 0; using (BrotliNET brotli = new BrotliNET(CompressionMode.Decompress)) { outputLength = brotli.Decompress(input, 0, input.Length, output); } string textOutput = Encoding.UTF8.GetString(output, 0, outputLength); Assert.AreEqual( TestResource.BingCN, textOutput, "The decompressed file differs from the expected one."); }
public void TestEncode() { byte[] input = Encoding.UTF8.GetBytes(TestResource.BingCN); byte[] output = new byte[input.Length]; int outputLength = 0; using (BrotliNET brotli = new BrotliNET(CompressionMode.Compress)) { brotli.Quality = 11; brotli.Window = 22; outputLength = brotli.Compress(input, 0, input.Length, output); } Assert.IsTrue(ArraySliceEquals( TestResource.BingCN_Compressed, 0, TestResource.BingCN_Compressed.Length, output, 0, outputLength), "The compressed file differs from the expected one."); }