summaryrefslogtreecommitdiff
path: root/tests/test_struct.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_struct.rs')
-rw-r--r--tests/test_struct.rs222
1 files changed, 33 insertions, 189 deletions
diff --git a/tests/test_struct.rs b/tests/test_struct.rs
index 2360f208..9f0625b4 100644
--- a/tests/test_struct.rs
+++ b/tests/test_struct.rs
@@ -4,125 +4,68 @@ use support::assert_bind_eq;
fn with_anon_struct() {
assert_bind_eq(Default::default(), "headers/struct_with_anon_struct.h", "
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_foo {
- pub bar: Struct_Unnamed1,
- }
- impl ::std::clone::Clone for Struct_foo {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_foo {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ pub bar: Struct_struct_with_anon_struct_h_unnamed_1,
}
+
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
- pub struct Struct_Unnamed1 {
+ #[derive(Copy, Clone)]
+ pub struct Struct_struct_with_anon_struct_h_unnamed_1 {
pub a: ::std::os::raw::c_int,
pub b: ::std::os::raw::c_int,
- }
- impl ::std::clone::Clone for Struct_Unnamed1 {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_Unnamed1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
- ");
+ }");
}
#[test]
fn with_anon_struct_array() {
assert_bind_eq(Default::default(), "headers/struct_with_anon_struct_array.h", "
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_foo {
- pub bar: [Struct_Unnamed1; 2usize],
- pub baz: [[[Struct_Unnamed2; 4usize]; 3usize]; 2usize],
- }
-
- impl ::std::clone::Clone for Struct_foo {
- fn clone(&self) -> Self { *self }
- }
-
- impl ::std::default::Default for Struct_foo {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ pub bar: [Struct_struct_with_anon_struct_array_h_unnamed_1; 2usize],
+ pub baz: [[[Struct_struct_with_anon_struct_array_h_unnamed_2; 4usize]; 3usize]; 2usize],
}
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
- pub struct Struct_Unnamed1 {
+ #[derive(Copy, Clone)]
+ pub struct Struct_struct_with_anon_struct_array_h_unnamed_1 {
pub a: ::std::os::raw::c_int,
pub b: ::std::os::raw::c_int,
}
- impl ::std::clone::Clone for Struct_Unnamed1 {
- fn clone(&self) -> Self { *self }
- }
-
- impl ::std::default::Default for Struct_Unnamed1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
-
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
- pub struct Struct_Unnamed2 {
+ #[derive(Copy, Clone)]
+ pub struct Struct_struct_with_anon_struct_array_h_unnamed_2 {
pub a: ::std::os::raw::c_int,
pub b: ::std::os::raw::c_int,
- }
-
- impl ::std::clone::Clone for Struct_Unnamed2 {
- fn clone(&self) -> Self { *self }
- }
-
- impl ::std::default::Default for Struct_Unnamed2 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
- ");
+ }");
}
#[test]
fn with_anon_struct_pointer() {
assert_bind_eq(Default::default(), "headers/struct_with_anon_struct_pointer.h", "
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_foo {
- pub bar: *mut Struct_Unnamed1,
- }
- impl ::std::clone::Clone for Struct_foo {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_foo {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+ pub bar: *mut Struct_struct_with_anon_struct_pointer_h_unnamed_1,
}
+
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
- pub struct Struct_Unnamed1 {
+ #[derive(Copy, Clone)]
+ pub struct Struct_struct_with_anon_struct_pointer_h_unnamed_1 {
pub a: ::std::os::raw::c_int,
pub b: ::std::os::raw::c_int,
- }
- impl ::std::clone::Clone for Struct_Unnamed1 {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_Unnamed1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
- ");
+ }");
}
#[test]
fn with_anon_union() {
assert_bind_eq(Default::default(), "headers/struct_with_anon_union.h", "
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_foo {
- pub bar: Union_Unnamed1,
+ pub bar: Union_unnamed1,
}
impl ::std::clone::Clone for Struct_foo {
fn clone(&self) -> Self { *self }
@@ -133,10 +76,10 @@ fn with_anon_union() {
#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
- pub struct Union_Unnamed1 {
+ pub struct Union_unnamed1 {
pub _bindgen_data_: [u32; 1usize],
}
- impl Union_Unnamed1 {
+ impl Union_unnamed1 {
pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
::std::mem::transmute(raw.offset(0))
@@ -146,12 +89,6 @@ fn with_anon_union() {
::std::mem::transmute(raw.offset(0))
}
}
- impl ::std::clone::Clone for Union_Unnamed1 {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Union_Unnamed1 {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
");
}
@@ -187,8 +124,7 @@ fn with_anon_unnamed_struct() {
fn with_anon_unnamed_union() {
assert_bind_eq(Default::default(), "headers/struct_with_anon_unnamed_union.h", "
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_foo {
pub _bindgen_data_1_: [u32; 1usize],
}
@@ -264,34 +200,16 @@ fn with_nesting() {
fn containing_fwd_decl_struct() {
assert_bind_eq(Default::default(), "headers/struct_containing_forward_declared_struct.h", "
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_a {
pub val_a: *mut Struct_b,
}
- impl ::std::clone::Clone for Struct_a {
- fn clone(&self) -> Self { *self }
- }
-
- impl ::std::default::Default for Struct_a {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
-
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_b {
pub val_b: ::std::os::raw::c_int,
}
-
- impl ::std::clone::Clone for Struct_b {
- fn clone(&self) -> Self { *self }
- }
-
- impl ::std::default::Default for Struct_b {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
");
}
@@ -322,30 +240,16 @@ fn with_bitfields() {
fn with_fwd_decl_struct() {
assert_bind_eq(Default::default(), "headers/forward_declared_struct.h", "
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_a {
pub b: ::std::os::raw::c_int,
}
- impl ::std::clone::Clone for Struct_a {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_a {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
+
#[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_c {
pub d: ::std::os::raw::c_int,
- }
- impl ::std::clone::Clone for Struct_c {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_c {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
- ");
+ }");
}
@@ -353,69 +257,9 @@ fn with_fwd_decl_struct() {
fn packed_struct() {
assert_bind_eq(Default::default(), "headers/struct_with_packing.h", "
#[repr(C, packed)]
- #[derive(Copy)]
- #[derive(Debug)]
+ #[derive(Copy, Clone)]
pub struct Struct_a {
pub b: ::std::os::raw::c_char,
pub c: ::std::os::raw::c_short,
- }
- impl ::std::clone::Clone for Struct_a {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_a {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
- ");
-}
-
-#[test]
-fn derive_debug_big_array() {
- assert_bind_eq(Default::default(), "headers/struct_with_derive_debug.h", "
- #[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
- pub struct Struct_LittleArray {
- pub a: [::std::os::raw::c_int; 32usize],
- }
- impl ::std::clone::Clone for Struct_LittleArray {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_LittleArray {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
- #[repr(C)]
- #[derive(Copy)]
- pub struct Struct_BigArray {
- pub a: [::std::os::raw::c_int; 33usize],
- }
- impl ::std::clone::Clone for Struct_BigArray {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_BigArray {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
- #[repr(C)]
- #[derive(Copy)]
- #[derive(Debug)]
- pub struct Struct_WithLittleArray {
- pub a: Struct_LittleArray,
- }
- impl ::std::clone::Clone for Struct_WithLittleArray {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_WithLittleArray {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
- #[repr(C)]
- #[derive(Copy)]
- pub struct Struct_WithBigArray {
- pub a: Struct_BigArray,
- }
- impl ::std::clone::Clone for Struct_WithBigArray {
- fn clone(&self) -> Self { *self }
- }
- impl ::std::default::Default for Struct_WithBigArray {
- fn default() -> Self { unsafe { ::std::mem::zeroed() } }
- }
- ");
+ }");
}