@@ -544,7 +544,7 @@ impl PartialEq<Uint128> for &Uint128 {
544544mod tests {
545545 use crate :: errors:: CheckedMultiplyFractionalError :: { ConversionOverflow , DivideByZero } ;
546546 use crate :: math:: fraction:: { Fraction , FractionMath } ;
547- use crate :: { from_slice, to_vec, Decimal } ;
547+ use crate :: { from_slice, to_vec, Decimal , Decimal256 } ;
548548
549549 use super :: * ;
550550
@@ -1069,13 +1069,27 @@ mod tests {
10691069 assert_eq ! ( Uint128 :: new( 47030 ) , res)
10701070 }
10711071
1072+ #[ test]
1073+ fn mul_floored_works_with_higher_bit_sizes ( ) {
1074+ let fraction = Fraction :: new ( Uint256 :: from ( 8u128 ) , Uint256 :: from ( 21u128 ) ) ;
1075+ let res = Uint128 :: new ( 123456 ) . mul_floored ( fraction) ; // 47030.8571
1076+ assert_eq ! ( Uint128 :: new( 47030 ) , res)
1077+ }
1078+
10721079 #[ test]
10731080 fn mul_floored_works_with_decimal ( ) {
10741081 let decimal = Decimal :: from_ratio ( 8u128 , 21u128 ) ;
10751082 let res = Uint128 :: new ( 123456 ) . mul_floored ( decimal) ; // 47030.8571
10761083 assert_eq ! ( Uint128 :: new( 47030 ) , res)
10771084 }
10781085
1086+ #[ test]
1087+ fn mul_floored_works_with_decimal256 ( ) {
1088+ let decimal = Decimal256 :: from_ratio ( 8u128 , 21u128 ) ;
1089+ let res = Uint128 :: new ( 123456 ) . mul_floored ( decimal) ; // 47030.8571
1090+ assert_eq ! ( Uint128 :: new( 47030 ) , res)
1091+ }
1092+
10791093 #[ test]
10801094 #[ should_panic( expected = "ConversionOverflowError" ) ]
10811095 fn mul_floored_panics_on_overflow ( ) {
@@ -1135,13 +1149,27 @@ mod tests {
11351149 assert_eq ! ( Uint128 :: new( 47031 ) , res)
11361150 }
11371151
1152+ #[ test]
1153+ fn mul_ceil_works_with_higher_bit_sizes ( ) {
1154+ let fraction = Fraction :: new ( Uint256 :: from ( 8u128 ) , Uint256 :: from ( 21u128 ) ) ;
1155+ let res = Uint128 :: new ( 123456 ) . mul_ceil ( fraction) ; // 47030.8571
1156+ assert_eq ! ( Uint128 :: new( 47031 ) , res)
1157+ }
1158+
11381159 #[ test]
11391160 fn mul_ceil_works_with_decimal ( ) {
11401161 let decimal = Decimal :: from_ratio ( 8u128 , 21u128 ) ;
11411162 let res = Uint128 :: new ( 123456 ) . mul_ceil ( decimal) ; // 47030.8571
11421163 assert_eq ! ( Uint128 :: new( 47031 ) , res)
11431164 }
11441165
1166+ #[ test]
1167+ fn mul_ceil_works_with_decimal256 ( ) {
1168+ let decimal = Decimal256 :: from_ratio ( 8u128 , 21u128 ) ;
1169+ let res = Uint128 :: new ( 123456 ) . mul_ceil ( decimal) ; // 47030.8571
1170+ assert_eq ! ( Uint128 :: new( 47031 ) , res)
1171+ }
1172+
11451173 #[ test]
11461174 #[ should_panic( expected = "ConversionOverflowError" ) ]
11471175 fn mul_ceil_panics_on_overflow ( ) {
0 commit comments