@@ -68,155 +68,72 @@ mod public_imp {
68
68
69
69
#[ allow( unused_variables) ] // nothing to do if not SIMD implementation is available
70
70
pub ( super ) fn test_valid ( input : & [ u8 ] ) {
71
- if cfg ! ( any( target_arch = "x86" , target_arch = "x86_64" ) ) {
72
- #[ cfg( target_feature = "avx2" ) ]
73
- unsafe {
74
- assert ! ( simdutf8:: basic:: imp:: x86:: avx2:: validate_utf8( input) . is_ok( ) ) ;
75
- assert ! ( simdutf8:: compat:: imp:: x86:: avx2:: validate_utf8( input) . is_ok( ) ) ;
76
-
77
- test_streaming :: < simdutf8:: basic:: imp:: x86:: avx2:: Utf8ValidatorImp > ( input, true ) ;
78
- test_chunked_streaming :: < simdutf8:: basic:: imp:: x86:: avx2:: ChunkedUtf8ValidatorImp > (
79
- input, true ,
80
- ) ;
81
- }
82
-
83
- #[ cfg( target_feature = "sse4.2" ) ]
84
- unsafe {
85
- assert ! ( simdutf8:: basic:: imp:: x86:: sse42:: validate_utf8( input) . is_ok( ) ) ;
86
- assert ! ( simdutf8:: compat:: imp:: x86:: sse42:: validate_utf8( input) . is_ok( ) ) ;
87
-
88
- test_streaming :: < simdutf8:: basic:: imp:: x86:: sse42:: Utf8ValidatorImp > ( input, true ) ;
89
- test_chunked_streaming :: < simdutf8:: basic:: imp:: x86:: sse42:: ChunkedUtf8ValidatorImp > (
90
- input, true ,
91
- ) ;
92
- }
93
- }
94
- #[ cfg( all( target_arch = "aarch64" , target_feature = "neon" ) ) ]
71
+ #[ cfg( feature = "public_imp" ) ]
95
72
unsafe {
96
- assert ! ( simdutf8:: basic:: imp:: aarch64:: neon:: validate_utf8( input) . is_ok( ) ) ;
97
- assert ! ( simdutf8:: compat:: imp:: aarch64:: neon:: validate_utf8( input) . is_ok( ) ) ;
98
-
99
- test_streaming :: < simdutf8:: basic:: imp:: aarch64:: neon:: Utf8ValidatorImp > ( input, true ) ;
100
- test_chunked_streaming :: < simdutf8:: basic:: imp:: aarch64:: neon:: ChunkedUtf8ValidatorImp > (
101
- input, true ,
73
+ assert ! ( simdutf8_portable:: basic:: imp:: portable:: simd128:: validate_utf8( input) . is_ok( ) ) ;
74
+ assert ! (
75
+ simdutf8_portable:: compat:: imp:: portable:: simd128:: validate_utf8( input) . is_ok( )
102
76
) ;
103
- }
104
- #[ cfg( all( target_arch = "wasm32" , target_feature = "simd128" ) ) ]
105
- unsafe {
106
- assert ! ( simdutf8:: basic:: imp:: wasm32:: simd128:: validate_utf8( input) . is_ok( ) ) ;
107
- assert ! ( simdutf8:: compat:: imp:: wasm32:: simd128:: validate_utf8( input) . is_ok( ) ) ;
108
77
109
- test_streaming :: < simdutf8:: basic:: imp:: wasm32:: simd128:: Utf8ValidatorImp > ( input, true ) ;
110
- test_chunked_streaming :: < simdutf8:: basic:: imp:: wasm32:: simd128:: ChunkedUtf8ValidatorImp > (
111
- input, true ,
112
- ) ;
113
- }
114
- #[ cfg( feature = "portable_public_imp" ) ]
115
- unsafe {
116
- assert ! ( simdutf8:: basic:: imp:: portable:: simd128:: validate_utf8( input) . is_ok( ) ) ;
117
- assert ! ( simdutf8:: compat:: imp:: portable:: simd128:: validate_utf8( input) . is_ok( ) ) ;
118
-
119
- test_streaming :: < simdutf8:: basic:: imp:: portable:: simd128:: Utf8ValidatorImp > (
78
+ test_streaming :: < simdutf8_portable:: basic:: imp:: portable:: simd128:: Utf8ValidatorImp > (
120
79
input, true ,
121
80
) ;
122
81
test_chunked_streaming :: <
123
- simdutf8 :: basic:: imp:: portable:: simd128:: ChunkedUtf8ValidatorImp ,
82
+ simdutf8_portable :: basic:: imp:: portable:: simd128:: ChunkedUtf8ValidatorImp ,
124
83
> ( input, true ) ;
125
84
126
- assert ! ( simdutf8:: basic:: imp:: portable:: simd256:: validate_utf8( input) . is_ok( ) ) ;
127
- assert ! ( simdutf8:: compat:: imp:: portable:: simd256:: validate_utf8( input) . is_ok( ) ) ;
85
+ assert ! ( simdutf8_portable:: basic:: imp:: portable:: simd256:: validate_utf8( input) . is_ok( ) ) ;
86
+ assert ! (
87
+ simdutf8_portable:: compat:: imp:: portable:: simd256:: validate_utf8( input) . is_ok( )
88
+ ) ;
128
89
129
- test_streaming :: < simdutf8 :: basic:: imp:: portable:: simd256:: Utf8ValidatorImp > (
90
+ test_streaming :: < simdutf8_portable :: basic:: imp:: portable:: simd256:: Utf8ValidatorImp > (
130
91
input, true ,
131
92
) ;
132
93
test_chunked_streaming :: <
133
- simdutf8 :: basic:: imp:: portable:: simd256:: ChunkedUtf8ValidatorImp ,
94
+ simdutf8_portable :: basic:: imp:: portable:: simd256:: ChunkedUtf8ValidatorImp ,
134
95
> ( input, true ) ;
135
96
}
136
97
}
137
98
138
99
#[ allow( unused_variables) ] // nothing to do if not SIMD implementation is available
139
100
pub ( super ) fn test_invalid ( input : & [ u8 ] , valid_up_to : usize , error_len : Option < usize > ) {
140
- if cfg ! ( any( target_arch = "x86" , target_arch = "x86_64" ) ) {
141
- #[ cfg( target_feature = "avx2" ) ]
142
- unsafe {
143
- assert ! ( simdutf8:: basic:: imp:: x86:: avx2:: validate_utf8( input) . is_err( ) ) ;
144
- let err = simdutf8:: compat:: imp:: x86:: avx2:: validate_utf8 ( input) . unwrap_err ( ) ;
145
- assert_eq ! ( err. valid_up_to( ) , valid_up_to) ;
146
- assert_eq ! ( err. error_len( ) , error_len) ;
147
-
148
- test_streaming :: < simdutf8:: basic:: imp:: x86:: avx2:: Utf8ValidatorImp > ( input, false ) ;
149
- test_chunked_streaming :: < simdutf8:: basic:: imp:: x86:: avx2:: ChunkedUtf8ValidatorImp > (
150
- input, false ,
151
- ) ;
152
- }
153
- #[ cfg( target_feature = "sse4.2" ) ]
154
- unsafe {
155
- assert ! ( simdutf8:: basic:: imp:: x86:: sse42:: validate_utf8( input) . is_err( ) ) ;
156
- let err = simdutf8:: compat:: imp:: x86:: sse42:: validate_utf8 ( input) . unwrap_err ( ) ;
157
- assert_eq ! ( err. valid_up_to( ) , valid_up_to) ;
158
- assert_eq ! ( err. error_len( ) , error_len) ;
159
-
160
- test_streaming :: < simdutf8:: basic:: imp:: x86:: sse42:: Utf8ValidatorImp > ( input, false ) ;
161
- test_chunked_streaming :: < simdutf8:: basic:: imp:: x86:: sse42:: ChunkedUtf8ValidatorImp > (
162
- input, false ,
163
- ) ;
164
- }
165
- }
166
- #[ cfg( all( target_arch = "aarch64" , target_feature = "neon" ) ) ]
167
- unsafe {
168
- assert ! ( simdutf8:: basic:: imp:: aarch64:: neon:: validate_utf8( input) . is_err( ) ) ;
169
- let err = simdutf8:: compat:: imp:: aarch64:: neon:: validate_utf8 ( input) . unwrap_err ( ) ;
170
- assert_eq ! ( err. valid_up_to( ) , valid_up_to) ;
171
- assert_eq ! ( err. error_len( ) , error_len) ;
172
-
173
- test_streaming :: < simdutf8:: basic:: imp:: aarch64:: neon:: Utf8ValidatorImp > ( input, false ) ;
174
- test_chunked_streaming :: < simdutf8:: basic:: imp:: aarch64:: neon:: ChunkedUtf8ValidatorImp > (
175
- input, false ,
176
- ) ;
177
- }
178
- #[ cfg( all( target_arch = "wasm32" , target_feature = "simd128" ) ) ]
101
+ #[ cfg( feature = "public_imp" ) ]
179
102
unsafe {
180
- assert ! ( simdutf8:: basic:: imp:: wasm32:: simd128:: validate_utf8( input) . is_err( ) ) ;
181
- let err = simdutf8:: compat:: imp:: wasm32:: simd128:: validate_utf8 ( input) . unwrap_err ( ) ;
182
- assert_eq ! ( err. valid_up_to( ) , valid_up_to) ;
183
- assert_eq ! ( err. error_len( ) , error_len) ;
184
-
185
- test_streaming :: < simdutf8:: basic:: imp:: wasm32:: simd128:: Utf8ValidatorImp > ( input, false ) ;
186
- test_chunked_streaming :: < simdutf8:: basic:: imp:: wasm32:: simd128:: ChunkedUtf8ValidatorImp > (
187
- input, false ,
103
+ assert ! (
104
+ simdutf8_portable:: basic:: imp:: portable:: simd128:: validate_utf8( input) . is_err( )
188
105
) ;
189
- }
190
- #[ cfg( feature = "portable_public_imp" ) ]
191
- unsafe {
192
- assert ! ( simdutf8:: basic:: imp:: portable:: simd128:: validate_utf8( input) . is_err( ) ) ;
193
- let err = simdutf8:: compat:: imp:: portable:: simd128:: validate_utf8 ( input) . unwrap_err ( ) ;
106
+ let err = simdutf8_portable:: compat:: imp:: portable:: simd128:: validate_utf8 ( input)
107
+ . unwrap_err ( ) ;
194
108
assert_eq ! ( err. valid_up_to( ) , valid_up_to) ;
195
109
assert_eq ! ( err. error_len( ) , error_len) ;
196
110
197
- test_streaming :: < simdutf8 :: basic:: imp:: portable:: simd128:: Utf8ValidatorImp > (
111
+ test_streaming :: < simdutf8_portable :: basic:: imp:: portable:: simd128:: Utf8ValidatorImp > (
198
112
input, false ,
199
113
) ;
200
114
test_chunked_streaming :: <
201
- simdutf8 :: basic:: imp:: portable:: simd128:: ChunkedUtf8ValidatorImp ,
115
+ simdutf8_portable :: basic:: imp:: portable:: simd128:: ChunkedUtf8ValidatorImp ,
202
116
> ( input, false ) ;
203
117
204
- assert ! ( simdutf8:: basic:: imp:: portable:: simd256:: validate_utf8( input) . is_err( ) ) ;
205
- let err = simdutf8:: compat:: imp:: portable:: simd256:: validate_utf8 ( input) . unwrap_err ( ) ;
118
+ assert ! (
119
+ simdutf8_portable:: basic:: imp:: portable:: simd256:: validate_utf8( input) . is_err( )
120
+ ) ;
121
+ let err = simdutf8_portable:: compat:: imp:: portable:: simd256:: validate_utf8 ( input)
122
+ . unwrap_err ( ) ;
206
123
assert_eq ! ( err. valid_up_to( ) , valid_up_to) ;
207
124
assert_eq ! ( err. error_len( ) , error_len) ;
208
125
209
- test_streaming :: < simdutf8 :: basic:: imp:: portable:: simd256:: Utf8ValidatorImp > (
126
+ test_streaming :: < simdutf8_portable :: basic:: imp:: portable:: simd256:: Utf8ValidatorImp > (
210
127
input, false ,
211
128
) ;
212
129
test_chunked_streaming :: <
213
- simdutf8 :: basic:: imp:: portable:: simd256:: ChunkedUtf8ValidatorImp ,
130
+ simdutf8_portable :: basic:: imp:: portable:: simd256:: ChunkedUtf8ValidatorImp ,
214
131
> ( input, false ) ;
215
132
}
216
133
}
217
134
218
135
#[ allow( unused) ] // not used if not SIMD implementation is available
219
- fn test_streaming < T : simdutf8 :: basic:: imp:: Utf8Validator > ( input : & [ u8 ] , ok : bool ) {
136
+ fn test_streaming < T : simdutf8_portable :: basic:: imp:: Utf8Validator > ( input : & [ u8 ] , ok : bool ) {
220
137
unsafe {
221
138
let mut validator = T :: new ( ) ;
222
139
validator. update ( input) ;
@@ -228,7 +145,7 @@ mod public_imp {
228
145
}
229
146
230
147
#[ allow( unused) ] // not used if not SIMD implementation is available
231
- fn test_streaming_blocks < T : simdutf8 :: basic:: imp:: Utf8Validator > (
148
+ fn test_streaming_blocks < T : simdutf8_portable :: basic:: imp:: Utf8Validator > (
232
149
input : & [ u8 ] ,
233
150
block_size : usize ,
234
151
ok : bool ,
@@ -243,7 +160,7 @@ mod public_imp {
243
160
}
244
161
245
162
#[ allow( unused) ] // not used if not SIMD implementation is available
246
- fn test_chunked_streaming < T : simdutf8 :: basic:: imp:: ChunkedUtf8Validator > (
163
+ fn test_chunked_streaming < T : simdutf8_portable :: basic:: imp:: ChunkedUtf8Validator > (
247
164
input : & [ u8 ] ,
248
165
ok : bool ,
249
166
) {
@@ -253,7 +170,9 @@ mod public_imp {
253
170
}
254
171
255
172
#[ allow( unused) ] // not used if not SIMD implementation is available
256
- fn test_chunked_streaming_with_chunk_size < T : simdutf8:: basic:: imp:: ChunkedUtf8Validator > (
173
+ fn test_chunked_streaming_with_chunk_size <
174
+ T : simdutf8_portable:: basic:: imp:: ChunkedUtf8Validator ,
175
+ > (
257
176
input : & [ u8 ] ,
258
177
chunk_size : usize ,
259
178
ok : bool ,
@@ -270,46 +189,9 @@ mod public_imp {
270
189
271
190
#[ test]
272
191
#[ should_panic]
273
- #[ cfg( all(
274
- any( target_arch = "x86" , target_arch = "x86_64" ) ,
275
- target_feature = "avx2"
276
- ) ) ]
277
- fn test_avx2_chunked_panic ( ) {
278
- test_chunked_streaming_with_chunk_size :: <
279
- simdutf8:: basic:: imp:: x86:: avx2:: ChunkedUtf8ValidatorImp ,
280
- > ( b"abcd" , 1 , true ) ;
281
- }
282
-
283
- #[ test]
284
- #[ should_panic]
285
- #[ cfg( all(
286
- any( target_arch = "x86" , target_arch = "x86_64" ) ,
287
- target_feature = "sse4.2"
288
- ) ) ]
289
- fn test_sse42_chunked_panic ( ) {
290
- test_chunked_streaming_with_chunk_size :: <
291
- simdutf8:: basic:: imp:: x86:: sse42:: ChunkedUtf8ValidatorImp ,
292
- > ( b"abcd" , 1 , true ) ;
293
- }
294
-
295
- #[ test]
296
- #[ should_panic]
297
- #[ cfg( all( target_arch = "aarch64" , target_feature = "neon" ) ) ]
298
192
fn test_neon_chunked_panic ( ) {
299
193
test_chunked_streaming_with_chunk_size :: <
300
- simdutf8:: basic:: imp:: aarch64:: neon:: ChunkedUtf8ValidatorImp ,
301
- > ( b"abcd" , 1 , true ) ;
302
- }
303
-
304
- // the test runner will ignore this test probably due to limitations of panic handling/threading
305
- // of that target--keeping this here so that when it can be tested properly, it will
306
- // FIXME: remove this comment once this works properly.
307
- #[ test]
308
- #[ should_panic]
309
- #[ cfg( all( target_arch = "wasm32" , target_feature = "simd128" ) ) ]
310
- fn test_simd128_chunked_panic ( ) {
311
- test_chunked_streaming_with_chunk_size :: <
312
- simdutf8:: basic:: imp:: wasm32:: simd128:: ChunkedUtf8ValidatorImp ,
194
+ simdutf8_portable:: basic:: imp:: portable:: simd128:: ChunkedUtf8ValidatorImp ,
313
195
> ( b"abcd" , 1 , true ) ;
314
196
}
315
197
}
0 commit comments