File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -2072,6 +2072,19 @@ mod tests {
2072
2072
2073
2073
let d = Decimal :: MAX ;
2074
2074
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
+ }
2075
2088
}
2076
2089
2077
2090
#[ test]
Original file line number Diff line number Diff line change @@ -2223,6 +2223,19 @@ mod tests {
2223
2223
Uint256 :: from_str( "115792089237316195423570985008687907853269984665640564039457" )
2224
2224
. unwrap( )
2225
2225
) ;
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
+ }
2226
2239
}
2227
2240
2228
2241
#[ test]
You can’t perform that action at this time.
0 commit comments