diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-03-10 07:45:08 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-03-13 12:16:55 +0100 |
commit | 965dff29049c792f9243f2bbb9f5e64ba0b2ce52 (patch) | |
tree | 4175bfdd86652ef0d94ae0493fad603fb3bf4040 | |
parent | cd7e095091c4c8526aabd8aa7447bec67ddb95e2 (diff) |
tests: Add a test for alignas(double).
-rw-r--r-- | tests/expectations/tests/repr-align.rs | 31 | ||||
-rw-r--r-- | tests/headers/repr-align.hpp | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/expectations/tests/repr-align.rs b/tests/expectations/tests/repr-align.rs index be9ce9ad..9689dacd 100644 --- a/tests/expectations/tests/repr-align.rs +++ b/tests/expectations/tests/repr-align.rs @@ -33,3 +33,34 @@ fn bindgen_test_layout_a() { concat!("Offset of field: ", stringify!(a), "::", stringify!(c)) ); } +#[repr(C)] +#[repr(align(8))] +#[derive(Debug, Default, Copy, Clone)] +pub struct b { + pub b: ::std::os::raw::c_int, + pub c: ::std::os::raw::c_int, + pub __bindgen_align: [u64; 0usize], +} +#[test] +fn bindgen_test_layout_b() { + assert_eq!( + ::std::mem::size_of::<b>(), + 8usize, + concat!("Size of: ", stringify!(b)) + ); + assert_eq!( + ::std::mem::align_of::<b>(), + 8usize, + concat!("Alignment of ", stringify!(b)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<b>())).b as *const _ as usize }, + 0usize, + concat!("Offset of field: ", stringify!(b), "::", stringify!(b)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<b>())).c as *const _ as usize }, + 4usize, + concat!("Offset of field: ", stringify!(b), "::", stringify!(c)) + ); +} diff --git a/tests/headers/repr-align.hpp b/tests/headers/repr-align.hpp index f0629496..5e1b60ab 100644 --- a/tests/headers/repr-align.hpp +++ b/tests/headers/repr-align.hpp @@ -4,3 +4,8 @@ struct alignas(8) a { int b; int c; }; + +struct alignas(double) b { + int b; + int c; +}; |