Skip to content

Commit

Permalink
Use a platform-neutral header for test_multiple_header_calls_in_builder
Browse files Browse the repository at this point in the history
  • Loading branch information
upsuper committed Jul 20, 2017
1 parent c6cf648 commit 2944834
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 7 deletions.
95 changes: 89 additions & 6 deletions tests/expectations/tests/test_multiple_header_calls_in_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,92 @@ extern "C" {
::std::os::raw::c_int)
-> ::std::os::raw::c_int>;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Foo { Bar = 0, Qux = 1, }
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Neg { MinusOne = -1, One = 1, }
pub type Char = ::std::os::raw::c_char;
pub type SChar = ::std::os::raw::c_schar;
pub type UChar = ::std::os::raw::c_uchar;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Test {
pub ch: ::std::os::raw::c_char,
pub u: ::std::os::raw::c_uchar,
pub d: ::std::os::raw::c_schar,
pub cch: ::std::os::raw::c_char,
pub cu: ::std::os::raw::c_uchar,
pub cd: ::std::os::raw::c_schar,
pub Cch: Char,
pub Cu: UChar,
pub Cd: SChar,
pub Ccch: Char,
pub Ccu: UChar,
pub Ccd: SChar,
}
#[test]
fn bindgen_test_layout_Test() {
assert_eq!(::std::mem::size_of::<Test>() , 12usize , concat ! (
"Size of: " , stringify ! ( Test ) ));
assert_eq! (::std::mem::align_of::<Test>() , 1usize , concat ! (
"Alignment of " , stringify ! ( Test ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . ch as * const _ as usize } ,
0usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( ch ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . u as * const _ as usize } ,
1usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( u ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . d as * const _ as usize } ,
2usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( d ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . cch as * const _ as usize } ,
3usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( cch ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . cu as * const _ as usize } ,
4usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( cu ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . cd as * const _ as usize } ,
5usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( cd ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . Cch as * const _ as usize } ,
6usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( Cch ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . Cu as * const _ as usize } ,
7usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( Cu ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . Cd as * const _ as usize } ,
8usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( Cd ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . Ccch as * const _ as usize } ,
9usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( Ccch ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . Ccu as * const _ as usize } ,
10usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( Ccu ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const Test ) ) . Ccd as * const _ as usize } ,
11usize , concat ! (
"Alignment of field: " , stringify ! ( Test ) , "::" ,
stringify ! ( Ccd ) ));
}
impl Clone for Test {
fn clone(&self) -> Self { *self }
}
2 changes: 1 addition & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ extern \"C\" {
fn test_multiple_header_calls_in_builder() {
let actual = builder()
.header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/func_ptr.h"))
.header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/enum.h"))
.header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/char.h"))
.generate()
.unwrap()
.to_string();
Expand Down

0 comments on commit 2944834

Please sign in to comment.