diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/headers/struct_with_anon_struct_array.h | 4 | ||||
-rw-r--r-- | tests/test_struct.rs | 49 |
2 files changed, 45 insertions, 8 deletions
diff --git a/tests/headers/struct_with_anon_struct_array.h b/tests/headers/struct_with_anon_struct_array.h index 2d9d7bdd..9ea977e8 100644 --- a/tests/headers/struct_with_anon_struct_array.h +++ b/tests/headers/struct_with_anon_struct_array.h @@ -3,4 +3,8 @@ struct foo { int a; int b; } bar[2]; + struct { + int a; + int b; + } baz[2][3][4]; }; 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] |