Skip to content

Commit 3edb811

Browse files
author
Zhiting Zhu
committed
Misc tests for derive Hash
1 parent e967d18 commit 3edb811

File tree

10 files changed

+39
-22
lines changed

10 files changed

+39
-22
lines changed

tests/expectations/tests/16-byte-alignment.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,25 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
2828
fmt.write_str("__BindgenUnionField")
2929
}
3030
}
31+
impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
32+
fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
33+
}
3134
#[repr(C)]
32-
#[derive(Debug, Default, Copy)]
35+
#[derive(Debug, Default, Copy, Hash)]
3336
pub struct rte_ipv4_tuple {
3437
pub src_addr: u32,
3538
pub dst_addr: u32,
3639
pub __bindgen_anon_1: rte_ipv4_tuple__bindgen_ty_1,
3740
}
3841
#[repr(C)]
39-
#[derive(Debug, Default, Copy)]
42+
#[derive(Debug, Default, Copy, Hash)]
4043
pub struct rte_ipv4_tuple__bindgen_ty_1 {
4144
pub __bindgen_anon_1: __BindgenUnionField<rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1>,
4245
pub sctp_tag: __BindgenUnionField<u32>,
4346
pub bindgen_union_field: u32,
4447
}
4548
#[repr(C)]
46-
#[derive(Debug, Default, Copy)]
49+
#[derive(Debug, Default, Copy, Hash)]
4750
pub struct rte_ipv4_tuple__bindgen_ty_1__bindgen_ty_1 {
4851
pub dport: u16,
4952
pub sport: u16,
@@ -116,21 +119,21 @@ impl Clone for rte_ipv4_tuple {
116119
fn clone(&self) -> Self { *self }
117120
}
118121
#[repr(C)]
119-
#[derive(Debug, Default, Copy)]
122+
#[derive(Debug, Default, Copy, Hash)]
120123
pub struct rte_ipv6_tuple {
121124
pub src_addr: [u8; 16usize],
122125
pub dst_addr: [u8; 16usize],
123126
pub __bindgen_anon_1: rte_ipv6_tuple__bindgen_ty_1,
124127
}
125128
#[repr(C)]
126-
#[derive(Debug, Default, Copy)]
129+
#[derive(Debug, Default, Copy, Hash)]
127130
pub struct rte_ipv6_tuple__bindgen_ty_1 {
128131
pub __bindgen_anon_1: __BindgenUnionField<rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1>,
129132
pub sctp_tag: __BindgenUnionField<u32>,
130133
pub bindgen_union_field: u32,
131134
}
132135
#[repr(C)]
133-
#[derive(Debug, Default, Copy)]
136+
#[derive(Debug, Default, Copy, Hash)]
134137
pub struct rte_ipv6_tuple__bindgen_ty_1__bindgen_ty_1 {
135138
pub dport: u16,
136139
pub sport: u16,

tests/expectations/tests/char.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub type Char = ::std::os::raw::c_char;
88
pub type SChar = ::std::os::raw::c_schar;
99
pub type UChar = ::std::os::raw::c_uchar;
1010
#[repr(C)]
11-
#[derive(Debug, Default, Copy)]
11+
#[derive(Debug, Default, Copy, Hash)]
1212
pub struct Test {
1313
pub ch: ::std::os::raw::c_char,
1414
pub u: ::std::os::raw::c_uchar,

tests/expectations/tests/issue-493.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
2828
fmt.write_str("__BindgenUnionField")
2929
}
3030
}
31+
impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
32+
fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
33+
}
3134
#[repr(C)]
32-
#[derive(Debug, Default, Copy, Clone)]
35+
#[derive(Debug, Default, Copy, Clone, Hash)]
3336
pub struct basic_string {
3437
pub _address: u8,
3538
}
3639
pub type basic_string_size_type = ::std::os::raw::c_ulonglong;
3740
pub type basic_string_value_type = ::std::os::raw::c_char;
3841
pub type basic_string_pointer = *mut basic_string_value_type;
3942
#[repr(C)]
40-
#[derive(Debug, Copy, Clone)]
43+
#[derive(Debug, Copy, Clone, Hash)]
4144
pub struct basic_string___long {
4245
pub __cap_: basic_string_size_type,
4346
pub __size_: basic_string_size_type,
@@ -52,13 +55,13 @@ pub const basic_string___min_cap: basic_string__bindgen_ty_1 =
5255
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
5356
pub enum basic_string__bindgen_ty_1 { __min_cap = 0, }
5457
#[repr(C)]
55-
#[derive(Debug, Copy, Clone)]
58+
#[derive(Debug, Copy, Clone, Hash)]
5659
pub struct basic_string___short {
5760
pub __bindgen_anon_1: basic_string___short__bindgen_ty_1,
5861
pub __data_: *mut basic_string_value_type,
5962
}
6063
#[repr(C)]
61-
#[derive(Debug, Default, Copy, Clone)]
64+
#[derive(Debug, Default, Copy, Clone, Hash)]
6265
pub struct basic_string___short__bindgen_ty_1 {
6366
pub __size_: __BindgenUnionField<::std::os::raw::c_uchar>,
6467
pub __lx: __BindgenUnionField<basic_string_value_type>,
@@ -83,7 +86,7 @@ pub const basic_string___n_words: basic_string__bindgen_ty_2 =
8386
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
8487
pub enum basic_string__bindgen_ty_2 { __n_words = 0, }
8588
#[repr(C)]
86-
#[derive(Debug, Copy, Clone)]
89+
#[derive(Debug, Copy, Clone, Hash)]
8790
pub struct basic_string___raw {
8891
pub __words: *mut basic_string_size_type,
8992
}

tests/expectations/tests/typeref.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
2828
fmt.write_str("__BindgenUnionField")
2929
}
3030
}
31+
impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
32+
fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
33+
}
3134
#[repr(C)]
32-
#[derive(Debug, Default, Copy)]
35+
#[derive(Debug, Default, Copy, Hash)]
3336
pub struct nsFoo {
3437
pub mBar: mozilla_StyleShapeSource,
3538
}
@@ -49,7 +52,7 @@ impl Clone for nsFoo {
4952
fn clone(&self) -> Self { *self }
5053
}
5154
#[repr(C)]
52-
#[derive(Debug, Default, Copy)]
55+
#[derive(Debug, Default, Copy, Hash)]
5356
pub struct mozilla_FragmentOrURL {
5457
pub mIsLocalRef: bool,
5558
}
@@ -71,7 +74,7 @@ impl Clone for mozilla_FragmentOrURL {
7174
fn clone(&self) -> Self { *self }
7275
}
7376
#[repr(C)]
74-
#[derive(Debug, Default, Copy)]
77+
#[derive(Debug, Default, Copy, Hash)]
7578
pub struct mozilla_Position {
7679
pub _address: u8,
7780
}
@@ -86,19 +89,19 @@ impl Clone for mozilla_Position {
8689
fn clone(&self) -> Self { *self }
8790
}
8891
#[repr(C)]
89-
#[derive(Debug, Default, Copy, Clone)]
92+
#[derive(Debug, Default, Copy, Clone, Hash)]
9093
pub struct mozilla_StyleShapeSource {
9194
pub __bindgen_anon_1: mozilla_StyleShapeSource__bindgen_ty_1,
9295
}
9396
#[repr(C)]
94-
#[derive(Debug, Default, Copy, Clone)]
97+
#[derive(Debug, Default, Copy, Clone, Hash)]
9598
pub struct mozilla_StyleShapeSource__bindgen_ty_1 {
9699
pub mPosition: __BindgenUnionField<*mut mozilla_Position>,
97100
pub mFragmentOrURL: __BindgenUnionField<*mut mozilla_FragmentOrURL>,
98101
pub bindgen_union_field: u64,
99102
}
100103
#[repr(C)]
101-
#[derive(Debug, Copy)]
104+
#[derive(Debug, Copy, Hash)]
102105
pub struct Bar {
103106
pub mFoo: *mut nsFoo,
104107
}

