Debian Codegraph @

src/proptest.rs

raw symbols SCIP
1 use crate::Decimal;
2
3 use core::ops::RangeInclusive;
4 use proptest::arbitrary::{Arbitrary, StrategyFor};
5 use proptest::prelude::*;
6 use proptest::strategy::Map;
7
8 impl Arbitrary for Decimal {
9 type Parameters = ();
10 fn arbitrary_with(_parameters: Self::Parameters) -> Self::Strategy {
11 // generate 3 arbitrary u32, a bool and an u32 between 0 to 28
12 (any::<(u32, u32, u32, bool)>(), 0..=28)
13 .prop_map(|((lo, mid, hi, negative), scale)| Decimal::from_parts(lo, mid, hi, negative, scale as u32))
14 }
15
16 type Strategy =
17 Map<(StrategyFor<(u32, u32, u32, bool)>, RangeInclusive<u8>), fn(((u32, u32, u32, bool), u8)) -> Self>;
18 }