Skip to content

Commit 2944834

Browse files
committed
Use a platform-neutral header for test_multiple_header_calls_in_builder
1 parent c6cf648 commit 2944834

File tree

2 files changed

+90
-7
lines changed

2 files changed

+90
-7
lines changed

tests/expectations/tests/test_multiple_header_calls_in_builder.rs

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,92 @@ extern "C" {
99
::std::os::raw::c_int)
1010
-> ::std::os::raw::c_int>;
1111
}
12-
#[repr(u32)]
13-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
14-
pub enum Foo { Bar = 0, Qux = 1, }
15-
#[repr(i32)]
16-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
17-
pub enum Neg { MinusOne = -1, One = 1, }
12+
pub type Char = ::std::os::raw::c_char;
13+
pub type SChar = ::std::os::raw::c_schar;
14+
pub type UChar = ::std::os::raw::c_uchar;
15+
#[repr(C)]
16+
#[derive(Debug, Copy)]
17+
pub struct Test {
18+
pub ch: ::std::os::raw::c_char,
19+
pub u: ::std::os::raw::c_uchar,
20+
pub d: ::std::os::raw::c_schar,
21+
pub cch: ::std::os::raw::c_char,
22+
pub cu: ::std::os::raw::c_uchar,
23+
pub cd: ::std::os::raw::c_schar,
24+
pub Cch: Char,
25+
pub Cu: UChar,
26+
pub Cd: SChar,
27+
pub Ccch: Char,
28+
pub Ccu: UChar,
29+
pub Ccd: SChar,
30+
}
31+
#[test]
32+
fn bindgen_test_layout_Test() {
33+
assert_eq!(::std::mem::size_of::<Test>() , 12usize , concat ! (
34+
"Size of: " , stringify ! ( Test ) ));
35+
assert_eq! (::std::mem::align_of::<Test>() , 1usize , concat ! (
36+
"Alignment of " , stringify ! ( Test ) ));
37+
assert_eq! (unsafe {
38+
& ( * ( 0 as * const Test ) ) . ch as * const _ as usize } ,
39+
0usize , concat ! (
40+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
41+
stringify ! ( ch ) ));
42+
assert_eq! (unsafe {
43+
& ( * ( 0 as * const Test ) ) . u as * const _ as usize } ,
44+
1usize , concat ! (
45+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
46+
stringify ! ( u ) ));
47+
assert_eq! (unsafe {
48+
& ( * ( 0 as * const Test ) ) . d as * const _ as usize } ,
49+
2usize , concat ! (
50+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
51+
stringify ! ( d ) ));
52+
assert_eq! (unsafe {
53+
& ( * ( 0 as * const Test ) ) . cch as * const _ as usize } ,
54+
3usize , concat ! (
55+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
56+
stringify ! ( cch ) ));
57+
assert_eq! (unsafe {
58+
& ( * ( 0 as * const Test ) ) . cu as * const _ as usize } ,
59+
4usize , concat ! (
60+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
61+
stringify ! ( cu ) ));
62+
assert_eq! (unsafe {
63+
& ( * ( 0 as * const Test ) ) . cd as * const _ as usize } ,
64+
5usize , concat ! (
65+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
66+
stringify ! ( cd ) ));
67+
assert_eq! (unsafe {
68+
& ( * ( 0 as * const Test ) ) . Cch as * const _ as usize } ,
69+
6usize , concat ! (
70+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
71+
stringify ! ( Cch ) ));
72+
assert_eq! (unsafe {
73+
& ( * ( 0 as * const Test ) ) . Cu as * const _ as usize } ,
74+
7usize , concat ! (
75+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
76+
stringify ! ( Cu ) ));
77+
assert_eq! (unsafe {
78+
& ( * ( 0 as * const Test ) ) . Cd as * const _ as usize } ,
79+
8usize , concat ! (
80+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
81+
stringify ! ( Cd ) ));
82+
assert_eq! (unsafe {
83+
& ( * ( 0 as * const Test ) ) . Ccch as * const _ as usize } ,
84+
9usize , concat ! (
85+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
86+
stringify ! ( Ccch ) ));
87+
assert_eq! (unsafe {
88+
& ( * ( 0 as * const Test ) ) . Ccu as * const _ as usize } ,
89+
10usize , concat ! (
90+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
91+
stringify ! ( Ccu ) ));
92+
assert_eq! (unsafe {
93+
& ( * ( 0 as * const Test ) ) . Ccd as * const _ as usize } ,
94+
11usize , concat ! (
95+
"Alignment of field: " , stringify ! ( Test ) , "::" ,
96+
stringify ! ( Ccd ) ));
97+
}
98+
impl Clone for Test {
99+
fn clone(&self) -> Self { *self }
100+
}

tests/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ extern \"C\" {
219219
fn test_multiple_header_calls_in_builder() {
220220
let actual = builder()
221221
.header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/func_ptr.h"))
222-
.header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/enum.h"))
222+
.header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/char.h"))
223223
.generate()
224224
.unwrap()
225225
.to_string();

0 commit comments

Comments
 (0)