diff --git a/Cargo.lock b/Cargo.lock index 104e98f..e857def 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -167,13 +167,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "examples" -version = "0.0.0" -dependencies = [ - "datasketches", -] - [[package]] name = "fastrand" version = "2.3.0" diff --git a/datasketches/src/theta/bit_pack.rs b/datasketches/src/theta/bit_pack.rs index 0c8902f..2271ea2 100644 --- a/datasketches/src/theta/bit_pack.rs +++ b/datasketches/src/theta/bit_pack.rs @@ -5323,6 +5323,22 @@ mod tests { } } + #[test] + #[should_panic(expected = "values length must be 8")] + fn pack_bits_block_rejects_invalid_values_len() { + let input = [0u64; BLOCK_WIDTH + 1]; + let mut bytes = [0u8; 1]; + pack_bits_block(&input, &mut bytes, 1); + } + + #[test] + #[should_panic(expected = "values length must be 8")] + fn unpack_bits_block_rejects_invalid_values_len() { + let mut output = [0u64; BLOCK_WIDTH - 1]; + let bytes = [0u8; 1]; + unpack_bits_block(&mut output, &bytes, 1); + } + #[test] #[should_panic(expected = "wrong number of bits in pack_bits_block8")] fn pack_bits_block8_rejects_zero_bits() { @@ -5339,6 +5355,22 @@ mod tests { unpack_bits_block(&mut output, &bytes, 64); } + #[test] + #[should_panic(expected = "output buffer too small")] + fn pack_bits_block_rejects_buffer_too_small() { + let input = [0u64; BLOCK_WIDTH]; + let mut bytes = [0u8; 1]; + pack_bits_block(&input, &mut bytes, 2); + } + + #[test] + #[should_panic(expected = "output buffer too small")] + fn unpack_bits_block_rejects_buffer_too_small() { + let mut output = [0u64; BLOCK_WIDTH]; + let bytes = [0u8; 1]; + unpack_bits_block(&mut output, &bytes, 2); + } + #[test] #[should_panic] fn packer_panics_on_buffer_overflow() { diff --git a/datasketches/tests/cpc_union_test.rs b/datasketches/tests/cpc_union_test.rs index e8d2017..36badbd 100644 --- a/datasketches/tests/cpc_union_test.rs +++ b/datasketches/tests/cpc_union_test.rs @@ -167,3 +167,15 @@ fn test_reduce_k_window() { near(1000.0, RELATIVE_ERROR_FOR_LG_K_11 * 10000.0) ); } + +#[test] +#[should_panic] +fn test_lg_k_too_small() { + let _ = CpcSketch::new(3); +} + +#[test] +#[should_panic] +fn test_lg_k_too_large() { + let _ = CpcSketch::new(27); +}