Skip to content

Commit e838a12

Browse files
committed
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.
1 parent 0105e4d commit e838a12

6 files changed

+135
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
#[repr(C)]
4+
#[derive(Debug, Copy, PartialEq)]
5+
pub struct NoPartialEq {
6+
pub _bindgen_opaque_blob: u32,
7+
}
8+
#[test]
9+
fn bindgen_test_layout_NoPartialEq() {
10+
assert_eq!(
11+
::std::mem::size_of::<NoPartialEq>(),
12+
4usize,
13+
concat!("Size of: ", stringify!(NoPartialEq))
14+
);
15+
assert_eq!(
16+
::std::mem::align_of::<NoPartialEq>(),
17+
4usize,
18+
concat!("Alignment of ", stringify!(NoPartialEq))
19+
);
20+
}
21+
impl Clone for NoPartialEq {
22+
fn clone(&self) -> Self {
23+
*self
24+
}
25+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
#[repr(C)]
4+
#[derive(Debug, Copy, PartialEq)]
5+
pub struct NoPartialEq {
6+
pub i: ::std::os::raw::c_int,
7+
}
8+
#[test]
9+
fn bindgen_test_layout_NoPartialEq() {
10+
assert_eq!(
11+
::std::mem::size_of::<NoPartialEq>(),
12+
4usize,
13+
concat!("Size of: ", stringify!(NoPartialEq))
14+
);
15+
assert_eq!(
16+
::std::mem::align_of::<NoPartialEq>(),
17+
4usize,
18+
concat!("Alignment of ", stringify!(NoPartialEq))
19+
);
20+
assert_eq!(
21+
unsafe { &(*(0 as *const NoPartialEq)).i as *const _ as usize },
22+
0usize,
23+
concat!(
24+
"Alignment of field: ",
25+
stringify!(NoPartialEq),
26+
"::",
27+
stringify!(i)
28+
)
29+
);
30+
}
31+
impl Clone for NoPartialEq {
32+
fn clone(&self) -> Self {
33+
*self
34+
}
35+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
#[repr(C)]
4+
#[derive(Debug, Copy)]
5+
pub struct NoPartialEq {
6+
pub _address: u8,
7+
}
8+
#[test]
9+
fn bindgen_test_layout_NoPartialEq() {
10+
assert_eq!(
11+
::std::mem::size_of::<NoPartialEq>(),
12+
1usize,
13+
concat!("Size of: ", stringify!(NoPartialEq))
14+
);
15+
assert_eq!(
16+
::std::mem::align_of::<NoPartialEq>(),
17+
1usize,
18+
concat!("Alignment of ", stringify!(NoPartialEq))
19+
);
20+
}
21+
impl Clone for NoPartialEq {
22+
fn clone(&self) -> Self {
23+
*self
24+
}
25+
}
26+
#[repr(C)]
27+
#[derive(Debug, Copy)]
28+
pub struct WhitelistMe {
29+
pub a: NoPartialEq,
30+
}
31+
#[test]
32+
fn bindgen_test_layout_WhitelistMe() {
33+
assert_eq!(
34+
::std::mem::size_of::<WhitelistMe>(),
35+
1usize,
36+
concat!("Size of: ", stringify!(WhitelistMe))
37+
);
38+
assert_eq!(
39+
::std::mem::align_of::<WhitelistMe>(),
40+
1usize,
41+
concat!("Alignment of ", stringify!(WhitelistMe))
42+
);
43+
assert_eq!(
44+
unsafe { &(*(0 as *const WhitelistMe)).a as *const _ as usize },
45+
0usize,
46+
concat!(
47+
"Alignment of field: ",
48+
stringify!(WhitelistMe),
49+
"::",
50+
stringify!(a)
51+
)
52+
);
53+
}
54+
impl Clone for WhitelistMe {
55+
fn clone(&self) -> Self {
56+
*self
57+
}
58+
}

tests/headers/no-partialeq-opaque.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// bindgen-flags --with-derive-partialeq --opaque-type "NoPartialEq" --no-partialeq "NoPartialEq"
2+
3+
class NoPartialEq {
4+
int i;
5+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// bindgen-flags: --with-derive-partialeq --whitelist-type "NoPartialEq" --no-partialeq "NoPartialEq"
2+
3+
class NoPartialEq {
4+
int i;
5+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// bindgen-flags: --with-derive-partialeq --whitelist-type "WhitelistMe" --no-partialeq "NoPartialEq"
2+
3+
struct NoPartialEq {};
4+
5+
class WhitelistMe {
6+
NoPartialEq a;
7+
};

0 commit comments

Comments
 (0)