Skip to content

Commit 0f83ad8

Browse files
committed
Use test_strategy macro instead of raw proptest macro
1 parent 4180ae2 commit 0f83ad8

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl<T> SortedIndexBuffer<T> {
194194
}
195195

196196
/// Turn into an iterator over all (index, value) pairs in the buffer in ascending order of their keys.
197-
///
197+
///
198198
/// This is an explicit method instead of implementing IntoIterator, so we can return a
199199
/// DoubleEndedIterator without having to name the iterator type.
200200
#[allow(clippy::should_implement_trait)]

src/tests.rs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use std::collections::BTreeMap;
32

43
use proptest::prelude::*;
@@ -157,33 +156,33 @@ fn op_strategy() -> impl Strategy<Value = InsertRemoveGetOp> {
157156
]
158157
}
159158

160-
proptest! {
161-
#[test]
162-
fn test_insert_remove_get(ops in prop::collection::vec(op_strategy(), 0..1000)) {
163-
let mut pb = SortedIndexBuffer::default();
164-
let mut reference = BTreeMap::new();
165-
166-
for op in ops {
167-
match op {
168-
InsertRemoveGetOp::Insert(k, v) => {
169-
pb.insert(k, v);
170-
reference.insert(k, v);
171-
}
172-
InsertRemoveGetOp::Remove(k) => {
173-
let v1 = pb.remove(k);
174-
let v2 = reference.remove(&k);
175-
assert_eq!(v1, v2);
176-
}
177-
InsertRemoveGetOp::Get(k) => {
178-
let v1 = pb.get(k);
179-
let v2 = reference.get(&k);
180-
assert_eq!(v1, v2);
181-
}
159+
#[test_strategy::proptest]
160+
fn test_insert_remove_get(
161+
#[strategy(prop::collection::vec(op_strategy(), 0..1000))] ops: Vec<InsertRemoveGetOp>,
162+
) {
163+
let mut pb = SortedIndexBuffer::default();
164+
let mut reference = BTreeMap::new();
165+
166+
for op in ops {
167+
match op {
168+
InsertRemoveGetOp::Insert(k, v) => {
169+
pb.insert(k, v);
170+
reference.insert(k, v);
171+
}
172+
InsertRemoveGetOp::Remove(k) => {
173+
let v1 = pb.remove(k);
174+
let v2 = reference.remove(&k);
175+
assert_eq!(v1, v2);
176+
}
177+
InsertRemoveGetOp::Get(k) => {
178+
let v1 = pb.get(k);
179+
let v2 = reference.get(&k);
180+
assert_eq!(v1, v2);
182181
}
183-
pb.check_invariants_expensive();
184182
}
185-
186-
// Final state should match
187-
assert_same(pb.iter(), reference.iter().map(|(k, v)| (*k, v)));
183+
pb.check_invariants_expensive();
188184
}
185+
186+
// Final state should match
187+
assert_same(pb.iter(), reference.iter().map(|(k, v)| (*k, v)));
189188
}

0 commit comments

Comments
 (0)