summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2017-07-20 10:44:53 +1000
committerXidorn Quan <me@upsuper.org>2017-07-20 10:46:36 +1000
commit294483487aa41a1a12deea4c9ecde1ba79c0976f (patch)
tree5cf8bf97fe4c386bb7ae4e359ed8fb5ea9c03883 /tests
parentc6cf648b6cd9a5d6a85336ab7dc47388c346e27c (diff)
Use a platform-neutral header for test_multiple_header_calls_in_builder
Diffstat (limited to 'tests')
-rw-r--r--tests/expectations/tests/test_multiple_header_calls_in_builder.rs95
-rw-r--r--tests/tests.rs2
2 files changed, 90 insertions, 7 deletions
diff --git a/tests/expectations/tests/test_multiple_header_calls_in_builder.rs b/tests/expectations/tests/test_multiple_header_calls_in_builder.rs
index 58ec6fff..5f009f85 100644
--- a/tests/expectations/tests/test_multiple_header_calls_in_builder.rs
+++ b/tests/expectations/tests/test_multiple_header_calls_in_builder.rs
@@ -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 }
+}
diff --git a/tests/tests.rs b/tests/tests.rs
index 41e8d858..cf04af50 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -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();