summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/expectations/tests/merge-extern-blocks.rs37
-rw-r--r--tests/headers/merge-extern-blocks.h6
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/expectations/tests/merge-extern-blocks.rs b/tests/expectations/tests/merge-extern-blocks.rs
new file mode 100644
index 00000000..66ceeff0
--- /dev/null
+++ b/tests/expectations/tests/merge-extern-blocks.rs
@@ -0,0 +1,37 @@
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct Point {
+ pub x: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_Point() {
+ const UNINIT: ::std::mem::MaybeUninit<Point> =
+ ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
+ assert_eq!(
+ ::std::mem::size_of::<Point>(),
+ 4usize,
+ concat!("Size of: ", stringify!(Point))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<Point>(),
+ 4usize,
+ concat!("Alignment of ", stringify!(Point))
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize },
+ 0usize,
+ concat!("Offset of field: ", stringify!(Point), "::", stringify!(x))
+ );
+}
+extern "C" {
+ pub fn foo() -> ::std::os::raw::c_int;
+ pub fn bar() -> ::std::os::raw::c_int;
+}
diff --git a/tests/headers/merge-extern-blocks.h b/tests/headers/merge-extern-blocks.h
new file mode 100644
index 00000000..1d46b7d4
--- /dev/null
+++ b/tests/headers/merge-extern-blocks.h
@@ -0,0 +1,6 @@
+// bindgen-flags: --merge-extern-blocks -- --target=x86_64-unknown-linux
+int foo();
+typedef struct Point {
+ int x;
+} Point;
+int bar();