diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-04-05 19:26:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-05 19:26:03 -0500 |
commit | 261a81c7940dbde0f09f19cc4dd10437f8d230e8 (patch) | |
tree | 98562ad926eee558d726981a17e2d2b2d8acf315 | |
parent | abd454cfc67c6815bc9084fdf5b1405bfd5ac660 (diff) | |
parent | 9a52ca27f2283854e5295d0e94e2fcf97c941211 (diff) |
Auto merge of #616 - fitzgen:explicit-test-for-default-type-parameters, r=emilio
Add a test explicitly for default type parameters
This is exercised in other tests, but in a round about fashion. It is nice to have a test that explicitly exercises default type parameters, without any cruft.
r? @emilio
-rw-r--r-- | tests/expectations/tests/default-template-parameter.rs | 30 | ||||
-rw-r--r-- | tests/headers/default-template-parameter.hpp | 7 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/expectations/tests/default-template-parameter.rs b/tests/expectations/tests/default-template-parameter.rs new file mode 100644 index 00000000..af4616ff --- /dev/null +++ b/tests/expectations/tests/default-template-parameter.rs @@ -0,0 +1,30 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Foo<T, U> { + pub t: T, + pub u: U, +} +impl <T, U> Default for Foo<T, U> { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} +#[test] +fn __bindgen_test_layout_Foo_instantiation_6() { + assert_eq!(::std::mem::size_of::<Foo<bool, ::std::os::raw::c_int>>() , + 8usize , concat ! ( + "Size of template specialization: " , stringify ! ( + Foo<bool, ::std::os::raw::c_int> ) )); + assert_eq!(::std::mem::align_of::<Foo<bool, ::std::os::raw::c_int>>() , + 4usize , concat ! ( + "Alignment of template specialization: " , stringify ! ( + Foo<bool, ::std::os::raw::c_int> ) )); +} +extern "C" { + #[link_name = "_ZL3bar"] + pub static mut bar: Foo<bool, ::std::os::raw::c_int>; +} diff --git a/tests/headers/default-template-parameter.hpp b/tests/headers/default-template-parameter.hpp new file mode 100644 index 00000000..4deed834 --- /dev/null +++ b/tests/headers/default-template-parameter.hpp @@ -0,0 +1,7 @@ +template <typename T, typename U = int> +struct Foo { + T t; + U u; +}; + +static Foo<bool> bar; |