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

tisonkun 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 bcb83e6  chore(deps): upgrade rand to 0.10 and use quickcheck (#215)
bcb83e6 is described below

commit bcb83e629ae86eb8619bb7eb0a372a172c94b79c
Author: tison <[email protected]>
AuthorDate: Tue Aug 25 10:45:48 2026 +0800

    chore(deps): upgrade rand to 0.10 and use quickcheck (#215)
    
    Signed-off-by: tison <[email protected]>
---
 Cargo.lock                                     | 190 +++++--------------------
 Cargo.toml                                     |   4 +-
 datasketches/Cargo.toml                        |   2 +-
 datasketches/tests/req_test/accuracy.rs        |   2 -
 datasketches/tests/req_test/bounds.rs          |   2 -
 datasketches/tests/req_test/core.rs            |   2 -
 datasketches/tests/req_test/merge.rs           |   2 -
 datasketches/tests/req_test/property.rs        |  99 +++++++++----
 datasketches/tests/req_test/query.rs           |   2 -
 datasketches/tests/req_test/sorted_view_api.rs |   2 -
 datasketches/tests/req_test/structure.rs       |   2 -
 datasketches/tests/req_test/union.rs           |   2 -
 12 files changed, 104 insertions(+), 207 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 8ad1542..fe379e8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -79,21 +79,6 @@ version = "0.22.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
 
-[[package]]
-name = "bit-set"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
-dependencies = [
- "bit-vec",
-]
-
-[[package]]
-name = "bit-vec"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
-
 [[package]]
 name = "bitflags"
 version = "2.13.1"
@@ -160,6 +145,17 @@ version = "1.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
 
+[[package]]
+name = "chacha20"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "rand_core",
+]
+
 [[package]]
 name = "clap"
 version = "4.6.5"
@@ -224,6 +220,15 @@ dependencies = [
  "windows-sys 0.61.2",
 ]
 
+[[package]]
+name = "cpufeatures"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
+dependencies = [
+ "libc",
+]
+
 [[package]]
 name = "datasketches"
 version = "0.4.0"
@@ -231,7 +236,7 @@ dependencies = [
  "divan",
  "googletest",
  "insta",
- "proptest",
+ "quickcheck",
  "rand",
 ]
 
@@ -308,12 +313,6 @@ dependencies = [
  "zlib-rs",
 ]
 
-[[package]]
-name = "fnv"
-version = "1.0.7"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
-
 [[package]]
 name = "getrandom"
 version = "0.2.17"
@@ -325,18 +324,6 @@ dependencies = [
  "wasi",
 ]
 
-[[package]]
-name = "getrandom"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
-dependencies = [
- "cfg-if",
- "libc",
- "r-efi 5.3.0",
- "wasip2",
-]
-
 [[package]]
 name = "getrandom"
 version = "0.4.3"
@@ -345,7 +332,8 @@ checksum = 
"300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
 dependencies = [
  "cfg-if",
  "libc",
- "r-efi 6.0.0",
+ "r-efi",
+ "rand_core",
 ]
 
 [[package]]
@@ -478,15 +466,6 @@ version = "2.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
 
-[[package]]
-name = "ppv-lite86"
-version = "0.2.21"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
-dependencies = [
- "zerocopy",
-]
-
 [[package]]
 name = "proc-macro2"
 version = "1.0.107"
@@ -497,30 +476,14 @@ dependencies = [
 ]
 
 [[package]]
-name = "proptest"
-version = "1.11.0"
+name = "quickcheck"
+version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744"
+checksum = "95c589f335db0f6aaa168a7cd27b1fc6920f5e1470c804f814d9cd6e62a0f70b"
 dependencies = [
- "bit-set",
- "bit-vec",
- "bitflags",
- "num-traits",
  "rand",
- "rand_chacha",
- "rand_xorshift",
- "regex-syntax",
- "rusty-fork",
- "tempfile",
- "unarray",
 ]
 
-[[package]]
-name = "quick-error"
-version = "1.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
-
 [[package]]
 name = "quote"
 version = "1.0.47"
@@ -530,12 +493,6 @@ dependencies = [
  "proc-macro2",
 ]
 
-[[package]]
-name = "r-efi"
-version = "5.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
-
 [[package]]
 name = "r-efi"
 version = "6.0.0"
@@ -544,41 +501,20 @@ checksum = 
"f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
 
 [[package]]
 name = "rand"
-version = "0.9.5"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41"
-dependencies = [
- "rand_chacha",
- "rand_core",
-]
-
-[[package]]
-name = "rand_chacha"
-version = "0.9.0"
+version = "0.10.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
+checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"
 dependencies = [
- "ppv-lite86",
+ "chacha20",
+ "getrandom 0.4.3",
  "rand_core",
 ]
 
 [[package]]
 name = "rand_core"
-version = "0.9.5"
+version = "0.10.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
-dependencies = [
- "getrandom 0.3.4",
-]
-
-[[package]]
-name = "rand_xorshift"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a"
-dependencies = [
- "rand_core",
-]
+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
 
 [[package]]
 name = "regex"
@@ -683,18 +619,6 @@ version = "1.0.23"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
 
-[[package]]
-name = "rusty-fork"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "cc6bf79ff24e648f6da1f8d1f011e9cac26491b619e6b9280f2b47f1774e6ee2"
-dependencies = [
- "fnv",
- "quick-error",
- "tempfile",
- "wait-timeout",
-]
-
 [[package]]
 name = "semver"
 version = "1.0.28"
@@ -864,12 +788,6 @@ dependencies = [
  "syn 3.0.3",
 ]
 
-[[package]]
-name = "unarray"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94"
-
 [[package]]
 name = "unicode-ident"
 version = "1.0.24"
@@ -923,30 +841,12 @@ version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
 
-[[package]]
-name = "wait-timeout"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11"
-dependencies = [
- "libc",
-]
-
 [[package]]
 name = "wasi"
 version = "0.11.1+wasi-snapshot-preview1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
 
-[[package]]
-name = "wasip2"
-version = "1.0.1+wasi-0.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
-dependencies = [
- "wit-bindgen",
-]
-
 [[package]]
 name = "webpki-roots"
 version = "1.0.9"
@@ -1075,12 +975,6 @@ version = "0.52.6"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
 
-[[package]]
-name = "wit-bindgen"
-version = "0.46.0"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
-
 [[package]]
 name = "x"
 version = "0.0.0"
@@ -1093,26 +987,6 @@ dependencies = [
  "which",
 ]
 
-[[package]]
-name = "zerocopy"
-version = "0.8.56"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "556764e583adb45a9f8d413c2a147fa7e8d821e48e12b14fd560b607998b75eb"
-dependencies = [
- "zerocopy-derive",
-]
-
-[[package]]
-name = "zerocopy-derive"
-version = "0.8.56"
-source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "f2ab42fc20575779bd240faa45f94a74256f755c0fa9e89f0ede20d91d0cdfc1"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.119",
-]
-
 [[package]]
 name = "zeroize"
 version = "1.9.0"
