Skip to content

Commit

Permalink
Add tests for overflow converting slices to views
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner314 committed Dec 7, 2021
1 parent 6c8b821 commit 1a7c020
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/array-construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,29 @@ fn deny_wraparound_uninit() {
let _five_large = Array::<f32, _>::uninit((3, 7, 29, 36760123, 823996703));
}

#[should_panic]
#[test]
fn deny_slice_with_too_many_rows_to_arrayview2() {
let _view = ArrayView2::from(&[[0u8; 0]; usize::MAX][..]);
}

#[should_panic]
#[test]
fn deny_slice_with_too_many_zero_sized_elems_to_arrayview2() {
let _view = ArrayView2::from(&[[(); isize::MAX as usize]; isize::MAX as usize][..]);
}

#[should_panic]
#[test]
fn deny_slice_with_too_many_rows_to_arrayviewmut2() {
let _view = ArrayViewMut2::from(&mut [[0u8; 0]; usize::MAX][..]);
}

#[should_panic]
#[test]
fn deny_slice_with_too_many_zero_sized_elems_to_arrayviewmut2() {
let _view = ArrayViewMut2::from(&mut [[(); isize::MAX as usize]; isize::MAX as usize][..]);
}

#[test]
fn maybe_uninit_1() {
Expand Down

0 comments on commit 1a7c020

Please # to comment.