summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Fitzgerald <fitzgen@gmail.com>2017-09-05 13:38:23 -0700
committerNick Fitzgerald <fitzgen@gmail.com>2017-09-06 13:46:58 -0700
commit641337dd9eaa068314220373568ded01e18b0871 (patch)
treeefffbd632a2a53b1625e4350596eda529cbf9c93
parent2644a5d1d1b69ddf3dba9742d293db2ef54b3fb5 (diff)
Add a test for blacklisting and deriving PartialEq
-rw-r--r--tests/expectations/tests/derive-partialeq-and-blacklist.rs30
-rw-r--r--tests/headers/derive-partialeq-and-blacklist.hpp11
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/expectations/tests/derive-partialeq-and-blacklist.rs b/tests/expectations/tests/derive-partialeq-and-blacklist.rs
new file mode 100644
index 00000000..4aac3c8c
--- /dev/null
+++ b/tests/expectations/tests/derive-partialeq-and-blacklist.rs
@@ -0,0 +1,30 @@
+/* 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
+/// PartialEq.
+#[repr(C)]
+pub struct ShouldNotDerivePartialEq {
+ pub a: BlacklistMe,
+}
+#[test]
+fn bindgen_test_layout_ShouldNotDerivePartialEq() {
+ assert_eq!(::std::mem::size_of::<ShouldNotDerivePartialEq>() , 1usize ,
+ concat ! (
+ "Size of: " , stringify ! ( ShouldNotDerivePartialEq ) ));
+ assert_eq! (::std::mem::align_of::<ShouldNotDerivePartialEq>() , 1usize ,
+ concat ! (
+ "Alignment of " , stringify ! ( ShouldNotDerivePartialEq ) ));
+ assert_eq! (unsafe {
+ & ( * ( 0 as * const ShouldNotDerivePartialEq ) ) . a as *
+ const _ as usize } , 0usize , concat ! (
+ "Alignment of field: " , stringify ! (
+ ShouldNotDerivePartialEq ) , "::" , stringify ! ( a ) ));
+}
+impl Default for ShouldNotDerivePartialEq {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
diff --git a/tests/headers/derive-partialeq-and-blacklist.hpp b/tests/headers/derive-partialeq-and-blacklist.hpp
new file mode 100644
index 00000000..a996eee8
--- /dev/null
+++ b/tests/headers/derive-partialeq-and-blacklist.hpp
@@ -0,0 +1,11 @@
+// bindgen-flags: --with-derive-partialeq --blacklist-type BlacklistMe --raw-line 'pub struct BlacklistMe(u8);'
+
+struct BlacklistMe {};
+
+/**
+ * Because this type contains a blacklisted type, it should not derive
+ * PartialEq.
+ */
+struct ShouldNotDerivePartialEq {
+ BlacklistMe a;
+};