Skip to content

Commit 7b1df49

Browse files
jturner314bluss
authored andcommitted
Add tests for overflow converting slices to views
1 parent f0f4849 commit 7b1df49

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/array-construct.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,29 @@ fn deny_wraparound_uninit() {
244244
let _five_large = Array::<f32, _>::uninit((3, 7, 29, 36760123, 823996703));
245245
}
246246

247+
#[should_panic]
248+
#[test]
249+
fn deny_slice_with_too_many_rows_to_arrayview2() {
250+
let _view = ArrayView2::from(&[[0u8; 0]; usize::MAX][..]);
251+
}
252+
253+
#[should_panic]
254+
#[test]
255+
fn deny_slice_with_too_many_zero_sized_elems_to_arrayview2() {
256+
let _view = ArrayView2::from(&[[(); isize::MAX as usize]; isize::MAX as usize][..]);
257+
}
258+
259+
#[should_panic]
260+
#[test]
261+
fn deny_slice_with_too_many_rows_to_arrayviewmut2() {
262+
let _view = ArrayViewMut2::from(&mut [[0u8; 0]; usize::MAX][..]);
263+
}
264+
265+
#[should_panic]
266+
#[test]
267+
fn deny_slice_with_too_many_zero_sized_elems_to_arrayviewmut2() {
268+
let _view = ArrayViewMut2::from(&mut [[(); isize::MAX as usize]; isize::MAX as usize][..]);
269+
}
247270

248271
#[test]
249272
fn maybe_uninit_1() {

0 commit comments

Comments
 (0)