Skip to content

Commit 6ca600b

Browse files
committed
Test compatibility with old workaround
1 parent a31e81f commit 6ca600b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/std/src/math/decimal.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,19 @@ mod tests {
20722072

20732073
let d = Decimal::MAX;
20742074
assert_eq!(d.to_uint_floor(), Uint128::new(340282366920938463463));
2075+
2076+
// Does the same as the old workaround `Uint128::one() * my_decimal`.
2077+
// This block can be deleted as part of https://github.com/CosmWasm/cosmwasm/issues/1485.
2078+
let tests = vec![
2079+
Decimal::from_str("12.345").unwrap(),
2080+
Decimal::from_str("0.98451384").unwrap(),
2081+
Decimal::from_str("178.0").unwrap(),
2082+
Decimal::MIN,
2083+
Decimal::MAX,
2084+
];
2085+
for my_decimal in tests.into_iter() {
2086+
assert_eq!(my_decimal.to_uint_floor(), Uint128::one() * my_decimal);
2087+
}
20752088
}
20762089

20772090
#[test]

packages/std/src/math/decimal256.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,6 +2223,19 @@ mod tests {
22232223
Uint256::from_str("115792089237316195423570985008687907853269984665640564039457")
22242224
.unwrap()
22252225
);
2226+
2227+
// Does the same as the old workaround `Uint256::one() * my_decimal`.
2228+
// This block can be deleted as part of https://github.com/CosmWasm/cosmwasm/issues/1485.
2229+
let tests = vec![
2230+
Decimal256::from_str("12.345").unwrap(),
2231+
Decimal256::from_str("0.98451384").unwrap(),
2232+
Decimal256::from_str("178.0").unwrap(),
2233+
Decimal256::MIN,
2234+
Decimal256::MAX,
2235+
];
2236+
for my_decimal in tests.into_iter() {
2237+
assert_eq!(my_decimal.to_uint_floor(), Uint256::one() * my_decimal);
2238+
}
22262239
}
22272240

22282241
#[test]

0 commit comments

Comments
 (0)