summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlkka Rauta <ilkka.rauta@gmail.com>2015-07-29 16:22:09 +0300
committerIlkka Rauta <ilkka.rauta@gmail.com>2015-07-29 16:22:34 +0300
commit740fe6db8e8d183e24a2bd3ab56b8757955544b7 (patch)
tree31b315a44036970a8e17ccf72426e80aab0b3c16
parent5bd9f05a5c9d907e92be6df4aa28e655bacf3df7 (diff)
Add test for 'packed' attribute.
-rw-r--r--tests/headers/struct_with_packing.h4
-rw-r--r--tests/test_struct.rs19
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() } }
+ }
+ ");
+}
+