From e838a127fc480f302257fbb174bed8ef96d57a8a Mon Sep 17 00:00:00 2001 From: Alexey Zabelin Date: Tue, 19 Sep 2017 11:58:35 -0400 Subject: [PATCH] Add tests When the no-partialeq type is transitively referenced by a whitelisted item. When the no-partialeq type is explicitly whitelisted. When the no-partialeq type is marked opaque. --- .../expectations/tests/no-partialeq-opaque.rs | 25 ++++++++ .../tests/no-partialeq-whitelisted.rs | 35 +++++++++++ ...hitelisted-item-references-no-partialeq.rs | 58 +++++++++++++++++++ tests/headers/no-partialeq-opaque.hpp | 5 ++ tests/headers/no-partialeq-whitelisted.hpp | 5 ++ ...itelisted-item-references-no-partialeq.hpp | 7 +++ 6 files changed, 135 insertions(+) create mode 100644 tests/expectations/tests/no-partialeq-opaque.rs create mode 100644 tests/expectations/tests/no-partialeq-whitelisted.rs create mode 100644 tests/expectations/tests/whitelisted-item-references-no-partialeq.rs create mode 100644 tests/headers/no-partialeq-opaque.hpp create mode 100644 tests/headers/no-partialeq-whitelisted.hpp create mode 100644 tests/headers/whitelisted-item-references-no-partialeq.hpp diff --git a/tests/expectations/tests/no-partialeq-opaque.rs b/tests/expectations/tests/no-partialeq-opaque.rs new file mode 100644 index 0000000000..dd496b1cc2 --- /dev/null +++ b/tests/expectations/tests/no-partialeq-opaque.rs @@ -0,0 +1,25 @@ +/* automatically generated by rust-bindgen */ + +#[repr(C)] +#[derive(Debug, Copy, PartialEq)] +pub struct NoPartialEq { + pub _bindgen_opaque_blob: u32, +} +#[test] +fn bindgen_test_layout_NoPartialEq() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(NoPartialEq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(NoPartialEq)) + ); +} +impl Clone for NoPartialEq { + fn clone(&self) -> Self { + *self + } +} diff --git a/tests/expectations/tests/no-partialeq-whitelisted.rs b/tests/expectations/tests/no-partialeq-whitelisted.rs new file mode 100644 index 0000000000..99ee2ff027 --- /dev/null +++ b/tests/expectations/tests/no-partialeq-whitelisted.rs @@ -0,0 +1,35 @@ +/* automatically generated by rust-bindgen */ + +#[repr(C)] +#[derive(Debug, Copy, PartialEq)] +pub struct NoPartialEq { + pub i: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_NoPartialEq() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(NoPartialEq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(NoPartialEq)) + ); + assert_eq!( + unsafe { &(*(0 as *const NoPartialEq)).i as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(NoPartialEq), + "::", + stringify!(i) + ) + ); +} +impl Clone for NoPartialEq { + fn clone(&self) -> Self { + *self + } +} diff --git a/tests/expectations/tests/whitelisted-item-references-no-partialeq.rs b/tests/expectations/tests/whitelisted-item-references-no-partialeq.rs new file mode 100644 index 0000000000..b6cb555701 --- /dev/null +++ b/tests/expectations/tests/whitelisted-item-references-no-partialeq.rs @@ -0,0 +1,58 @@ +/* automatically generated by rust-bindgen */ + +#[repr(C)] +#[derive(Debug, Copy)] +pub struct NoPartialEq { + pub _address: u8, +} +#[test] +fn bindgen_test_layout_NoPartialEq() { + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(NoPartialEq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(NoPartialEq)) + ); +} +impl Clone for NoPartialEq { + fn clone(&self) -> Self { + *self + } +} +#[repr(C)] +#[derive(Debug, Copy)] +pub struct WhitelistMe { + pub a: NoPartialEq, +} +#[test] +fn bindgen_test_layout_WhitelistMe() { + assert_eq!( + ::std::mem::size_of::(), + 1usize, + concat!("Size of: ", stringify!(WhitelistMe)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(WhitelistMe)) + ); + assert_eq!( + unsafe { &(*(0 as *const WhitelistMe)).a as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(WhitelistMe), + "::", + stringify!(a) + ) + ); +} +impl Clone for WhitelistMe { + fn clone(&self) -> Self { + *self + } +} diff --git a/tests/headers/no-partialeq-opaque.hpp b/tests/headers/no-partialeq-opaque.hpp new file mode 100644 index 0000000000..2b4e128370 --- /dev/null +++ b/tests/headers/no-partialeq-opaque.hpp @@ -0,0 +1,5 @@ +// bindgen-flags --with-derive-partialeq --opaque-type "NoPartialEq" --no-partialeq "NoPartialEq" + +class NoPartialEq { + int i; +}; diff --git a/tests/headers/no-partialeq-whitelisted.hpp b/tests/headers/no-partialeq-whitelisted.hpp new file mode 100644 index 0000000000..dba4e91f76 --- /dev/null +++ b/tests/headers/no-partialeq-whitelisted.hpp @@ -0,0 +1,5 @@ +// bindgen-flags: --with-derive-partialeq --whitelist-type "NoPartialEq" --no-partialeq "NoPartialEq" + +class NoPartialEq { + int i; +}; diff --git a/tests/headers/whitelisted-item-references-no-partialeq.hpp b/tests/headers/whitelisted-item-references-no-partialeq.hpp new file mode 100644 index 0000000000..d9d3d4311f --- /dev/null +++ b/tests/headers/whitelisted-item-references-no-partialeq.hpp @@ -0,0 +1,7 @@ +// bindgen-flags: --with-derive-partialeq --whitelist-type "WhitelistMe" --no-partialeq "NoPartialEq" + +struct NoPartialEq {}; + +class WhitelistMe { + NoPartialEq a; +};