blob: 638eb14281b5a401b116b783731953639f517f0d [file] [log] [blame]
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
/// <div rustbindgen="true" replaces="whatever"></div>
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct whatever {
pub replacement: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_whatever() {
assert_eq!(
::std::mem::size_of::<whatever>(),
4usize,
concat!("Size of: ", stringify!(whatever))
);
assert_eq!(
::std::mem::align_of::<whatever>(),
4usize,
concat!("Alignment of ", stringify!(whatever))
);
assert_eq!(
{
let struct_instance = unsafe { std::mem::zeroed::<whatever>() };
let struct_ptr = &struct_instance as *const whatever;
let field_ptr = std::ptr::addr_of!(struct_instance.replacement);
let struct_address = struct_ptr as usize;
let field_address = field_ptr as usize;
std::mem::forget(struct_instance);
field_address.checked_sub(struct_address).unwrap()
},
0usize,
concat!(
"Offset of field: ",
stringify!(whatever),
"::",
stringify!(replacement)
)
);
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct container {
pub c: whatever,
}
#[test]
fn bindgen_test_layout_container() {
assert_eq!(
::std::mem::size_of::<container>(),
4usize,
concat!("Size of: ", stringify!(container))
);
assert_eq!(
::std::mem::align_of::<container>(),
4usize,
concat!("Alignment of ", stringify!(container))
);
assert_eq!(
{
let struct_instance = unsafe { std::mem::zeroed::<container>() };
let struct_ptr = &struct_instance as *const container;
let field_ptr = std::ptr::addr_of!(struct_instance.c);
let struct_address = struct_ptr as usize;
let field_address = field_ptr as usize;
std::mem::forget(struct_instance);
field_address.checked_sub(struct_address).unwrap()
},
0usize,
concat!(
"Offset of field: ",
stringify!(container),
"::",
stringify!(c)
)
);
}