summaryrefslogtreecommitdiff
path: root/tests/test_struct.rs
diff options
context:
space:
mode:
authorEdward Barnard <eabarnard@gmail.com>2015-01-03 14:03:44 +0000
committerEdward Barnard <eabarnard@gmail.com>2015-01-03 14:29:53 +0000
commitb016bc541ad172479f83615eddf49c129b2ddb74 (patch)
treeca78451bac5a12f94d343cdc119fb622a973dcde /tests/test_struct.rs
parent76b8db5f9b1ed4637707574950a9c34a2ac3e1fe (diff)
Recurse through arrays and pointers to anonymous structs. Closes #150.
Diffstat (limited to 'tests/test_struct.rs')
-rw-r--r--tests/test_struct.rs49
1 files changed, 41 insertions, 8 deletions
diff --git a/tests/test_struct.rs b/tests/test_struct.rs
index d9d8f930..3a9e3550 100644
--- a/tests/test_struct.rs
+++ b/tests/test_struct.rs
@@ -14,14 +14,47 @@ fn with_anon_struct() {
#[test]
fn with_anon_struct_array() {
- mod ffi { bindgen!("headers/struct_with_anon_struct_array.h"); }
- let mut x: ffi::Struct_foo = Default::default();
-
- x.bar[1].a = 1;
- x.bar[1].b = 2;
-
- assert_eq!(x.bar[1].a, 1);
- assert_eq!(x.bar[1].b, 2);
+ assert_bind_eq!("headers/struct_with_anon_struct_array.h", cx,
+ quote_item!(cx,
+ #[repr(C)]
+ #[deriving(Copy)]
+ pub struct Struct_foo {
+ pub bar: [Struct_Unnamed1; 2u],
+ pub baz: [[[Struct_Unnamed2; 4u]; 3u]; 2u],
+ }
+ ),
+ quote_item!(cx,
+ impl ::std::default::Default for Struct_foo {
+ fn default() -> Struct_foo { unsafe { ::std::mem::zeroed() } }
+ }
+ ),
+ quote_item!(cx,
+ #[repr(C)]
+ #[deriving(Copy)]
+ pub struct Struct_Unnamed1 {
+ pub a: ::libc::c_int,
+ pub b: ::libc::c_int,
+ }
+ ),
+ quote_item!(cx,
+ impl ::std::default::Default for Struct_Unnamed1 {
+ fn default() -> Struct_Unnamed1 { unsafe { ::std::mem::zeroed() } }
+ }
+ ),
+ quote_item!(cx,
+ #[repr(C)]
+ #[deriving(Copy)]
+ pub struct Struct_Unnamed2 {
+ pub a: ::libc::c_int,
+ pub b: ::libc::c_int,
+ }
+ ),
+ quote_item!(cx,
+ impl ::std::default::Default for Struct_Unnamed2 {
+ fn default() -> Struct_Unnamed2 { unsafe { ::std::mem::zeroed() } }
+ }
+ )
+ );
}
#[test]