summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/expectations/tests/derive-hash-and-blacklist.rs28
-rw-r--r--tests/headers/derive-hash-and-blacklist.hpp10
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/expectations/tests/derive-hash-and-blacklist.rs b/tests/expectations/tests/derive-hash-and-blacklist.rs
new file mode 100644
index 00000000..e5a66376
--- /dev/null
+++ b/tests/expectations/tests/derive-hash-and-blacklist.rs
@@ -0,0 +1,28 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+pub struct BlacklistMe(u8);
+
+/// Because this type contains a blacklisted type, it should not derive Hash.
+#[repr(C)]
+pub struct ShouldNotDeriveHash {
+ pub a: BlacklistMe,
+}
+#[test]
+fn bindgen_test_layout_ShouldNotDeriveHash() {
+ assert_eq!(::std::mem::size_of::<ShouldNotDeriveHash>() , 1usize , concat
+ ! ( "Size of: " , stringify ! ( ShouldNotDeriveHash ) ));
+ assert_eq! (::std::mem::align_of::<ShouldNotDeriveHash>() , 1usize ,
+ concat ! (
+ "Alignment of " , stringify ! ( ShouldNotDeriveHash ) ));
+ assert_eq! (unsafe {
+ & ( * ( 0 as * const ShouldNotDeriveHash ) ) . a as * const _
+ as usize } , 0usize , concat ! (
+ "Alignment of field: " , stringify ! ( ShouldNotDeriveHash ) ,
+ "::" , stringify ! ( a ) ));
+}
+impl Default for ShouldNotDeriveHash {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
diff --git a/tests/headers/derive-hash-and-blacklist.hpp b/tests/headers/derive-hash-and-blacklist.hpp
new file mode 100644
index 00000000..4b3a4a53
--- /dev/null
+++ b/tests/headers/derive-hash-and-blacklist.hpp
@@ -0,0 +1,10 @@
+// bindgen-flags: --with-derive-hash --blacklist-type BlacklistMe --raw-line 'pub struct BlacklistMe(u8);'
+
+struct BlacklistMe {};
+
+/**
+ * Because this type contains a blacklisted type, it should not derive Hash.
+ */
+struct ShouldNotDeriveHash {
+ BlacklistMe a;
+};