tests/expectations/tests/use-core.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ impl <T> ::core::fmt::Debug for __BindgenUnionField<T> {
2929
fmt.write_str("__BindgenUnionField")
3030
}
3131
}
32+
impl <T> ::core::hash::Hash for __BindgenUnionField<T> {
33+
fn hash<H: ::core::hash::Hasher>(&self, _state: &mut H) { }
34+
}
3235
#[repr(C)]
33-
#[derive(Debug, Copy)]
36+
#[derive(Debug, Copy, Hash)]
3437
pub struct foo {
3538
pub a: ::std::os::raw::c_int,
3639
pub b: ::std::os::raw::c_int,
@@ -65,7 +68,7 @@ impl Default for foo {
6568
fn default() -> Self { unsafe { ::core::mem::zeroed() } }
6669
}
6770
#[repr(C)]
68-
#[derive(Debug, Default, Copy)]
71+
#[derive(Debug, Default, Copy, Hash)]
6972
pub struct _bindgen_ty_1 {
7073
pub bar: __BindgenUnionField<::std::os::raw::c_int>,
7174
pub baz: __BindgenUnionField<::std::os::raw::c_long>,

tests/headers/16-byte-alignment.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// bindgen-flags: --with-derive-hash
12

23
typedef unsigned char uint8_t;
34
typedef unsigned short uint16_t;

tests/headers/char.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// bindgen-flags: --with-derive-hash
2+
//
13
typedef char Char;
24
typedef signed char SChar;
35
typedef unsigned char UChar;

tests/headers/issue-493.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// bindgen-flags: --with-derive-hash
12
template<class _CharT, class _Traits, class _Allocator>
23
class basic_string
34
{
@@ -44,4 +45,4 @@ class basic_string
4445
__raw __r;
4546
};
4647
};
47-
};
48+
};

tests/headers/typeref.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// bindgen-flags: --with-derive-hash
12
struct nsFoo;
23

34
namespace mozilla {

tests/headers/use-core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// bindgen-flags: --use-core --raw-line "extern crate core;"
1+
// bindgen-flags: --use-core --raw-line "extern crate core;" --with-derive-hash
22

33
struct foo {
44
int a, b;

0 commit comments

Comments
 (0)