@@ -5,16 +5,16 @@ mod bindings {
5
5
}
6
6
7
7
use std:: ffi:: CStr ;
8
- use std:: os:: raw:: c_int;
9
8
use std:: mem;
9
+ use std:: os:: raw:: c_int;
10
10
11
11
#[ allow( unused) ]
12
12
use bindings:: testing:: Bar ; // This type is generated from module_raw_line.
13
13
14
14
#[ test]
15
15
fn test_static_array ( ) {
16
16
let mut test = unsafe { bindings:: Test_COUNTDOWN . as_ptr ( ) } ;
17
- let expected = unsafe { bindings:: Test_countdown ( ) } ;
17
+ let expected = unsafe { bindings:: Test_countdown ( ) } ;
18
18
let also_expected = unsafe { bindings:: Test_COUNTDOWN_PTR } ;
19
19
assert ! ( !test. is_null( ) ) ;
20
20
assert_eq ! ( also_expected, expected) ;
@@ -56,63 +56,41 @@ fn test_overload() {
56
56
57
57
#[ test]
58
58
fn test_bitfields_first ( ) {
59
- let mut first: bindings:: bitfields:: First = unsafe {
60
- mem:: zeroed ( )
61
- } ;
62
- assert ! ( unsafe {
63
- first. assert( 0 , 0 , 0 )
64
- } ) ;
59
+ let mut first: bindings:: bitfields:: First = unsafe { mem:: zeroed ( ) } ;
60
+ assert ! ( unsafe { first. assert( 0 , 0 , 0 ) } ) ;
65
61
first. set_three_bits_byte_one ( 2 ) ;
66
62
first. set_six_bits_byte_two ( 42 ) ;
67
63
first. set_two_bits_byte_two ( 1 ) ;
68
- assert ! ( unsafe {
69
- first. assert( 2 , 42 , 1 )
70
- } ) ;
64
+ assert ! ( unsafe { first. assert( 2 , 42 , 1 ) } ) ;
71
65
}
72
66
73
67
#[ test]
74
68
fn test_bitfields_second ( ) {
75
- let mut second: bindings:: bitfields:: Second = unsafe {
76
- mem:: zeroed ( )
77
- } ;
78
- assert ! ( unsafe {
79
- second. assert( 0 , false )
80
- } ) ;
69
+ let mut second: bindings:: bitfields:: Second = unsafe { mem:: zeroed ( ) } ;
70
+ assert ! ( unsafe { second. assert( 0 , false ) } ) ;
81
71
second. set_thirty_one_bits ( 1337 ) ;
82
72
second. set_one_bit ( true ) ;
83
- assert ! ( unsafe {
84
- second. assert( 1337 , true )
85
- } ) ;
73
+ assert ! ( unsafe { second. assert( 1337 , true ) } ) ;
86
74
}
87
75
88
76
#[ test]
89
77
fn test_bitfields_third ( ) {
90
- let mut third: bindings:: bitfields:: Third = unsafe {
91
- mem:: zeroed ( )
92
- } ;
78
+ let mut third: bindings:: bitfields:: Third = unsafe { mem:: zeroed ( ) } ;
93
79
assert ! ( unsafe {
94
- third. assert( 0 ,
95
- false ,
96
- bindings:: bitfields:: ItemKind :: ITEM_KIND_UNO )
80
+ third. assert( 0 , false , bindings:: bitfields:: ItemKind :: ITEM_KIND_UNO )
97
81
} ) ;
98
82
third. set_flags ( 12345 ) ;
99
83
third. set_is_whatever ( true ) ;
100
84
third. set_kind ( bindings:: bitfields:: ItemKind :: ITEM_KIND_TRES ) ;
101
85
assert ! ( unsafe {
102
- third. assert( 12345 ,
103
- true ,
104
- bindings:: bitfields:: ItemKind :: ITEM_KIND_TRES )
86
+ third. assert( 12345 , true , bindings:: bitfields:: ItemKind :: ITEM_KIND_TRES )
105
87
} ) ;
106
88
}
107
89
108
90
#[ test]
109
91
fn test_bitfields_fourth ( ) {
110
- let mut fourth: bindings:: bitfields:: Fourth = unsafe {
111
- mem:: zeroed ( )
112
- } ;
113
- assert ! ( unsafe {
114
- fourth. assert( bindings:: bitfields:: MyEnum :: ONE , 0 )
115
- } ) ;
92
+ let mut fourth: bindings:: bitfields:: Fourth = unsafe { mem:: zeroed ( ) } ;
93
+ assert ! ( unsafe { fourth. assert( bindings:: bitfields:: MyEnum :: ONE , 0 ) } ) ;
116
94
117
95
fourth. set_tag ( bindings:: bitfields:: MyEnum :: THREE ) ;
118
96
fourth. set_ptr ( 0xdeadbeef ) ;
@@ -123,32 +101,22 @@ fn test_bitfields_fourth() {
123
101
124
102
#[ test]
125
103
fn test_bitfields_date2 ( ) {
126
- let mut date: bindings:: bitfields:: Date2 = unsafe {
127
- mem:: zeroed ( )
128
- } ;
129
- assert ! ( unsafe {
130
- date. assert( 0 , 0 , 0 , 0 , 0 )
131
- } ) ;
104
+ let mut date: bindings:: bitfields:: Date2 = unsafe { mem:: zeroed ( ) } ;
105
+ assert ! ( unsafe { date. assert( 0 , 0 , 0 , 0 , 0 ) } ) ;
132
106
133
107
date. set_nWeekDay ( 6 ) ; // saturdays are the best
134
108
date. set_nMonthDay ( 20 ) ;
135
109
date. set_nMonth ( 11 ) ;
136
110
date. set_nYear ( 95 ) ;
137
111
date. set_byte ( 255 ) ;
138
- assert ! ( unsafe {
139
- date. assert( 6 , 20 , 11 , 95 , 255 )
140
- } ) ;
112
+ assert ! ( unsafe { date. assert( 6 , 20 , 11 , 95 , 255 ) } ) ;
141
113
}
142
114
143
115
#[ test]
144
116
fn test_bitfields_fifth ( ) {
145
- let mut date: bindings:: bitfields:: Fifth = unsafe {
146
- mem:: zeroed ( )
147
- } ;
117
+ let mut date: bindings:: bitfields:: Fifth = unsafe { mem:: zeroed ( ) } ;
148
118
149
- assert ! ( unsafe {
150
- date. assert( 0 , 0 , 0 , 0 , 0 )
151
- } ) ;
119
+ assert ! ( unsafe { date. assert( 0 , 0 , 0 , 0 , 0 ) } ) ;
152
120
153
121
date. byte = 255 ; // Set this first, to ensure we don't override it.
154
122
@@ -157,40 +125,28 @@ fn test_bitfields_fifth() {
157
125
date. set_nMonth ( 11 ) ;
158
126
date. set_nYear ( 95 ) ;
159
127
160
- assert ! ( unsafe {
161
- date. assert( 6 , 20 , 11 , 95 , 255 )
162
- } ) ;
128
+ assert ! ( unsafe { date. assert( 6 , 20 , 11 , 95 , 255 ) } ) ;
163
129
}
164
130
165
131
#[ test]
166
132
fn test_bitfields_sixth ( ) {
167
- let mut date: bindings:: bitfields:: Sixth = unsafe {
168
- mem:: zeroed ( )
169
- } ;
133
+ let mut date: bindings:: bitfields:: Sixth = unsafe { mem:: zeroed ( ) } ;
170
134
171
- assert ! ( unsafe {
172
- date. assert( 0 , 0 , 0 , 0 )
173
- } ) ;
135
+ assert ! ( unsafe { date. assert( 0 , 0 , 0 , 0 ) } ) ;
174
136
175
137
date. byte = 255 ;
176
138
date. set_nWeekDay ( 6 ) ; // saturdays are the best
177
139
date. set_nMonthDay ( 20 ) ;
178
140
date. set_nMonth ( 11 ) ;
179
141
180
- assert ! ( unsafe {
181
- date. assert( 255 , 6 , 11 , 20 )
182
- } ) ;
142
+ assert ! ( unsafe { date. assert( 255 , 6 , 11 , 20 ) } ) ;
183
143
}
184
144
185
145
#[ test]
186
146
fn test_bitfields_seventh ( ) {
187
- let mut large: bindings:: bitfields:: Seventh = unsafe {
188
- mem:: zeroed ( )
189
- } ;
147
+ let mut large: bindings:: bitfields:: Seventh = unsafe { mem:: zeroed ( ) } ;
190
148
191
- assert ! ( unsafe {
192
- large. assert( false , 0 , 0 , 0 , 0 , false , 0 )
193
- } ) ;
149
+ assert ! ( unsafe { large. assert( false , 0 , 0 , 0 , 0 , false , 0 ) } ) ;
194
150
195
151
large. set_first_one_bit ( true ) ;
196
152
large. set_second_thirty_bits ( 375028802 ) ;
@@ -217,32 +173,26 @@ fn test_bitfields_seventh() {
217
173
fn test_bitfield_constructors ( ) {
218
174
use std:: mem;
219
175
let mut first = bindings:: bitfields:: First {
220
- _bitfield_1 : bindings:: bitfields:: First :: new_bitfield_1 ( 1 , 2 , 3 )
176
+ _bitfield_1 : bindings:: bitfields:: First :: new_bitfield_1 ( 1 , 2 , 3 ) ,
221
177
} ;
222
- assert ! ( unsafe {
223
- first. assert( 1 , 2 , 3 )
224
- } ) ;
178
+ assert ! ( unsafe { first. assert( 1 , 2 , 3 ) } ) ;
225
179
226
180
let mut second = bindings:: bitfields:: Second {
227
181
_bitfield_1 : bindings:: bitfields:: Second :: new_bitfield_1 ( 1337 , true ) ,
228
182
__bindgen_align : [ ] ,
229
183
} ;
230
- assert ! ( unsafe {
231
- second. assert( 1337 , true )
232
- } ) ;
184
+ assert ! ( unsafe { second. assert( 1337 , true ) } ) ;
233
185
234
186
let mut third = bindings:: bitfields:: Third {
235
187
_bitfield_1 : bindings:: bitfields:: Third :: new_bitfield_1 (
236
188
42 ,
237
189
false ,
238
- bindings:: bitfields:: ItemKind :: ITEM_KIND_TRES
190
+ bindings:: bitfields:: ItemKind :: ITEM_KIND_TRES ,
239
191
) ,
240
192
__bindgen_align : [ ] ,
241
193
} ;
242
194
assert ! ( unsafe {
243
- third. assert( 42 ,
244
- false ,
245
- bindings:: bitfields:: ItemKind :: ITEM_KIND_TRES )
195
+ third. assert( 42 , false , bindings:: bitfields:: ItemKind :: ITEM_KIND_TRES )
246
196
} ) ;
247
197
}
248
198
@@ -266,7 +216,9 @@ fn test_destructors() {
266
216
267
217
impl Drop for bindings:: InheritsFromVirtualDestructor {
268
218
fn drop ( & mut self ) {
269
- unsafe { bindings:: InheritsFromVirtualDestructor_InheritsFromVirtualDestructor_destructor ( self ) }
219
+ unsafe {
220
+ bindings:: InheritsFromVirtualDestructor_InheritsFromVirtualDestructor_destructor ( self )
221
+ }
270
222
}
271
223
}
272
224
@@ -286,9 +238,9 @@ fn test_virtual_dtor() {
286
238
#[ test]
287
239
fn test_item_rename ( ) {
288
240
assert_eq ! ( bindings:: CONST_VALUE , 3 ) ;
289
- assert_eq ! ( unsafe { bindings:: function_name( ) } , 4 ) ;
241
+ assert_eq ! ( unsafe { bindings:: function_name( ) } , 4 ) ;
290
242
291
- let _foo = bindings:: foo {
292
- member : bindings:: bar { foo : 2 }
243
+ let _foo = bindings:: foo {
244
+ member : bindings:: bar { foo : 2 } ,
293
245
} ;
294
- }
246
+ }
0 commit comments