Skip to content

Commit

Permalink
Test types MIN/MAX instead of i64::MIN/i64::MAX
Browse files Browse the repository at this point in the history
The MIN/MAX for SignedAmount recently changed from i64::MIN and
i64::MAX to MAX_MONEY/MIN_MONEY.  Update the tests to reflect this new
MIN/MAX since it is no longer valid to create a value above or bellow
MAX_MONEY/MIN_MONEY.
  • Loading branch information
yancyribbens authored and daystar committed Dec 13, 2024
1 parent 7cd6778 commit 4d7b566
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions units/src/amount/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,12 @@ fn to_from_string_in() {
assert_eq!(sa_str(&sa_sat(-1).to_string_in(D::MicroBitcoin), D::MicroBitcoin), Ok(sa_sat(-1)));

assert_eq!(
sa_str(&sa_sat(i64::MAX).to_string_in(D::Satoshi), D::MicroBitcoin),
sa_str(&SignedAmount::MAX.to_string_in(D::Satoshi), D::MicroBitcoin),
Err(OutOfRangeError::too_big(true).into())
);
// Test an overflow bug in `abs()`
assert_eq!(
sa_str(&sa_sat(i64::MIN).to_string_in(D::Satoshi), D::MicroBitcoin),
sa_str(&SignedAmount::MIN.to_string_in(D::Satoshi), D::MicroBitcoin),
Err(OutOfRangeError::too_small().into())
);
}
Expand Down Expand Up @@ -903,12 +903,12 @@ fn checked_sum_amounts() {
assert_eq!(None, sum);

let amounts =
[SignedAmount::from_sat(i64::MIN), SignedAmount::from_sat(-1), SignedAmount::from_sat(21)];
[SignedAmount::MIN, SignedAmount::from_sat(-1), SignedAmount::from_sat(21)];
let sum = amounts.into_iter().checked_sum();
assert_eq!(None, sum);

let amounts =
[SignedAmount::from_sat(i64::MAX), SignedAmount::from_sat(1), SignedAmount::from_sat(21)];
[SignedAmount::MAX, SignedAmount::from_sat(1), SignedAmount::from_sat(21)];
let sum = amounts.into_iter().checked_sum();
assert_eq!(None, sum);

Expand Down

0 comments on commit 4d7b566

Please sign in to comment.