summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYamakaky <yamakaky@yamaworld.fr>2016-03-11 15:19:44 +0100
committerYamakaky <yamakaky@yamaworld.fr>2016-03-11 15:19:44 +0100
commitaf4ab06657ae224bd2e7bec8efdbef3aa924f34c (patch)
treec24dd08c48f1ca60adb5bc3af28259e083c48c1d /tests
parent08a32d5276afa7c120af3ce83ba3e32d59503e68 (diff)
derive(Debug) on unions.
Related #282
Diffstat (limited to 'tests')
-rw-r--r--tests/test_struct.rs1
-rw-r--r--tests/test_union.rs55
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/test_struct.rs b/tests/test_struct.rs
index 4539be83..2360f208 100644
--- a/tests/test_struct.rs
+++ b/tests/test_struct.rs
@@ -132,6 +132,7 @@ fn with_anon_union() {
}
#[repr(C)]
#[derive(Copy)]
+ #[derive(Debug)]
pub struct Union_Unnamed1 {
pub _bindgen_data_: [u32; 1usize],
}
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() } }
+ }
+ ");
+}