From 3f244db19d533d7384987623817408d8004a7f42 Mon Sep 17 00:00:00 2001 From: yancy Date: Thu, 29 Aug 2024 20:11:55 -0500 Subject: [PATCH] Add Arbitrary to SignedAmount type --- units/src/amount.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/units/src/amount.rs b/units/src/amount.rs index 724e5fd21..9e379e213 100644 --- a/units/src/amount.rs +++ b/units/src/amount.rs @@ -1594,6 +1594,14 @@ impl core::iter::Sum for SignedAmount { } } +#[cfg(feature = "arbitrary")] +impl<'a> Arbitrary<'a> for SignedAmount { + fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { + let s = i64::arbitrary(u)?; + Ok(SignedAmount(s)) + } +} + /// Calculates the sum over the iterator using checked arithmetic. pub trait CheckedSum: private::SumSeal { /// Calculates the sum over the iterator using checked arithmetic. If an over or underflow would