diff options
author | Darren Kulp <darren@kulp.ch> | 2022-02-19 20:24:27 -0500 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2022-03-15 03:53:10 +0100 |
commit | 638729fdbadfa4661553bb011b34f47058e26257 (patch) | |
tree | e6c9b990bfda6626af68059cb5f075768735a4b7 /tests | |
parent | 91b5371df62447fb91549b758ad3025dc83f295b (diff) |
tests: Enable a test with a const template param
This should have been added in #2155 but was missed then.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expectations/tests/template.rs | 34 | ||||
-rw-r--r-- | tests/headers/template.hpp | 4 |
2 files changed, 34 insertions, 4 deletions
diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index 9c484886..2e544ec3 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -64,12 +64,13 @@ pub struct C { pub mBConstRef: B<*const ::std::os::raw::c_int>, pub mPtrRef: B<*mut *mut ::std::os::raw::c_int>, pub mArrayRef: B<*mut [::std::os::raw::c_int; 1usize]>, + pub mBConstArray: B<[::std::os::raw::c_int; 1usize]>, } #[test] fn bindgen_test_layout_C() { assert_eq!( ::std::mem::size_of::<C>(), - 96usize, + 104usize, concat!("Size of: ", stringify!(C)) ); assert_eq!( @@ -236,6 +237,18 @@ fn bindgen_test_layout_C() { stringify!(mArrayRef) ) ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<C>())).mBConstArray as *const _ as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(C), + "::", + stringify!(mBConstArray) + ) + ); } impl Default for C { fn default() -> Self { @@ -877,6 +890,25 @@ fn __bindgen_test_layout_B_open0_ref_array1_int_close0_instantiation() { ); } #[test] +fn __bindgen_test_layout_B_open0_array1_const_int_close0_instantiation() { + assert_eq!( + ::std::mem::size_of::<B<[::std::os::raw::c_int; 1usize]>>(), + 4usize, + concat!( + "Size of template specialization: ", + stringify!(B<[::std::os::raw::c_int; 1usize]>) + ) + ); + assert_eq!( + ::std::mem::align_of::<B<[::std::os::raw::c_int; 1usize]>>(), + 4usize, + concat!( + "Alignment of template specialization: ", + stringify!(B<[::std::os::raw::c_int; 1usize]>) + ) + ); +} +#[test] fn __bindgen_test_layout_Foo_open0_int_int_close0_instantiation_1() { assert_eq!( ::std::mem::size_of::<Foo<::std::os::raw::c_int>>(), diff --git a/tests/headers/template.hpp b/tests/headers/template.hpp index eea2c4de..bc32a357 100644 --- a/tests/headers/template.hpp +++ b/tests/headers/template.hpp @@ -32,9 +32,7 @@ struct C { B<const int&> mBConstRef; B<int*&> mPtrRef; B<int(&)[1]> mArrayRef; - // clang 3.x ignores const in this case, so they generate different - // result than clang 4.0. - // B<const int[1]> mBConstArray; + B<const int[1]> mBConstArray; }; template<typename T> |