]> git.lizzy.rs Git - rust.git/commitdiff
Add const_unchecked_layout test to libcore/tests
authorRichard Wiedenhöft <richard@wiedenhoeft.xyz>
Tue, 30 Apr 2019 06:23:14 +0000 (08:23 +0200)
committerRichard Wiedenhöft <richard@wiedenhoeft.xyz>
Tue, 14 May 2019 07:41:50 +0000 (09:41 +0200)
src/libcore/tests/alloc.rs [new file with mode: 0644]
src/libcore/tests/lib.rs

diff --git a/src/libcore/tests/alloc.rs b/src/libcore/tests/alloc.rs
new file mode 100644 (file)
index 0000000..63537ba
--- /dev/null
@@ -0,0 +1,10 @@
+use core::alloc::Layout;
+
+#[test]
+fn const_unchecked_layout() {
+    const SIZE: usize = 0x2000;
+    const ALIGN: usize = 0x1000;
+    const LAYOUT: Layout = unsafe { Layout::from_size_align_unchecked(SIZE, ALIGN) };
+    assert_eq!(LAYOUT.size(), SIZE);
+    assert_eq!(LAYOUT.align(), ALIGN);
+}
index b8075ef2942e083d67d7af6f5778b68fcb7b648a..c617596aba80159af2ecb5f3c4967bc099897f8f 100644 (file)
 #![feature(slice_partition_dedup)]
 #![feature(copy_within)]
 #![feature(int_error_matching)]
+#![feature(const_fn)]
 #![warn(rust_2018_idioms)]
 
 extern crate test;
 
+mod alloc;
 mod any;
 mod array;
 mod ascii;