This is an automated email from the ASF dual-hosted git repository.

tison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new 6398732  tests: add boundary tests for bit_pack and CpcSketch (#108)
6398732 is described below

commit 6398732a8177e420a8a1d9c038eb82999019946f
Author: Yichi Zhang <[email protected]>
AuthorDate: Sat Apr 11 15:11:12 2026 +0800

    tests: add boundary tests for bit_pack and CpcSketch (#108)
    
    Co-authored-by: tison <[email protected]>
---
 Cargo.lock                           |  7 -------
 datasketches/src/theta/bit_pack.rs   | 32 ++++++++++++++++++++++++++++++++
 datasketches/tests/cpc_union_test.rs | 12 ++++++++++++
 3 files changed, 44 insertions(+), 7 deletions(-)

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);
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to