]> git.lizzy.rs Git - rust.git/blob - library/core/tests/alloc.rs
Rollup merge of #88523 - kpreid:category, r=yaahc
[rust.git] / library / core / tests / alloc.rs
1 use core::alloc::Layout;
2 use core::ptr::NonNull;
3
4 #[test]
5 fn const_unchecked_layout() {
6     const SIZE: usize = 0x2000;
7     const ALIGN: usize = 0x1000;
8     const LAYOUT: Layout = unsafe { Layout::from_size_align_unchecked(SIZE, ALIGN) };
9     const DANGLING: NonNull<u8> = LAYOUT.dangling();
10     assert_eq!(LAYOUT.size(), SIZE);
11     assert_eq!(LAYOUT.align(), ALIGN);
12     assert_eq!(Some(DANGLING), NonNull::new(ALIGN as *mut u8));
13 }