diff options
Diffstat (limited to 'tests/test_union.rs')
-rw-r--r-- | tests/test_union.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/test_union.rs b/tests/test_union.rs index 2e1869ac..f35e325a 100644 --- a/tests/test_union.rs +++ b/tests/test_union.rs @@ -5,6 +5,7 @@ fn with_anon_struct() { assert_bind_eq(Default::default(), "headers/union_with_anon_struct.h", " #[repr(C)] #[derive(Copy)] + #[derive(Debug)] pub struct Union_foo { pub _bindgen_data_: [u32; 2usize], } @@ -41,6 +42,7 @@ fn with_anon_struct_bitfield() { assert_bind_eq(Default::default(), "headers/union_with_anon_struct_bitfield.h", " #[repr(C)] #[derive(Copy)] + #[derive(Debug)] pub struct Union_foo { pub _bindgen_data_: [u32; 1usize], } @@ -67,6 +69,7 @@ fn with_anon_union() { assert_bind_eq(Default::default(), "headers/union_with_anon_union.h", " #[repr(C)] #[derive(Copy)] + #[derive(Debug)] pub struct Union_foo { pub _bindgen_data_: [u32; 1usize], } @@ -84,6 +87,7 @@ fn with_anon_union() { } #[repr(C)] #[derive(Copy)] + #[derive(Debug)] pub struct Union_Unnamed1 { pub _bindgen_data_: [u32; 1usize], } @@ -111,6 +115,7 @@ fn with_anon_unnamed_struct() { assert_bind_eq(Default::default(), "headers/union_with_anon_unnamed_struct.h", " #[repr(C)] #[derive(Copy)] + #[derive(Debug)] pub struct Union_pixel { pub _bindgen_data_: [u32; 1usize], } @@ -150,6 +155,7 @@ fn with_anon_unnamed_union() { assert_bind_eq(Default::default(), "headers/union_with_anon_unnamed_union.h", " #[repr(C)] #[derive(Copy)] + #[derive(Debug)] pub struct Union_foo { pub _bindgen_data_: [u32; 1usize], } @@ -181,6 +187,7 @@ fn with_nesting() { assert_bind_eq(Default::default(), "headers/union_with_nesting.h", " #[repr(C)] #[derive(Copy)] + #[derive(Debug)] pub struct Union_foo { pub _bindgen_data_: [u32; 1usize], } @@ -214,3 +221,51 @@ fn with_nesting() { } "); } + +#[test] +fn with_derive_debug() { + assert_bind_eq(Default::default(), "headers/union_with_big_member.h", " + #[repr(C)] + #[derive(Copy)] + pub struct Union_WithBigArray { + pub _bindgen_data_: [u32; 33usize], + } + impl Union_WithBigArray { + pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int { + let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); + ::std::mem::transmute(raw.offset(0)) + } + pub unsafe fn b(&mut self) -> *mut [::std::os::raw::c_int; 33usize] { + let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); + ::std::mem::transmute(raw.offset(0)) + } + } + impl ::std::clone::Clone for Union_WithBigArray { + fn clone(&self) -> Self { *self } + } + impl ::std::default::Default for Union_WithBigArray { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + #[repr(C)] + #[derive(Copy)] + pub struct Union_WithBigMember { + pub _bindgen_data_: [u32; 33usize], + } + impl Union_WithBigMember { + pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int { + let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); + ::std::mem::transmute(raw.offset(0)) + } + pub unsafe fn b(&mut self) -> *mut Union_WithBigArray { + let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_); + ::std::mem::transmute(raw.offset(0)) + } + } + impl ::std::clone::Clone for Union_WithBigMember { + fn clone(&self) -> Self { *self } + } + impl ::std::default::Default for Union_WithBigMember { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } + } + "); +} |