diff --git a/units/src/amount.rs b/units/src/amount.rs index 78b5c46f..65ca15c3 100644 --- a/units/src/amount.rs +++ b/units/src/amount.rs @@ -1710,6 +1710,8 @@ mod tests { assert_eq!(f(42.123456781, D::Bitcoin), Err(ParseAmountError::TooPrecise)); assert_eq!(sf(-184467440738.0, D::Bitcoin), Err(ParseAmountError::TooBig)); assert_eq!(f(18446744073709551617.0, D::Satoshi), Err(ParseAmountError::TooBig)); + + // Amount can be grater than the max SignedAmount. assert!(f(SignedAmount::MAX.to_float_in(D::Satoshi) + 1.0, D::Satoshi).is_ok()); assert_eq!( @@ -1717,6 +1719,11 @@ mod tests { Err(ParseAmountError::TooBig) ); + assert_eq!( + sf(SignedAmount::MAX.to_float_in(D::Satoshi) + 1.0, D::Satoshi), + Err(ParseAmountError::TooBig) + ); + let btc = move |f| SignedAmount::from_btc(f).unwrap(); assert_eq!(btc(2.5).to_float_in(D::Bitcoin), 2.5); assert_eq!(btc(-2.5).to_float_in(D::MilliBitcoin), -2500.0);