diff --git a/src/block/compress.rs b/src/block/compress.rs index 64a77ac8..8185cc8c 100644 --- a/src/block/compress.rs +++ b/src/block/compress.rs @@ -820,7 +820,8 @@ mod tests { #[test] fn test_dict() { let input: &[u8] = &[ - 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, + 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 14, 16, + 18, 10, 12, 14, 16, 18, ]; let dict = input; let compressed = compress_with_dict(input, dict); @@ -841,7 +842,8 @@ mod tests { #[test] fn test_dict_match_crossing() { let input: &[u8] = &[ - 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, + 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, + 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, 10, 12, 14, 16, 18, ]; let dict = input; let compressed = compress_with_dict(input, dict); @@ -878,33 +880,33 @@ mod tests { // so it needs at least one prior byte. // When a block can reference data from another block, it can start immediately with a match // and no literal, so a block of 12 bytes can be compressed. - let aaas: &[u8] = b"aaaaaaaaaaaaaaa"; + let aaas: &[u8] = b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; // uncompressible - let out = compress(&aaas[..12]); - assert_gt!(out.len(), 12); + let out = compress(&aaas[..MFLIMIT]); + assert_gt!(out.len(), MFLIMIT); // compressible - let out = compress(&aaas[..13]); - assert_le!(out.len(), 13); - let out = compress(&aaas[..14]); - assert_le!(out.len(), 14); - let out = compress(&aaas[..15]); - assert_le!(out.len(), 15); + let out = compress(&aaas[..MFLIMIT + 1]); + assert_le!(out.len(), MFLIMIT + 1); + let out = compress(&aaas[..MFLIMIT + 2]); + assert_le!(out.len(), MFLIMIT + 2); + let out = compress(&aaas[..MFLIMIT + 3]); + assert_le!(out.len(), MFLIMIT + 3); // dict uncompressible - let out = compress_with_dict(&aaas[..11], aaas); - assert_gt!(out.len(), 11); + let out = compress_with_dict(&aaas[..MFLIMIT - 1], aaas); + assert_gt!(out.len(), MFLIMIT - 1); // compressible - let out = compress_with_dict(&aaas[..12], aaas); + let out = compress_with_dict(&aaas[..MFLIMIT], aaas); // According to the spec this _could_ compres, but it doesn't in this lib // as it aborts compression for any input len < LZ4_MIN_LENGTH - assert_gt!(out.len(), 12); - let out = compress_with_dict(&aaas[..13], aaas); - assert_le!(out.len(), 13); - let out = compress_with_dict(&aaas[..14], aaas); - assert_le!(out.len(), 14); - let out = compress_with_dict(&aaas[..15], aaas); - assert_le!(out.len(), 15); + assert_gt!(out.len(), MFLIMIT); + let out = compress_with_dict(&aaas[..MFLIMIT + 1], aaas); + assert_le!(out.len(), MFLIMIT + 1); + let out = compress_with_dict(&aaas[..MFLIMIT + 2], aaas); + assert_le!(out.len(), MFLIMIT + 2); + let out = compress_with_dict(&aaas[..MFLIMIT + 3], aaas); + assert_le!(out.len(), MFLIMIT + 3); } #[test]