Skip to content

Commit

Permalink
Test compatibility with old workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jan 30, 2023
1 parent a31e81f commit 6ca600b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/std/src/math/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,19 @@ mod tests {

let d = Decimal::MAX;
assert_eq!(d.to_uint_floor(), Uint128::new(340282366920938463463));

// Does the same as the old workaround `Uint128::one() * my_decimal`.
// This block can be deleted as part of https://github.com/CosmWasm/cosmwasm/issues/1485.
let tests = vec![
Decimal::from_str("12.345").unwrap(),
Decimal::from_str("0.98451384").unwrap(),
Decimal::from_str("178.0").unwrap(),
Decimal::MIN,
Decimal::MAX,
];
for my_decimal in tests.into_iter() {
assert_eq!(my_decimal.to_uint_floor(), Uint128::one() * my_decimal);
}
}

#[test]
Expand Down
13 changes: 13 additions & 0 deletions packages/std/src/math/decimal256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,19 @@ mod tests {
Uint256::from_str("115792089237316195423570985008687907853269984665640564039457")
.unwrap()
);

// Does the same as the old workaround `Uint256::one() * my_decimal`.
// This block can be deleted as part of https://github.com/CosmWasm/cosmwasm/issues/1485.
let tests = vec![
Decimal256::from_str("12.345").unwrap(),
Decimal256::from_str("0.98451384").unwrap(),
Decimal256::from_str("178.0").unwrap(),
Decimal256::MIN,
Decimal256::MAX,
];
for my_decimal in tests.into_iter() {
assert_eq!(my_decimal.to_uint_floor(), Uint256::one() * my_decimal);
}
}

#[test]
Expand Down

0 comments on commit 6ca600b

Please sign in to comment.