diff options
-rw-r--r-- | tests/headers/struct_with_packing.h | 4 | ||||
-rw-r--r-- | tests/test_struct.rs | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/headers/struct_with_packing.h b/tests/headers/struct_with_packing.h new file mode 100644 index 00000000..1b9fe131 --- /dev/null +++ b/tests/headers/struct_with_packing.h @@ -0,0 +1,4 @@ +struct a { + char b; + short c; +} __attribute__((packed)); diff --git a/tests/test_struct.rs b/tests/test_struct.rs index fb61a09c..37424530 100644 --- a/tests/test_struct.rs +++ b/tests/test_struct.rs @@ -331,3 +331,22 @@ fn with_fwd_decl_struct() { "); } + +#[test] +fn packed_struct() { + assert_bind_eq("headers/struct_with_packing.h", " + #[repr(C, packed)] + #[derive(Copy)] + pub struct Struct_a { + pub b: ::libc::c_char, + pub c: ::libc::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() } } + } + "); +} + |