File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -445,7 +445,7 @@ impl Integer for BigUint {
445
445
if self . data . is_empty ( ) {
446
446
true
447
447
} else {
448
- self . data . last ( ) . is_even ( )
448
+ self . data [ 0 ] . is_even ( )
449
449
}
450
450
}
451
451
@@ -1446,6 +1446,17 @@ mod biguint_tests {
1446
1446
check ( 99 , 17 , 1683 ) ;
1447
1447
}
1448
1448
1449
+ #[ test]
1450
+ fn test_is_even ( ) {
1451
+ assert ! ( FromStr :: from_str:: <BigUint >( "1" ) . get( ) . is_odd( ) ) ;
1452
+ assert ! ( FromStr :: from_str:: <BigUint >( "2" ) . get( ) . is_even( ) ) ;
1453
+ assert ! ( FromStr :: from_str:: <BigUint >( "1000" ) . get( ) . is_even( ) ) ;
1454
+ assert ! ( FromStr :: from_str:: <BigUint >( "1000000000000000000000" ) . get( ) . is_even( ) ) ;
1455
+ assert ! ( FromStr :: from_str:: <BigUint >( "1000000000000000000001" ) . get( ) . is_odd( ) ) ;
1456
+ assert ! ( ( BigUint :: from_uint( 1 ) << 64 ) . is_even( ) ) ;
1457
+ assert ! ( ( ( BigUint :: from_uint( 1 ) << 64 ) + BigUint :: from_uint( 1 ) ) . is_odd( ) ) ;
1458
+ }
1459
+
1449
1460
fn to_str_pairs ( ) -> ~[ ( BigUint , ~[ ( uint , ~str ) ] ) ] {
1450
1461
let bits = BigDigit :: bits;
1451
1462
~[ ( Zero :: zero ( ) , ~[
You can’t perform that action at this time.
0 commit comments