use oxgraph_layout_util::crc32c_append;
use proptest::prelude::*;
#[test]
fn known_check_vector() {
assert_eq!(crc32c_append(0, b"123456789"), 0xE306_9283);
}
#[test]
fn empty_input_is_zero() {
assert_eq!(crc32c_append(0, b""), 0);
}
proptest! {
#![proptest_config(ProptestConfig {
failure_persistence: None,
..ProptestConfig::default()
})]
#[test]
fn matches_crc32c_crate(
seed in any::<u32>(),
bytes in proptest::collection::vec(any::<u8>(), 0..2048),
) {
prop_assert_eq!(crc32c_append(seed, &bytes), crc32c::crc32c_append(seed, &bytes));
}
#[test]
fn continuation_matches_single_shot(
bytes in proptest::collection::vec(any::<u8>(), 0..512),
split in any::<proptest::sample::Index>(),
) {
let mid = split.index(bytes.len() + 1);
let (head, tail) = bytes.split_at(mid);
prop_assert_eq!(
crc32c_append(crc32c_append(0, head), tail),
crc32c_append(0, &bytes)
);
}
}