diff --git a/Cargo.toml b/Cargo.toml
index 42c554d..46616b6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,8 +37,8 @@ divan = { version = "0.1.21" }
 googletest = { version = "0.14.3" }
 insta = { version = "1.48.0" }
 cargo_metadata = { version = "0.23.1" }
-proptest = { version = "1" }
-rand = { version = "0.9.2" }
+quickcheck = { version = "1.1.0", default-features = false }
+rand = { version = "0.10.0" }
 which = { version = "8.0.5" }
 flate2 = { version = "1.1.9", default-features = false, features = ["zlib-rs"] 
}
 tar = { version = "0.4.46", default-features = false }
diff --git a/datasketches/Cargo.toml b/datasketches/Cargo.toml
index 6f7f4d7..b34d8e8 100644
--- a/datasketches/Cargo.toml
+++ b/datasketches/Cargo.toml
@@ -106,7 +106,7 @@ rand = { workspace = true, optional = true }
 divan = { workspace = true }
 googletest = { workspace = true }
 insta = { workspace = true }
-proptest = { workspace = true }
+quickcheck = { workspace = true }
 
 [lints]
 workspace = true
diff --git a/datasketches/tests/req_test/accuracy.rs 
b/datasketches/tests/req_test/accuracy.rs
index 71112ae..d8dc10b 100644
--- a/datasketches/tests/req_test/accuracy.rs
+++ b/datasketches/tests/req_test/accuracy.rs
@@ -15,8 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#![cfg(feature = "req")]
-
 //! End-to-end accuracy checks for ReqSketch.
 
 use datasketches::error::Error;
