File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -1238,7 +1238,9 @@ impl<T: Element + AsPrimitive<f64>> PyArray<T, Ix1> {
1238
1238
1239
1239
#[ cfg( test) ]
1240
1240
mod tests {
1241
- use super :: PyArray ;
1241
+ use super :: * ;
1242
+
1243
+ use std:: ops:: Range ;
1242
1244
1243
1245
#[ test]
1244
1246
fn test_get_unchecked ( ) {
@@ -1269,4 +1271,36 @@ mod tests {
1269
1271
py_run ! ( py, arr, "assert arr.dtype.hasobject" ) ;
1270
1272
} ) ;
1271
1273
}
1274
+
1275
+ struct InsincereIterator ( Range < usize > , usize ) ;
1276
+
1277
+ impl Iterator for InsincereIterator {
1278
+ type Item = usize ;
1279
+
1280
+ fn next ( & mut self ) -> Option < Self :: Item > {
1281
+ self . 0 . next ( )
1282
+ }
1283
+ }
1284
+
1285
+ impl ExactSizeIterator for InsincereIterator {
1286
+ fn len ( & self ) -> usize {
1287
+ self . 1
1288
+ }
1289
+ }
1290
+
1291
+ #[ test]
1292
+ #[ should_panic]
1293
+ fn from_exact_iter_too_short ( ) {
1294
+ Python :: with_gil ( |py| {
1295
+ PyArray :: from_exact_iter ( py, InsincereIterator ( 0 ..3 , 5 ) ) ;
1296
+ } ) ;
1297
+ }
1298
+
1299
+ #[ test]
1300
+ #[ should_panic]
1301
+ fn from_exact_iter_too_long ( ) {
1302
+ Python :: with_gil ( |py| {
1303
+ PyArray :: from_exact_iter ( py, InsincereIterator ( 0 ..5 , 3 ) ) ;
1304
+ } ) ;
1305
+ }
1272
1306
}
You can’t perform that action at this time.
0 commit comments