summaryrefslogtreecommitdiff
path: root/libbindgen/tests
diff options
context:
space:
mode:
Diffstat (limited to 'libbindgen/tests')
-rw-r--r--libbindgen/tests/expectations/tests/anon_union.rs14
-rw-r--r--libbindgen/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs20
-rw-r--r--libbindgen/tests/expectations/tests/crtp.rs24
-rw-r--r--libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs10
-rw-r--r--libbindgen/tests/expectations/tests/forward-inherit-struct.rs4
-rw-r--r--libbindgen/tests/expectations/tests/issue-358.rs20
-rw-r--r--libbindgen/tests/expectations/tests/vtable_recursive_sig.rs26
-rw-r--r--libbindgen/tests/headers/bad-namespace-parenthood-inheritance.hpp15
-rw-r--r--libbindgen/tests/headers/issue-358.hpp8
9 files changed, 102 insertions, 39 deletions
diff --git a/libbindgen/tests/expectations/tests/anon_union.rs b/libbindgen/tests/expectations/tests/anon_union.rs
index 8ae92b31..f8559ca9 100644
--- a/libbindgen/tests/expectations/tests/anon_union.rs
+++ b/libbindgen/tests/expectations/tests/anon_union.rs
@@ -62,13 +62,6 @@ pub struct TErrorResult__bindgen_ty_1<T> {
pub bindgen_union_field: u64,
pub _phantom_0: ::std::marker::PhantomData<T>,
}
-#[test]
-fn __bindgen_test_layout_template_1() {
- assert_eq!(::std::mem::size_of::<TErrorResult<::std::os::raw::c_int>>() ,
- 24usize);
- assert_eq!(::std::mem::align_of::<TErrorResult<::std::os::raw::c_int>>() ,
- 8usize);
-}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct ErrorResult {
@@ -82,3 +75,10 @@ fn bindgen_test_layout_ErrorResult() {
impl Clone for ErrorResult {
fn clone(&self) -> Self { *self }
}
+#[test]
+fn __bindgen_test_layout_template_1() {
+ assert_eq!(::std::mem::size_of::<TErrorResult<::std::os::raw::c_int>>() ,
+ 24usize);
+ assert_eq!(::std::mem::align_of::<TErrorResult<::std::os::raw::c_int>>() ,
+ 8usize);
+}
diff --git a/libbindgen/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs b/libbindgen/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs
new file mode 100644
index 00000000..553879b7
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/bad-namespace-parenthood-inheritance.rs
@@ -0,0 +1,20 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct std_char_traits<_CharT> {
+ pub _address: u8,
+ pub _phantom_0: ::std::marker::PhantomData<_CharT>,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct __gnu_cxx_char_traits {
+ pub _address: u8,
+}
+impl Clone for __gnu_cxx_char_traits {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/crtp.rs b/libbindgen/tests/expectations/tests/crtp.rs
index 109a768a..cc488fd6 100644
--- a/libbindgen/tests/expectations/tests/crtp.rs
+++ b/libbindgen/tests/expectations/tests/crtp.rs
@@ -10,11 +10,6 @@ pub struct Base<T> {
pub _address: u8,
pub _phantom_0: ::std::marker::PhantomData<T>,
}
-#[test]
-fn __bindgen_test_layout_template_1() {
- assert_eq!(::std::mem::size_of::<Base<Derived>>() , 1usize);
- assert_eq!(::std::mem::align_of::<Base<Derived>>() , 1usize);
-}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Derived {
@@ -34,13 +29,6 @@ pub struct BaseWithDestructor<T> {
pub _address: u8,
pub _phantom_0: ::std::marker::PhantomData<T>,
}
-#[test]
-fn __bindgen_test_layout_template_2() {
- assert_eq!(::std::mem::size_of::<BaseWithDestructor<DerivedFromBaseWithDestructor>>()
- , 1usize);
- assert_eq!(::std::mem::align_of::<BaseWithDestructor<DerivedFromBaseWithDestructor>>()
- , 1usize);
-}
#[repr(C)]
#[derive(Debug)]
pub struct DerivedFromBaseWithDestructor {
@@ -53,3 +41,15 @@ fn bindgen_test_layout_DerivedFromBaseWithDestructor() {
assert_eq!(::std::mem::align_of::<DerivedFromBaseWithDestructor>() ,
1usize);
}
+#[test]
+fn __bindgen_test_layout_template_1() {
+ assert_eq!(::std::mem::size_of::<Base<Derived>>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Base<Derived>>() , 1usize);
+}
+#[test]
+fn __bindgen_test_layout_template_2() {
+ assert_eq!(::std::mem::size_of::<BaseWithDestructor<DerivedFromBaseWithDestructor>>()
+ , 1usize);
+ assert_eq!(::std::mem::align_of::<BaseWithDestructor<DerivedFromBaseWithDestructor>>()
+ , 1usize);
+}
diff --git a/libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs b/libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs
index fc24e989..e377b3ad 100644
--- a/libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs
+++ b/libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs
@@ -6,12 +6,12 @@
#[repr(C)]
#[derive(Debug, Copy, Clone)]
-pub struct RootedBase<T> {
- pub foo: *mut T,
- pub next: *mut Rooted<T>,
+pub struct Rooted<T> {
+ pub _base: js_RootedBase<T>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
-pub struct Rooted<T> {
- pub _base: RootedBase<T>,
+pub struct js_RootedBase<T> {
+ pub foo: *mut T,
+ pub next: *mut Rooted<T>,
}
diff --git a/libbindgen/tests/expectations/tests/forward-inherit-struct.rs b/libbindgen/tests/expectations/tests/forward-inherit-struct.rs
index a58058b0..5de70fa9 100644
--- a/libbindgen/tests/expectations/tests/forward-inherit-struct.rs
+++ b/libbindgen/tests/expectations/tests/forward-inherit-struct.rs
@@ -6,13 +6,13 @@
#[repr(C)]
#[derive(Debug, Copy, Clone)]
-pub struct RootedBase<T> {
+pub struct Rooted<T> {
pub _address: u8,
pub _phantom_0: ::std::marker::PhantomData<T>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
-pub struct Rooted<T> {
+pub struct js_RootedBase<T> {
pub _address: u8,
pub _phantom_0: ::std::marker::PhantomData<T>,
}
diff --git a/libbindgen/tests/expectations/tests/issue-358.rs b/libbindgen/tests/expectations/tests/issue-358.rs
new file mode 100644
index 00000000..1b933d34
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/issue-358.rs
@@ -0,0 +1,20 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct JS_PersistentRooted<c> {
+ pub _base: a,
+ pub _phantom_0: ::std::marker::PhantomData<c>,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct a {
+ pub b: *mut a,
+}
+impl Clone for a {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/expectations/tests/vtable_recursive_sig.rs b/libbindgen/tests/expectations/tests/vtable_recursive_sig.rs
index 77312336..ce62eeb0 100644
--- a/libbindgen/tests/expectations/tests/vtable_recursive_sig.rs
+++ b/libbindgen/tests/expectations/tests/vtable_recursive_sig.rs
@@ -5,6 +5,19 @@
#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Derived {
+ pub _base: Base,
+}
+#[test]
+fn bindgen_test_layout_Derived() {
+ assert_eq!(::std::mem::size_of::<Derived>() , 8usize);
+ assert_eq!(::std::mem::align_of::<Derived>() , 8usize);
+}
+impl Clone for Derived {
+ fn clone(&self) -> Self { *self }
+}
+#[repr(C)]
pub struct Base__bindgen_vtable {
}
#[repr(C)]
@@ -20,16 +33,3 @@ fn bindgen_test_layout_Base() {
impl Clone for Base {
fn clone(&self) -> Self { *self }
}
-#[repr(C)]
-#[derive(Debug, Copy)]
-pub struct Derived {
- pub _base: Base,
-}
-#[test]
-fn bindgen_test_layout_Derived() {
- assert_eq!(::std::mem::size_of::<Derived>() , 8usize);
- assert_eq!(::std::mem::align_of::<Derived>() , 8usize);
-}
-impl Clone for Derived {
- fn clone(&self) -> Self { *self }
-}
diff --git a/libbindgen/tests/headers/bad-namespace-parenthood-inheritance.hpp b/libbindgen/tests/headers/bad-namespace-parenthood-inheritance.hpp
new file mode 100644
index 00000000..ce21a401
--- /dev/null
+++ b/libbindgen/tests/headers/bad-namespace-parenthood-inheritance.hpp
@@ -0,0 +1,15 @@
+namespace std
+{
+ template < typename > struct char_traits;
+}
+namespace __gnu_cxx
+{
+ template < typename > struct char_traits;
+}
+namespace std
+{
+ template < class _CharT > struct char_traits:__gnu_cxx::char_traits <
+ _CharT >
+ {
+ };
+}
diff --git a/libbindgen/tests/headers/issue-358.hpp b/libbindgen/tests/headers/issue-358.hpp
new file mode 100644
index 00000000..b14521b7
--- /dev/null
+++ b/libbindgen/tests/headers/issue-358.hpp
@@ -0,0 +1,8 @@
+// bindgen-flags: -- -std=c++11
+namespace JS {
+template <typename> class PersistentRooted;
+}
+template <typename> class a { a *b; };
+namespace JS {
+template <typename c> class PersistentRooted : a<PersistentRooted<c>> {};
+}