• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![allow(
2     dead_code,
3     non_snake_case,
4     non_camel_case_types,
5     non_upper_case_globals
6 )]
7 
8 /// <div rustbindgen="true" replaces="whatever"></div>
9 #[repr(C)]
10 #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
11 pub struct whatever {
12     pub replacement: ::std::os::raw::c_int,
13 }
14 #[test]
bindgen_test_layout_whatever()15 fn bindgen_test_layout_whatever() {
16     const UNINIT: ::std::mem::MaybeUninit<whatever> =
17         ::std::mem::MaybeUninit::uninit();
18     let ptr = UNINIT.as_ptr();
19     assert_eq!(
20         ::std::mem::size_of::<whatever>(),
21         4usize,
22         concat!("Size of: ", stringify!(whatever))
23     );
24     assert_eq!(
25         ::std::mem::align_of::<whatever>(),
26         4usize,
27         concat!("Alignment of ", stringify!(whatever))
28     );
29     assert_eq!(
30         unsafe {
31             ::std::ptr::addr_of!((*ptr).replacement) as usize - ptr as usize
32         },
33         0usize,
34         concat!(
35             "Offset of field: ",
36             stringify!(whatever),
37             "::",
38             stringify!(replacement)
39         )
40     );
41 }
42 #[repr(C)]
43 #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
44 pub struct container {
45     pub c: whatever,
46 }
47 #[test]
bindgen_test_layout_container()48 fn bindgen_test_layout_container() {
49     const UNINIT: ::std::mem::MaybeUninit<container> =
50         ::std::mem::MaybeUninit::uninit();
51     let ptr = UNINIT.as_ptr();
52     assert_eq!(
53         ::std::mem::size_of::<container>(),
54         4usize,
55         concat!("Size of: ", stringify!(container))
56     );
57     assert_eq!(
58         ::std::mem::align_of::<container>(),
59         4usize,
60         concat!("Alignment of ", stringify!(container))
61     );
62     assert_eq!(
63         unsafe { ::std::ptr::addr_of!((*ptr).c) as usize - ptr as usize },
64         0usize,
65         concat!(
66             "Offset of field: ",
67             stringify!(container),
68             "::",
69             stringify!(c)
70         )
71     );
72 }
73