Skip to content

Commit 5ee3601

Browse files
committed
Add new expectations for tests
1 parent bed241e commit 5ee3601

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

libbindgen/src/codegen/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,11 +669,11 @@ impl CodeGenerator for CompInfo {
669669
for arg in self.template_args() {
670670
if let Some(name) = ctx.resolve_type(*arg).name() {
671671
// hope this isn't bad
672-
types.push_str(format!("{}_", name).as_str());
672+
types.push_str(format!("_{}", name).as_str());
673673
}
674674
}
675675

676-
let fn_name = format!("bindgen_test_layout_template_{}_{}", canonical_name, types);
676+
let fn_name = format!("bindgen_test_layout_template_{}{}", canonical_name, types);
677677
let fn_name = ctx.rust_ident_raw(&fn_name);
678678
let ident = item.to_rust_ty(ctx);
679679
let prefix = ctx.trait_prefix();

libbindgen/tests/expectations/tests/anon_union.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,10 @@ fn bindgen_test_layout_ErrorResult() {
7575
impl Clone for ErrorResult {
7676
fn clone(&self) -> Self { *self }
7777
}
78+
#[test]
79+
fn bindgen_test_layout_template_TErrorResult_int() {
80+
assert_eq!(::std::mem::size_of::<TErrorResult<::std::os::raw::c_int>>() ,
81+
24usize);
82+
assert_eq!(::std::mem::align_of::<TErrorResult<::std::os::raw::c_int>>() ,
83+
8usize);
84+
}

libbindgen/tests/expectations/tests/class_with_dtor.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ fn bindgen_test_layout_WithoutDtor() {
2020
assert_eq!(::std::mem::size_of::<WithoutDtor>() , 8usize);
2121
assert_eq!(::std::mem::align_of::<WithoutDtor>() , 8usize);
2222
}
23+
#[test]
24+
fn bindgen_test_layout_template_HandleWithDtor_int() {
25+
assert_eq!(::std::mem::size_of::<HandleWithDtor<::std::os::raw::c_int>>()
26+
, 8usize);
27+
assert_eq!(::std::mem::align_of::<HandleWithDtor<::std::os::raw::c_int>>()
28+
, 8usize);
29+
}

libbindgen/tests/expectations/tests/crtp.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ fn bindgen_test_layout_Derived() {
2323
impl Clone for Derived {
2424
fn clone(&self) -> Self { *self }
2525
}
26+
#[test]
27+
fn bindgen_test_layout_template_Base() {
28+
assert_eq!(::std::mem::size_of::<Base<Derived>>() , 1usize);
29+
assert_eq!(::std::mem::align_of::<Base<Derived>>() , 1usize);
30+
}
2631
#[repr(C)]
2732
#[derive(Debug)]
2833
pub struct BaseWithDestructor<T> {
@@ -41,3 +46,10 @@ fn bindgen_test_layout_DerivedFromBaseWithDestructor() {
4146
assert_eq!(::std::mem::align_of::<DerivedFromBaseWithDestructor>() ,
4247
1usize);
4348
}
49+
#[test]
50+
fn bindgen_test_layout_template_BaseWithDestructor() {
51+
assert_eq!(::std::mem::size_of::<BaseWithDestructor<DerivedFromBaseWithDestructor>>()
52+
, 1usize);
53+
assert_eq!(::std::mem::align_of::<BaseWithDestructor<DerivedFromBaseWithDestructor>>()
54+
, 1usize);
55+
}

libbindgen/tests/expectations/tests/template.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ pub struct Foo<T, U> {
1212
pub m_member_arr: [T; 1usize],
1313
pub _phantom_1: ::std::marker::PhantomData<U>,
1414
}
15+
#[test]
16+
fn bindgen_test_layout_template_Foo_int_int() {
17+
assert_eq!(::std::mem::size_of::<Foo<::std::os::raw::c_int, ::std::os::raw::c_int>>()
18+
, 24usize);
19+
assert_eq!(::std::mem::align_of::<Foo<::std::os::raw::c_int, ::std::os::raw::c_int>>()
20+
, 8usize);
21+
}
1522
extern "C" {
1623
#[link_name = "_Z3bar3FooIiiE"]
1724
pub fn bar(foo: Foo<::std::os::raw::c_int, ::std::os::raw::c_int>);
@@ -168,3 +175,10 @@ pub struct TemplateWithVar<T> {
168175
pub _address: u8,
169176
pub _phantom_0: ::std::marker::PhantomData<T>,
170177
}
178+
#[test]
179+
fn bindgen_test_layout_template_WithDtor_int() {
180+
assert_eq!(::std::mem::size_of::<WithDtor<::std::os::raw::c_int>>() ,
181+
4usize);
182+
assert_eq!(::std::mem::align_of::<WithDtor<::std::os::raw::c_int>>() ,
183+
4usize);
184+
}

0 commit comments

Comments
 (0)