Skip to content

Commit

Permalink
FIX 1 << 56 on 32-bit platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
bluss committed Mar 29, 2021
1 parent 815738f commit 31abaa1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ fn test_encode_decode_format() {

#[test]
fn test_encode_decode() {
for &i in [0, 1, 2, 3, 10, 32, 256, 1736, 16300, (1 << 56) - 1].iter() {
for &i in [0, 1, 2, 3, 10, 32, 256, 1736, 16300].iter() {
let err = ShapeError::invalid_axis(i, 0);
assert_eq!(err.info_expected_index(), Some(i));
let err = ShapeError::invalid_axis(0, i);
Expand All @@ -525,7 +525,12 @@ fn test_encode_decode() {
assert_eq!(err.info_actual_index(), Some((1 << 24) + 1));

if size_of::<usize>() > 4 {
let err = ShapeError::invalid_axis(1 << 56, 1 << 56);
// use .wrapping_shl(_) for portability
let err = ShapeError::invalid_axis(1usize.wrapping_shl(56) - 1, 0);
assert_eq!(err.info_expected_index(), Some(1usize.wrapping_shl(56) - 1));
assert_eq!(err.info_actual_index(), Some(0));

let err = ShapeError::invalid_axis(1usize.wrapping_shl(56), 1usize.wrapping_shl(56));
assert_eq!(err.info_expected_index(), None);
assert_eq!(err.info_actual_index(), None);

Expand Down

0 comments on commit 31abaa1

Please sign in to comment.