@@ -48,12 +48,15 @@ prop_compose! {
4848prop_compose ! {
4949 /// Generate a pair of random `BoxedUint`s with the same precision.
5050 fn uint_pair( ) ( mut a in uint( ) , mut b in uint( ) ) -> ( BoxedUint , BoxedUint ) {
51- if a. bits_precision( ) > b. bits_precision( ) {
52- b = b. widen( a. bits_precision( ) ) ;
53- } else if a. bits_precision( ) < b. bits_precision( ) {
54- a = a. widen( b. bits_precision( ) ) ;
55- }
56-
51+ match a. bits_precision( ) . cmp( & b. bits_precision( ) ) {
52+ Ordering :: Greater => {
53+ b = b. widen( a. bits_precision( ) ) ;
54+ }
55+ Ordering :: Less => {
56+ a = a. widen( b. bits_precision( ) ) ;
57+ } ,
58+ _ => ( )
59+ } ;
5760 ( a, b)
5861 }
5962}
@@ -77,8 +80,8 @@ proptest! {
7780 #[ test]
7881 fn bits( a in uint( ) ) {
7982 let expected = to_biguint( & a) . bits( ) as u32 ;
80- assert_eq !( expected, a. bits( ) ) ;
81- assert_eq !( expected, a. bits_vartime( ) ) ;
83+ prop_assert_eq !( expected, a. bits( ) ) ;
84+ prop_assert_eq !( expected, a. bits_vartime( ) ) ;
8285 }
8386
8487 #[ test]
@@ -149,7 +152,7 @@ proptest! {
149152
150153 let expected = to_uint( f_bi. gcd( & g_bi) ) ;
151154 let actual = f. gcd( & g) ;
152- assert_eq !( expected, actual) ;
155+ prop_assert_eq !( expected, actual) ;
153156 }
154157
155158 #[ test]
@@ -166,7 +169,7 @@ proptest! {
166169 let actual = Option :: <BoxedUint >:: from( a. inv_odd_mod( & b) ) ;
167170
168171 match ( expected, actual) {
169- ( Some ( exp) , Some ( act) ) => prop_assert_eq!( exp, to_biguint( & act) . into ( ) ) ,
172+ ( Some ( exp) , Some ( act) ) => prop_assert_eq!( exp, to_biguint( & act) ) ,
170173 ( None , None ) => ( ) ,
171174 ( _, _) => panic!( "disagreement on if modular inverse exists" )
172175 }
@@ -183,7 +186,7 @@ proptest! {
183186
184187 let expected = to_uint( ( a_bi * b_bi) % n_bi) ;
185188 let actual = a. mul_mod( & b, & n) ;
186- assert_eq !( expected, actual) ;
189+ prop_assert_eq !( expected, actual) ;
187190 }
188191
189192 #[ test]
@@ -233,10 +236,10 @@ proptest! {
233236 let expected = to_uint( ( a_bi << shift as usize ) & ( ( BigUint :: one( ) << a. bits_precision( ) as usize ) - BigUint :: one( ) ) ) ;
234237 let ( actual, overflow) = a. overflowing_shl( shift) ;
235238
236- assert_eq! ( expected, actual) ;
239+ prop_assert_eq! ( & expected, & actual) ;
237240 if shift >= a. bits_precision( ) {
238- assert_eq !( actual, BoxedUint :: zero( ) ) ;
239- assert !( bool :: from( overflow) ) ;
241+ prop_assert_eq !( actual, BoxedUint :: zero( ) ) ;
242+ prop_assert !( bool :: from( overflow) ) ;
240243 }
241244 }
242245
@@ -251,10 +254,10 @@ proptest! {
251254 let actual = a. shl_vartime( shift) ;
252255
253256 if shift >= a. bits_precision( ) {
254- assert !( actual. is_none( ) ) ;
257+ prop_assert !( actual. is_none( ) ) ;
255258 }
256259 else {
257- assert_eq !( expected, actual. unwrap( ) ) ;
260+ prop_assert_eq !( expected, actual. unwrap( ) ) ;
258261 }
259262 }
260263
@@ -268,10 +271,10 @@ proptest! {
268271 let expected = to_uint( a_bi >> shift as usize ) ;
269272 let ( actual, overflow) = a. overflowing_shr( shift) ;
270273
271- assert_eq! ( expected, actual) ;
274+ prop_assert_eq! ( & expected, & actual) ;
272275 if shift >= a. bits_precision( ) {
273- assert_eq !( actual, BoxedUint :: zero( ) ) ;
274- assert !( bool :: from( overflow) ) ;
276+ prop_assert_eq !( actual, BoxedUint :: zero( ) ) ;
277+ prop_assert !( bool :: from( overflow) ) ;
275278 }
276279 }
277280
@@ -287,10 +290,10 @@ proptest! {
287290 let actual = a. shr_vartime( shift) ;
288291
289292 if shift >= a. bits_precision( ) {
290- assert !( actual. is_none( ) ) ;
293+ prop_assert !( actual. is_none( ) ) ;
291294 }
292295 else {
293- assert_eq !( expected, actual. unwrap( ) ) ;
296+ prop_assert_eq !( expected, actual. unwrap( ) ) ;
294297 }
295298 }
296299}
0 commit comments