diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2017-09-05 13:29:01 -0700 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2017-09-06 13:46:58 -0700 |
commit | 2644a5d1d1b69ddf3dba9742d293db2ef54b3fb5 (patch) | |
tree | 5558d55a42a66f35fecee170685e8a704dab9d29 | |
parent | a3a4635ec96009ebd0394f0797bf231af0142249 (diff) |
Add a test for simple blacklisting + derive(Hash)
We already have a test for more complicated template instantiations and
blacklisting and their affects on deriving `Hash`, but it is good to have sanity
tests for the simple cases too.
-rw-r--r-- | tests/expectations/tests/derive-hash-and-blacklist.rs | 28 | ||||
-rw-r--r-- | tests/headers/derive-hash-and-blacklist.hpp | 10 |
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; +}; |