2019-04-30 06:23:14 +00:00
|
|
|
use core::alloc::Layout;
|
2020-03-07 01:40:54 +00:00
|
|
|
use core::ptr::NonNull;
|
2019-04-30 06:23:14 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn const_unchecked_layout() {
|
|
|
|
const SIZE: usize = 0x2000;
|
|
|
|
const ALIGN: usize = 0x1000;
|
|
|
|
const LAYOUT: Layout = unsafe { Layout::from_size_align_unchecked(SIZE, ALIGN) };
|
2020-03-07 01:40:54 +00:00
|
|
|
const DANGLING: NonNull<u8> = LAYOUT.dangling();
|
2019-04-30 06:23:14 +00:00
|
|
|
assert_eq!(LAYOUT.size(), SIZE);
|
|
|
|
assert_eq!(LAYOUT.align(), ALIGN);
|
2020-03-07 01:40:54 +00:00
|
|
|
assert_eq!(Some(DANGLING), NonNull::new(ALIGN as *mut u8));
|
2019-04-30 06:23:14 +00:00
|
|
|
}
|