Skip to content

Commit dc6ff72

Browse files
Merge pull request #22 from triblespace/codex/migrate-from-quickcheck-to-proptest
Switch property tests to proptest
2 parents 20483b2 + 83514ed commit dc6ff72

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- verify `cargo fmt` availability and install `rustfmt` via rustup if missing
2020
- note that the `pyo3` feature requires Python development libraries
2121
- documented safety requirements for `erase_lifetime`
22+
- replaced `quickcheck` property tests with `proptest`
2223

2324
## 0.19.3 - 2025-05-30
2425
- implemented `Error` for `ViewError`

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ zerocopy = { version = "0.8.26", optional = true, features = ["derive"] }
1414
pyo3 = { version = "0.25.1", optional = true }
1515

1616
[dev-dependencies]
17-
quickcheck = "1.0"
17+
proptest = "1.7"
1818

1919
[features]
2020
default = ["mmap", "zerocopy"]

src/tests.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
use quickcheck::quickcheck;
9+
use proptest::prelude::*;
1010

1111
use crate::Bytes;
1212

13-
quickcheck! {
14-
fn test_shallow_clone(v: Vec<u8>) -> bool {
13+
proptest! {
14+
#[test]
15+
fn test_shallow_clone(v in proptest::collection::vec(any::<u8>(), 0..256)) {
1516
let a: Bytes = v.into();
1617
let b: Bytes = a.clone();
17-
a == b && a.as_ptr() == b.as_ptr()
18+
prop_assert_eq!(a.as_ref(), b.as_ref());
19+
prop_assert_eq!(a.as_ptr(), b.as_ptr());
1820
}
1921

20-
fn test_shallow_slice(v: Vec<u8>) -> bool {
22+
#[test]
23+
fn test_shallow_slice(v in proptest::collection::vec(any::<u8>(), 0..256)) {
2124
let a: Bytes = v.into();
2225
let b: Bytes = a.slice(..a.len() / 2);
23-
&b[..] == &a[..b.len()] && (b.is_empty() || a.as_ptr() == b.as_ptr())
26+
prop_assert_eq!(&b[..], &a[..b.len()]);
27+
prop_assert!(b.is_empty() || a.as_ptr() == b.as_ptr());
2428
}
2529
}
2630

0 commit comments

Comments
 (0)