about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLuqman Aden <laden@csclub.uwaterloo.ca>2014-12-05 14:52:38 -0500
committerLuqman Aden <laden@csclub.uwaterloo.ca>2014-12-28 19:40:48 -0500
commite83272b62883f97b8717a8150d894e89d7ae18d6 (patch)
tree6bbb484c788d0689240c725592afa088b8885c99
parent466135bfef4d110213a9aeb46f8199fa89a5f267 (diff)
downloadrust-e83272b62883f97b8717a8150d894e89d7ae18d6.tar.gz
rust-e83272b62883f97b8717a8150d894e89d7ae18d6.zip
Add tests for NonZero.
-rw-r--r--src/test/run-pass/enum-null-pointer-opt.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs
index afed658a27b..f0e34f0dc4b 100644
--- a/src/test/run-pass/enum-null-pointer-opt.rs
+++ b/src/test/run-pass/enum-null-pointer-opt.rs
@@ -10,6 +10,9 @@
 
 
 use std::mem::size_of;
+use std::ptr::NonZero;
+use std::rc::Rc;
+use std::sync::Arc;
 
 trait Trait {}
 
@@ -51,4 +54,16 @@ fn main() {
     // and fixed-size arrays
     assert_eq!(size_of::<[Box<int>, ..1]>(), size_of::<Option<[Box<int>, ..1]>>());
 
+    // Should apply to NonZero
+    assert_eq!(size_of::<NonZero<uint>>(), size_of::<Option<NonZero<uint>>>());
+    assert_eq!(size_of::<NonZero<*mut i8>>(), size_of::<Option<NonZero<*mut i8>>>());
+
+    // Should apply to types that use NonZero internally
+    assert_eq!(size_of::<Vec<int>>(), size_of::<Option<Vec<int>>>());
+    assert_eq!(size_of::<Arc<int>>(), size_of::<Option<Arc<int>>>());
+    assert_eq!(size_of::<Rc<int>>(), size_of::<Option<Rc<int>>>());
+
+    // Should apply to types that have NonZero transitively
+    assert_eq!(size_of::<String>(), size_of::<Option<String>>());
+
 }