diff options
author | Kornel Lesiński <kornel@geekhood.net> | 2017-02-15 17:17:24 +0000 |
---|---|---|
committer | Kornel Lesiński <kornel@geekhood.net> | 2017-02-15 18:36:10 +0000 |
commit | fd70398e7b6e315fed9500beb5e726bb3108eb0d (patch) | |
tree | aa4d4123c802bbf265ec9ebc723f3de2aa3305e7 | |
parent | 06268ebcc0bc20330e4985b6d765c2976124e60d (diff) |
Test typedefed anon structs in C++
-rw-r--r-- | tests/expectations/tests/struct_typedef_ns.rs | 79 | ||||
-rw-r--r-- | tests/headers/struct_typedef_ns.hpp | 21 |
2 files changed, 100 insertions, 0 deletions
diff --git a/tests/expectations/tests/struct_typedef_ns.rs b/tests/expectations/tests/struct_typedef_ns.rs new file mode 100644 index 00000000..d7ada7fd --- /dev/null +++ b/tests/expectations/tests/struct_typedef_ns.rs @@ -0,0 +1,79 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +pub mod root { + #[allow(unused_imports)] + use self::super::root; + pub mod whatever { + #[allow(unused_imports)] + use self::super::super::root; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct _bindgen_ty_1 { + pub foo: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize , + concat ! ( "Size of: " , stringify ! ( _bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . foo as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) + , "::" , stringify ! ( foo ) )); + } + impl Clone for _bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + pub type typedef_struct = root::whatever::_bindgen_ty_1; + pub const whatever_BAR: root::whatever::_bindgen_ty_2 = + _bindgen_ty_2::BAR; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_2 { BAR = 1, } + pub use self::super::super::root::whatever::_bindgen_ty_2 as + typedef_enum; + } + pub mod _bindgen_mod_id_12 { + #[allow(unused_imports)] + use self::super::super::root; + #[repr(C)] + #[derive(Debug, Default, Copy)] + pub struct _bindgen_ty_1 { + pub foo: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize , + concat ! ( "Size of: " , stringify ! ( _bindgen_ty_1 ) + )); + assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 4usize , + concat ! ( + "Alignment of " , stringify ! ( _bindgen_ty_1 ) )); + assert_eq! (unsafe { + & ( * ( 0 as * const _bindgen_ty_1 ) ) . foo as * + const _ as usize } , 0usize , concat ! ( + "Alignment of field: " , stringify ! ( _bindgen_ty_1 ) + , "::" , stringify ! ( foo ) )); + } + impl Clone for _bindgen_ty_1 { + fn clone(&self) -> Self { *self } + } + pub type typedef_struct = root::_bindgen_mod_id_12::_bindgen_ty_1; + pub const _bindgen_mod_id_12_BAR: + root::_bindgen_mod_id_12::_bindgen_ty_2 = + _bindgen_ty_2::BAR; + #[repr(u32)] + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_2 { BAR = 1, } + pub use self::super::super::root::_bindgen_mod_id_12::_bindgen_ty_2 as + typedef_enum; + } +} diff --git a/tests/headers/struct_typedef_ns.hpp b/tests/headers/struct_typedef_ns.hpp new file mode 100644 index 00000000..bc89eb2b --- /dev/null +++ b/tests/headers/struct_typedef_ns.hpp @@ -0,0 +1,21 @@ +// bindgen-flags: --enable-cxx-namespaces + +namespace whatever { + typedef struct { + int foo; + } typedef_struct; + + typedef enum { + BAR=1 + } typedef_enum; +} + +namespace { + typedef struct { + int foo; + } typedef_struct; + + typedef enum { + BAR=1 + } typedef_enum; +} |