diff --git a/datasketches/tests/req_test/bounds.rs 
b/datasketches/tests/req_test/bounds.rs
index ad01d95..6f18aa4 100644
--- a/datasketches/tests/req_test/bounds.rs
+++ b/datasketches/tests/req_test/bounds.rs
@@ -15,8 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#![cfg(feature = "req")]
-
 //! Rank error bounds and sigma coverage for ReqSketch.
 
 use datasketches::error::Error;
diff --git a/datasketches/tests/req_test/core.rs 
b/datasketches/tests/req_test/core.rs
index a8b5ed2..c46b44f 100644
--- a/datasketches/tests/req_test/core.rs
+++ b/datasketches/tests/req_test/core.rs
@@ -15,8 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#![cfg(feature = "req")]
-
 //! Core ReqSketch construction and update behavior.
 
 use datasketches::error::Error;
diff --git a/datasketches/tests/req_test/merge.rs 
b/datasketches/tests/req_test/merge.rs
index 1d7d559..1ab1c9e 100644
--- a/datasketches/tests/req_test/merge.rs
+++ b/datasketches/tests/req_test/merge.rs
@@ -15,8 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#![cfg(feature = "req")]
-
 //! Merge behavior for ReqSketch.
 
 use datasketches::req::RankAccuracy;
diff --git a/datasketches/tests/req_test/property.rs 
b/datasketches/tests/req_test/property.rs
index 43b654d..cbaf130 100644
--- a/datasketches/tests/req_test/property.rs
+++ b/datasketches/tests/req_test/property.rs
@@ -15,19 +15,21 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#![cfg(feature = "req")]
-
 //! Property-based ReqSketch tests.
 
 use datasketches::req::ReqSketch;
 use datasketches::req::SearchCriteria;
