Skip to repository content33 lines · 930 B · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T02:57:47.341Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
property_test.rs
1use core::fmt::Debug;
2
3use proptest::{prelude::*, sample::SizeRange};
4
5use crate::{Item, SumTree, Summary};
6
7impl<T> Arbitrary for SumTree<T>
8where
9 T: Debug + Arbitrary + Item + 'static,
10 T::Summary: Debug + Summary<Context<'static> = ()>,
11{
12 type Parameters = ();
13 type Strategy = BoxedStrategy<Self>;
14
15 fn arbitrary_with((): Self::Parameters) -> Self::Strategy {
16 any::<Vec<T>>()
17 .prop_map(|vec| SumTree::from_iter(vec, ()))
18 .boxed()
19 }
20}
21
22/// A strategy for producing a [`SumTree`] with a given size.
23///
24/// Equivalent to [`proptest::collection::vec`].
25pub fn sum_tree<S, T>(values: S, size: impl Into<SizeRange>) -> impl Strategy<Value = SumTree<T>>
26where
27 T: Debug + Arbitrary + Item + 'static,
28 T::Summary: Debug + Summary<Context<'static> = ()>,
29 S: Strategy<Value = T>,
30{
31 proptest::collection::vec(values, size).prop_map(|vec| SumTree::from_iter(vec, ()))
32}
33