summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Biryukov <impowski@protonmail.ch>2016-11-20 12:11:53 +0300
committerArtem Biryukov <impowski@protonmail.ch>2016-11-20 12:11:53 +0300
commit5ee3601ea9eb953df23b0454f30662f2c154f7a4 (patch)
treea28e15084292cddc0029afb5a0f4f81bbb067fcb
parentbed241ea45ce82a283f9c5cda3f98bd6969e53c2 (diff)
Add new expectations for tests
-rw-r--r--libbindgen/src/codegen/mod.rs4
-rw-r--r--libbindgen/tests/expectations/tests/anon_union.rs7
-rw-r--r--libbindgen/tests/expectations/tests/class_with_dtor.rs7
-rw-r--r--libbindgen/tests/expectations/tests/crtp.rs12
-rw-r--r--libbindgen/tests/expectations/tests/template.rs14
5 files changed, 42 insertions, 2 deletions
diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs
index c99caf9e..6730a910 100644
--- a/libbindgen/src/codegen/mod.rs
+++ b/libbindgen/src/codegen/mod.rs
@@ -669,11 +669,11 @@ impl CodeGenerator for CompInfo {
for arg in self.template_args() {
if let Some(name) = ctx.resolve_type(*arg).name() {
// hope this isn't bad
- types.push_str(format!("{}_", name).as_str());
+ types.push_str(format!("_{}", name).as_str());
}
}
- let fn_name = format!("bindgen_test_layout_template_{}_{}", canonical_name, types);
+ let fn_name = format!("bindgen_test_layout_template_{}{}", canonical_name, types);
let fn_name = ctx.rust_ident_raw(&fn_name);
let ident = item.to_rust_ty(ctx);
let prefix = ctx.trait_prefix();
diff --git a/libbindgen/tests/expectations/tests/anon_union.rs b/libbindgen/tests/expectations/tests/anon_union.rs
index 8af416c3..2dc206b7 100644
--- a/libbindgen/tests/expectations/tests/anon_union.rs
+++ b/libbindgen/tests/expectations/tests/anon_union.rs
@@ -75,3 +75,10 @@ fn bindgen_test_layout_ErrorResult() {
impl Clone for ErrorResult {
fn clone(&self) -> Self { *self }
}
+#[test]
+fn bindgen_test_layout_template_TErrorResult_int() {
+ assert_eq!(::std::mem::size_of::<TErrorResult<::std::os::raw::c_int>>() ,
+ 24usize);
+ assert_eq!(::std::mem::align_of::<TErrorResult<::std::os::raw::c_int>>() ,
+ 8usize);
+}
diff --git a/libbindgen/tests/expectations/tests/class_with_dtor.rs b/libbindgen/tests/expectations/tests/class_with_dtor.rs
index 8ed1ddf9..f09699ca 100644
--- a/libbindgen/tests/expectations/tests/class_with_dtor.rs
+++ b/libbindgen/tests/expectations/tests/class_with_dtor.rs
@@ -20,3 +20,10 @@ fn bindgen_test_layout_WithoutDtor() {
assert_eq!(::std::mem::size_of::<WithoutDtor>() , 8usize);
assert_eq!(::std::mem::align_of::<WithoutDtor>() , 8usize);
}
+#[test]
+fn bindgen_test_layout_template_HandleWithDtor_int() {
+ assert_eq!(::std::mem::size_of::<HandleWithDtor<::std::os::raw::c_int>>()
+ , 8usize);
+ assert_eq!(::std::mem::align_of::<HandleWithDtor<::std::os::raw::c_int>>()
+ , 8usize);
+}
diff --git a/libbindgen/tests/expectations/tests/crtp.rs b/libbindgen/tests/expectations/tests/crtp.rs
index e4a86b24..39629599 100644
--- a/libbindgen/tests/expectations/tests/crtp.rs
+++ b/libbindgen/tests/expectations/tests/crtp.rs
@@ -23,6 +23,11 @@ fn bindgen_test_layout_Derived() {
impl Clone for Derived {
fn clone(&self) -> Self { *self }
}
+#[test]
+fn bindgen_test_layout_template_Base() {
+ assert_eq!(::std::mem::size_of::<Base<Derived>>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Base<Derived>>() , 1usize);
+}
#[repr(C)]
#[derive(Debug)]
pub struct BaseWithDestructor<T> {
@@ -41,3 +46,10 @@ fn bindgen_test_layout_DerivedFromBaseWithDestructor() {
assert_eq!(::std::mem::align_of::<DerivedFromBaseWithDestructor>() ,
1usize);
}
+#[test]
+fn bindgen_test_layout_template_BaseWithDestructor() {
+ assert_eq!(::std::mem::size_of::<BaseWithDestructor<DerivedFromBaseWithDestructor>>()
+ , 1usize);
+ assert_eq!(::std::mem::align_of::<BaseWithDestructor<DerivedFromBaseWithDestructor>>()
+ , 1usize);
+}
diff --git a/libbindgen/tests/expectations/tests/template.rs b/libbindgen/tests/expectations/tests/template.rs
index 76afc879..970b9037 100644
--- a/libbindgen/tests/expectations/tests/template.rs
+++ b/libbindgen/tests/expectations/tests/template.rs
@@ -12,6 +12,13 @@ pub struct Foo<T, U> {
pub m_member_arr: [T; 1usize],
pub _phantom_1: ::std::marker::PhantomData<U>,
}
+#[test]
+fn bindgen_test_layout_template_Foo_int_int() {
+ assert_eq!(::std::mem::size_of::<Foo<::std::os::raw::c_int, ::std::os::raw::c_int>>()
+ , 24usize);
+ assert_eq!(::std::mem::align_of::<Foo<::std::os::raw::c_int, ::std::os::raw::c_int>>()
+ , 8usize);
+}
extern "C" {
#[link_name = "_Z3bar3FooIiiE"]
pub fn bar(foo: Foo<::std::os::raw::c_int, ::std::os::raw::c_int>);
@@ -168,3 +175,10 @@ pub struct TemplateWithVar<T> {
pub _address: u8,
pub _phantom_0: ::std::marker::PhantomData<T>,
}
+#[test]
+fn bindgen_test_layout_template_WithDtor_int() {
+ assert_eq!(::std::mem::size_of::<WithDtor<::std::os::raw::c_int>>() ,
+ 4usize);
+ assert_eq!(::std::mem::align_of::<WithDtor<::std::os::raw::c_int>>() ,
+ 4usize);
+}