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