コード例 #1
0
        private static void Roundtrip(byte[] source)
        {
            var compressedOld = _LZ4.Encode(source, 0, source.Length);
            var compressedNew = LZ4CodecHelper.Encode(source, 0, source.Length, LZ4Level.L00_FAST);

            Tools.SameBytes(
                source,
                _LZ4.Decode(compressedNew, 0, compressedNew.Length, source.Length));

            Tools.SameBytes(
                source,
                LZ4CodecHelper.Decode(compressedNew, 0, compressedNew.Length, source.Length));

            Tools.SameBytes(
                source,
                LZ4CodecHelper.Decode(compressedOld, 0, compressedOld.Length, source.Length));
        }
コード例 #2
0
        // 32
        //[InlineData(".corpus/dickens", 0, 10192446, 6432049, 0x6144792e, "8CMqKlRoZSBQcm9qZWN0IEd1dGVuYmVyZyBFdGV4dCBvZiBBIENoaWxkJ3MgSGlzdG9yeRUA8CJFbmds")]
        //[InlineData(".corpus/mozilla", 0, 51220480, 26375278, 0xaaf353d0, "n21vemlsbGEvAAEASOAgNDA3NTUgACAgMjYwMAgANCAgIAgAAQIA/wgwICA3NDc1NzQyNzYxICAxMDc2")]
        //[InlineData(".corpus/mr", 0, 9970564, 5669219, 0xfcd03aa6, "8CEIAAUACgAAAElTT19JUiAxMDAIAAgAFgAAAE9SSUdJTkFMXFBSSU1BUllcT1RIRVIcAPAKGgAAADEu")]
        //[InlineData(".corpus/nci", 0, 33553445, 5877051, 0xd7feea9a, "8BYxNTU1NDIKUk90Y2xzZXJ2ZTExMTUwMDExMjEyRCAwICAgMC4wAQAQIAEAAwwA8AIxMDQ5NTIxCiAK")]
        //[InlineData(".corpus/ooffice", 0, 6152192, 4228589, 0x13f4365f, "8gNNWpAAAwAAAAQAAAD//wAAuAABABJABwAPAgAK8y7wAAAADh+6DgC0Cc0huAFMzSFUaGlzIHByb2dy")]
        //[InlineData(".corpus/osdb", 0, 10085684, 5223143, 0x4df76a, "8w4DAE8BYAIThAEAAHUlBa4AAAC5za/NhecSTgw2MQIA8T0uMDAJNy8xNy8xOTQ0RmhYVHViOlpRTjVt")]
        //[InlineData(".corpus/reymont", 0, 6627202, 3520792, 0xb81a006b, "8hElUERGLTEuMwozIDAgb2JqIDw8Ci9MZW5ndGggMTUzIAEA8SgKPj4Kc3RyZWFtCjEgMCAwIDEgMjQ0")]
        //[InlineData(".corpus/samba", 0, 21606400, 7897177, 0x8cd79ae9, "73NhbWJhLTIuMi4zYS8AAQBD8AAwMDQwNzU1ADAwMDE3NjEIAEEwMTUyCAADAgD/BwAwNzQyNzEwNDAy")]
        //[InlineData(".corpus/sao", 0, 7251944, 6595675, 0xecfd9131, "sAAAAAABAAAAtfMDCwABDAAAEADwRRwAAADUp7sLt0o4P2umFdrAF/c/QTDQApkGIrWqlCYyt0v4mJ/k")]
        //[InlineData(".corpus/webster", 0, 41458703, 20360352, 0x420439f9, "8BINClRoZSBQcm9qZWN0IEd1dGVuYmVyZyBFdGV4dCBvZiAfAPqfMTkxMyBXZWJzdGVyIFVuYWJyaWRn")]
        //[InlineData(".corpus/xml", 0, 5345280, 1288300, 0x55f0b8a6, "n2VsdHMueG1sAAEASOkxMDA3NzUgACAgIDc2NAgA/w8gIDMzNDc1NyAgNzE3NDM2NjM3MCAgMTIyMDEA")]
        //[InlineData(".corpus/x-ray", 0, 8474240, 8163278, 0xbdf802fe, "/w/QAQAQB2wItgAQAAEBEQ6zRlNfQS4zMTk3LmltZwABAA9vQkxLTTE4KAAPBAIAUzgwMDEwMQDzDjgw")]
        public void CompressedFilesBinaryIdentical(
            string filename, int index, int length, int expectedCompressedLength, uint expectedChecksum, string expectedBytes64)
        {
            var src = Tools.LoadChunk(Tools.FindFile(filename), index, length);

            var dst = LZ4CodecHelper.Encode(src, 0, src.Length, LZ4Level.L00_FAST);
            var cmp = LZ4CodecHelper.Decode(dst, 0, dst.Length, src.Length);

            string AsHex(uint value) => $"0x{value:x8}";

            Tools.SameBytes(src, cmp);

            var expectedBytes = Convert.FromBase64String(expectedBytes64);

            Tools.SameBytes(expectedBytes, dst, expectedBytes.Length);
            Assert.Equal(expectedCompressedLength, dst.Length);
            Assert.Equal(AsHex(expectedChecksum), AsHex(Tools.Adler32(dst)));
        }