-use proptest::prelude::*;
+use quickcheck::Gen;
+use quickcheck::QuickCheck;
+use quickcheck::TestResult;
+
+#[test]
+fn prop_quantile_rank_consistency() {
+    fn property(values: Vec<u64>) -> TestResult {
+        if !(500..1500).contains(&values.len()) {
+            return TestResult::discard();
+        }
 
-proptest! {
-    #[test]
-    fn prop_quantile_rank_consistency(
-        values in prop::collection::vec(0.0f64..1000.0, 500..1500),
-    ) {
         let mut sketch = ReqSketch::new();
         for value in values {
             sketch.update(value);
@@ -35,7 +37,9 @@ proptest! {
 
         // These sizes push the sketch past the compaction threshold, so the
         // round-trip exercises the estimation path rather than exact storage.
-        prop_assume!(sketch.is_estimation_mode());
+        if !sketch.is_estimation_mode() {
+            return TestResult::discard();
+        }
 
         for rank in [0.1, 0.25, 0.5, 0.75, 0.9] {
             let quantile = sketch
@@ -51,35 +55,45 @@ proptest! {
             // actually constrains the result instead of always passing.
             let lower = sketch.rank_lower_bound(rank, 3) - 0.02;
             let upper = sketch.rank_upper_bound(rank, 3) + 0.02;
-            prop_assert!(
+            assert!(
                 (lower..=upper).contains(&recovered),
                 "rank {rank} -> quantile {quantile} -> recovered {recovered}, 
expected within [{lower:.4}, {upper:.4}]"
             );
         }
+
+        TestResult::passed()
     }
 
-    #[test]
-    fn prop_sketch_bounds(values in prop::collection::vec(-1000.0f64..1000.0, 
1..1000)) {
+    QuickCheck::new()
+        .tests(256)
+        .min_tests_passed(256)
+        .rng(Gen::new(1500))
+        .quickcheck(property as fn(Vec<u64>) -> TestResult);
+}
+
+#[test]
+fn prop_sketch_bounds() {
+    fn property(values: Vec<i64>) -> TestResult {
+        if !(1..1000).contains(&values.len()) {
+            return TestResult::discard();
+        }
+
         let mut sketch = ReqSketch::new();
         for value in &values {
             sketch.update(*value);
         }
 
-        if sketch.is_empty() {
-            return Ok(());
-        }
-
-        let true_min = values.iter().fold(f64::INFINITY, |a, &b| a.min(b));
-        let true_max = values.iter().fold(f64::NEG_INFINITY, |a, &b| a.max(b));
+        let true_min = values.iter().copied().min().expect("values are 
non-empty");
+        let true_max = values.iter().copied().max().expect("values are 
non-empty");
 
-        prop_assert_eq!(sketch.min_item(), Some(&true_min));
-        prop_assert_eq!(sketch.max_item(), Some(&true_max));
+        assert_eq!(sketch.min_item(), Some(&true_min));
+        assert_eq!(sketch.max_item(), Some(&true_max));
 
         for rank in [0.0, 0.25, 0.5, 0.75, 1.0] {
             let quantile = sketch
                 .quantile(rank, SearchCriteria::Inclusive)
                 .expect("quantile should succeed");
-            prop_assert!(
+            assert!(
                 quantile >= true_min && quantile <= true_max,
                 "quantile {} out of bounds [{}, {}]",
                 quantile,
@@ -87,27 +101,52 @@ proptest! {
                 true_max
             );
         }
+
+        TestResult::passed()
     }
 
-    #[test]
-    fn prop_rank_monotonicity(values in prop::collection::vec(0.0f64..1000.0, 
10..100)) {
+    QuickCheck::new()
+        .tests(256)
+        .min_tests_passed(256)
+        .rng(Gen::new(1000))
+        .quickcheck(property as fn(Vec<i64>) -> TestResult);
+}
+
+#[test]
+fn prop_rank_monotonicity() {
+    fn property(values: Vec<u32>) -> TestResult {
+        if !(10..100).contains(&values.len()) {
+            return TestResult::discard();
+        }
+
         let mut sketch = ReqSketch::new();
         for value in values {
             sketch.update(value);
         }
 
-        if sketch.is_empty() {
-            return Ok(());
-        }
-
         let mut last_rank = -1.0;
-        for value in [0.0, 100.0, 200.0, 500.0, 800.0, 1000.0] {
+        for value in [
+            0,
+            u32::MAX / 10,
+            u32::MAX / 5,
+            u32::MAX / 2,
+            (u32::MAX / 5) * 4,
+            u32::MAX,
+        ] {
             let rank = sketch
                 .rank(&value, SearchCriteria::Inclusive)
                 .expect("rank should succeed");
-            prop_assert!(rank >= last_rank, "rank {} after {}", rank, 
last_rank);
-            prop_assert!((0.0..=1.0).contains(&rank), "rank {} out of bounds", 
rank);
+            assert!(rank >= last_rank, "rank {} after {}", rank, last_rank);
+            assert!((0.0..=1.0).contains(&rank), "rank {} out of bounds", 
rank);
             last_rank = rank;
         }
+
+        TestResult::passed()
     }
+
+    QuickCheck::new()
+        .tests(256)
+        .min_tests_passed(256)
+        .rng(Gen::new(100))
+        .quickcheck(property as fn(Vec<u32>) -> TestResult);
 }
diff --git a/datasketches/tests/req_test/query.rs 
b/datasketches/tests/req_test/query.rs
index afa9a4c..38e9513 100644
--- a/datasketches/tests/req_test/query.rs
+++ b/datasketches/tests/req_test/query.rs
@@ -15,8 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#![cfg(feature = "req")]
-
 //! Rank, quantile, PMF, and CDF behavior for ReqSketch.
 
 use datasketches::error::Error;
diff --git a/datasketches/tests/req_test/sorted_view_api.rs 
b/datasketches/tests/req_test/sorted_view_api.rs
index fa0338c..f6eff2b 100644
--- a/datasketches/tests/req_test/sorted_view_api.rs
+++ b/datasketches/tests/req_test/sorted_view_api.rs
@@ -15,8 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#![cfg(feature = "req")]
-
 //! Tests for the user-managed SortedView API (ported from reqsketch-rs #25):
 //! distribution queries take `&self`, and `sorted_view()` returns an owned
 //! snapshot instead of relying on an internal cache.
diff --git a/datasketches/tests/req_test/structure.rs 
b/datasketches/tests/req_test/structure.rs
index c8f46a2..c5bd42d 100644
--- a/datasketches/tests/req_test/structure.rs
+++ b/datasketches/tests/req_test/structure.rs
@@ -15,8 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#![cfg(feature = "req")]
-
 //! Public iterator behavior for ReqSketch.
 
 use datasketches::req::ReqSketch;
diff --git a/datasketches/tests/req_test/union.rs 
b/datasketches/tests/req_test/union.rs
index cb04e15..79e337e 100644
--- a/datasketches/tests/req_test/union.rs
+++ b/datasketches/tests/req_test/union.rs
@@ -15,8 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#![cfg(feature = "req")]
-
 //! Integration tests for ReqUnion.
 
 use datasketches::req::RankAccuracy;


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

Reply via email to