Skip to content

Commit

Permalink
Add tests for zstd pre-and-postprocessors.
Browse files Browse the repository at this point in the history
Signed-off-by: Daksh Chauhan <dak-x@outlook.com>
  • Loading branch information
dak-x committed Jul 1, 2021
1 parent 121b2c8 commit 54cb8e1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/preprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ impl Preprocessor for Decompress {
decoder.read_to_end(&mut decompressed)?;
decompressed
}
// Zstd Magic : 0xFD2FB528 (but little endian)
Some(&[0x28, 0xb5, 0x2f, 0xfd, _, _]) => zstd::decode_all(data)?,
_ => data.to_vec(),
};
Ok(vec![r])
Expand Down Expand Up @@ -599,7 +601,7 @@ mod test {
Ok(())
}

const LOOKUP_TABLE: [&str; 16] = [
const LOOKUP_TABLE: [&str; 17] = [
"lines",
"lines-null",
"lines-pipe",
Expand All @@ -616,6 +618,7 @@ mod test {
"ingest-ns",
"length-prefixed",
"textual-length-prefix",
"zstd",
];

#[test]
Expand Down Expand Up @@ -747,6 +750,7 @@ mod test {
Some(b"sNaPpY") => "snap",
Some(&[0xff, 0x6, 0x0, 0x0, _, _]) => "snap",
Some(&[0x04, 0x22, 0x4d, 0x18, _, _]) => "lz4",
Some(&[0x28, 0xb5, 0x2f, 0xfd, _, _]) => "zstd",
_ => "fail/unknown",
}
}
Expand Down Expand Up @@ -869,4 +873,11 @@ mod test {
assert_decompress!(int, Lz4, "lz4");
Ok(())
}
#[test]
fn test_zstd() -> Result<()> {
let int = "snot".as_bytes();
assert_simple_symmetric!(int, Zstd, "zstd");
assert_decompress!(int, Zstd, "zstd");
Ok(())
}
}

0 comments on commit 54cb8e1

Please sign in to comment.