Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexeyzab committed Sep 19, 2017
1 parent 0105e4d commit e838a12
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/expectations/tests/no-partialeq-opaque.rs
Original file line number Diff line number Diff line change
@@ -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::<NoPartialEq>(),
4usize,
concat!("Size of: ", stringify!(NoPartialEq))
);
assert_eq!(
::std::mem::align_of::<NoPartialEq>(),
4usize,
concat!("Alignment of ", stringify!(NoPartialEq))
);
}
impl Clone for NoPartialEq {
fn clone(&self) -> Self {
*self
}
}
35 changes: 35 additions & 0 deletions tests/expectations/tests/no-partialeq-whitelisted.rs
Original file line number Diff line number Diff line change
@@ -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::<NoPartialEq>(),
4usize,
concat!("Size of: ", stringify!(NoPartialEq))
);
assert_eq!(
::std::mem::align_of::<NoPartialEq>(),
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
}
}
Original file line number Diff line number Diff line change
@@ -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::<NoPartialEq>(),
1usize,
concat!("Size of: ", stringify!(NoPartialEq))
);
assert_eq!(
::std::mem::align_of::<NoPartialEq>(),
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::<WhitelistMe>(),
1usize,
concat!("Size of: ", stringify!(WhitelistMe))
);
assert_eq!(
::std::mem::align_of::<WhitelistMe>(),
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
}
}
5 changes: 5 additions & 0 deletions tests/headers/no-partialeq-opaque.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// bindgen-flags --with-derive-partialeq --opaque-type "NoPartialEq" --no-partialeq "NoPartialEq"

class NoPartialEq {
int i;
};
5 changes: 5 additions & 0 deletions tests/headers/no-partialeq-whitelisted.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// bindgen-flags: --with-derive-partialeq --whitelist-type "NoPartialEq" --no-partialeq "NoPartialEq"

class NoPartialEq {
int i;
};
7 changes: 7 additions & 0 deletions tests/headers/whitelisted-item-references-no-partialeq.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// bindgen-flags: --with-derive-partialeq --whitelist-type "WhitelistMe" --no-partialeq "NoPartialEq"

struct NoPartialEq {};

class WhitelistMe {
NoPartialEq a;
};

0 comments on commit e838a12

Please sign in to comment.