-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for dependent qualified types.
- Loading branch information
Showing
8 changed files
with
433 additions
and
6 deletions.
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
tests/expectations/tests/dependent_qualified_type_complex.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#![allow( | ||
dead_code, | ||
non_snake_case, | ||
non_camel_case_types, | ||
non_upper_case_globals | ||
)] | ||
|
||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct InnerType { | ||
pub foo: ::std::os::raw::c_int, | ||
pub foo2: ::std::os::raw::c_int, | ||
} | ||
pub type InnerType_related_type = ::std::os::raw::c_int; | ||
impl __bindgen_has_inner_type_related_type for InnerType { | ||
type related_type = InnerType_related_type; | ||
} | ||
#[test] | ||
fn bindgen_test_layout_InnerType() { | ||
assert_eq!( | ||
::std::mem::size_of::<InnerType>(), | ||
8usize, | ||
concat!("Size of: ", stringify!(InnerType)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<InnerType>(), | ||
4usize, | ||
concat!("Alignment of ", stringify!(InnerType)) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<InnerType>())).foo as *const _ as usize | ||
}, | ||
0usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(InnerType), | ||
"::", | ||
stringify!(foo) | ||
) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<InnerType>())).foo2 as *const _ as usize | ||
}, | ||
4usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(InnerType), | ||
"::", | ||
stringify!(foo2) | ||
) | ||
); | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct Container<ContainedType> | ||
where | ||
ContainedType: __bindgen_has_inner_type_related_type, | ||
{ | ||
pub contents_: Container_content_ty<ContainedType>, | ||
pub _phantom_0: | ||
::std::marker::PhantomData<::std::cell::UnsafeCell<ContainedType>>, | ||
} | ||
pub type Container_content_ty<ContainedType> = | ||
<ContainedType as __bindgen_has_inner_type_related_type>::related_type; | ||
pub type Concrete = Container<InnerType>; | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct LaterContainingType { | ||
pub outer_contents: Concrete, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_LaterContainingType() { | ||
assert_eq!( | ||
::std::mem::size_of::<LaterContainingType>(), | ||
4usize, | ||
concat!("Size of: ", stringify!(LaterContainingType)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<LaterContainingType>(), | ||
4usize, | ||
concat!("Alignment of ", stringify!(LaterContainingType)) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<LaterContainingType>())).outer_contents | ||
as *const _ as usize | ||
}, | ||
0usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(LaterContainingType), | ||
"::", | ||
stringify!(outer_contents) | ||
) | ||
); | ||
} | ||
pub trait __bindgen_has_inner_type_related_type { | ||
type related_type: std::fmt::Debug + Default + Copy + Clone; | ||
} | ||
#[test] | ||
fn __bindgen_test_layout_Container_open0_InnerType_close0_instantiation() { | ||
assert_eq!( | ||
::std::mem::size_of::<Container<InnerType>>(), | ||
4usize, | ||
concat!( | ||
"Size of template specialization: ", | ||
stringify!(Container<InnerType>) | ||
) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<Container<InnerType>>(), | ||
4usize, | ||
concat!( | ||
"Alignment of template specialization: ", | ||
stringify!(Container<InnerType>) | ||
) | ||
); | ||
} |
56 changes: 56 additions & 0 deletions
56
tests/expectations/tests/dependent_qualified_type_simpler.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#![allow( | ||
dead_code, | ||
non_snake_case, | ||
non_camel_case_types, | ||
non_upper_case_globals | ||
)] | ||
|
||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct InnerType { | ||
pub foo: ::std::os::raw::c_long, | ||
} | ||
pub type InnerType_related_type = ::std::os::raw::c_int; | ||
impl __bindgen_has_inner_type_related_type for InnerType { | ||
type related_type = InnerType_related_type; | ||
} | ||
#[test] | ||
fn bindgen_test_layout_InnerType() { | ||
assert_eq!( | ||
::std::mem::size_of::<InnerType>(), | ||
8usize, | ||
concat!("Size of: ", stringify!(InnerType)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<InnerType>(), | ||
8usize, | ||
concat!("Alignment of ", stringify!(InnerType)) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<InnerType>())).foo as *const _ as usize | ||
}, | ||
0usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(InnerType), | ||
"::", | ||
stringify!(foo) | ||
) | ||
); | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct Container<ContainedType> | ||
where | ||
ContainedType: __bindgen_has_inner_type_related_type, | ||
{ | ||
pub contents_: | ||
<ContainedType as __bindgen_has_inner_type_related_type>::related_type, | ||
pub _phantom_0: | ||
::std::marker::PhantomData<::std::cell::UnsafeCell<ContainedType>>, | ||
} | ||
pub type Concrete = Container<InnerType>; | ||
pub trait __bindgen_has_inner_type_related_type { | ||
type related_type: std::fmt::Debug + Default + Copy + Clone; | ||
} |
187 changes: 187 additions & 0 deletions
187
tests/expectations/tests/dependent_qualified_type_two.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
#![allow( | ||
dead_code, | ||
non_snake_case, | ||
non_camel_case_types, | ||
non_upper_case_globals | ||
)] | ||
|
||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct InnerTypeA { | ||
pub foo: ::std::os::raw::c_int, | ||
pub foo2: ::std::os::raw::c_int, | ||
} | ||
pub type InnerTypeA_related_type = ::std::os::raw::c_int; | ||
impl __bindgen_has_inner_type_related_type for InnerTypeA { | ||
type related_type = InnerTypeA_related_type; | ||
} | ||
#[test] | ||
fn bindgen_test_layout_InnerTypeA() { | ||
assert_eq!( | ||
::std::mem::size_of::<InnerTypeA>(), | ||
8usize, | ||
concat!("Size of: ", stringify!(InnerTypeA)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<InnerTypeA>(), | ||
4usize, | ||
concat!("Alignment of ", stringify!(InnerTypeA)) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<InnerTypeA>())).foo as *const _ as usize | ||
}, | ||
0usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(InnerTypeA), | ||
"::", | ||
stringify!(foo) | ||
) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<InnerTypeA>())).foo2 as *const _ as usize | ||
}, | ||
4usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(InnerTypeA), | ||
"::", | ||
stringify!(foo2) | ||
) | ||
); | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct InnerTypeB { | ||
pub bar: ::std::os::raw::c_ulong, | ||
} | ||
pub type InnerTypeB_related_type = ::std::os::raw::c_char; | ||
impl __bindgen_has_inner_type_related_type for InnerTypeB { | ||
type related_type = InnerTypeB_related_type; | ||
} | ||
#[test] | ||
fn bindgen_test_layout_InnerTypeB() { | ||
assert_eq!( | ||
::std::mem::size_of::<InnerTypeB>(), | ||
8usize, | ||
concat!("Size of: ", stringify!(InnerTypeB)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<InnerTypeB>(), | ||
8usize, | ||
concat!("Alignment of ", stringify!(InnerTypeB)) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<InnerTypeB>())).bar as *const _ as usize | ||
}, | ||
0usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(InnerTypeB), | ||
"::", | ||
stringify!(bar) | ||
) | ||
); | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct Container<ContainedType> | ||
where | ||
ContainedType: __bindgen_has_inner_type_related_type, | ||
{ | ||
pub contents_: Container_content_ty<ContainedType>, | ||
pub _phantom_0: | ||
::std::marker::PhantomData<::std::cell::UnsafeCell<ContainedType>>, | ||
} | ||
pub type Container_content_ty<ContainedType> = | ||
<ContainedType as __bindgen_has_inner_type_related_type>::related_type; | ||
pub type Concrete = Container<InnerTypeA>; | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct LaterContainingType { | ||
pub outer_contents_a: Concrete, | ||
pub outer_contents_b: Container<InnerTypeB>, | ||
} | ||
#[test] | ||
fn bindgen_test_layout_LaterContainingType() { | ||
assert_eq!( | ||
::std::mem::size_of::<LaterContainingType>(), | ||
8usize, | ||
concat!("Size of: ", stringify!(LaterContainingType)) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<LaterContainingType>(), | ||
4usize, | ||
concat!("Alignment of ", stringify!(LaterContainingType)) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<LaterContainingType>())).outer_contents_a | ||
as *const _ as usize | ||
}, | ||
0usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(LaterContainingType), | ||
"::", | ||
stringify!(outer_contents_a) | ||
) | ||
); | ||
assert_eq!( | ||
unsafe { | ||
&(*(::std::ptr::null::<LaterContainingType>())).outer_contents_b | ||
as *const _ as usize | ||
}, | ||
4usize, | ||
concat!( | ||
"Offset of field: ", | ||
stringify!(LaterContainingType), | ||
"::", | ||
stringify!(outer_contents_b) | ||
) | ||
); | ||
} | ||
pub trait __bindgen_has_inner_type_related_type { | ||
type related_type: std::fmt::Debug + Default + Copy + Clone; | ||
} | ||
#[test] | ||
fn __bindgen_test_layout_Container_open0_InnerTypeA_close0_instantiation() { | ||
assert_eq!( | ||
::std::mem::size_of::<Container<InnerTypeA>>(), | ||
4usize, | ||
concat!( | ||
"Size of template specialization: ", | ||
stringify!(Container<InnerTypeA>) | ||
) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<Container<InnerTypeA>>(), | ||
4usize, | ||
concat!( | ||
"Alignment of template specialization: ", | ||
stringify!(Container<InnerTypeA>) | ||
) | ||
); | ||
} | ||
#[test] | ||
fn __bindgen_test_layout_Container_open0_InnerTypeB_close0_instantiation() { | ||
assert_eq!( | ||
::std::mem::size_of::<Container<InnerTypeB>>(), | ||
1usize, | ||
concat!( | ||
"Size of template specialization: ", | ||
stringify!(Container<InnerTypeB>) | ||
) | ||
); | ||
assert_eq!( | ||
::std::mem::align_of::<Container<InnerTypeB>>(), | ||
1usize, | ||
concat!( | ||
"Alignment of template specialization: ", | ||
stringify!(Container<InnerTypeB>) | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.