Example #1
0
        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.");
            }
        }
Example #2
0
        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.");
        }