|
295 | 295 | # check iteration behavior on boundary |
296 | 296 | R = CartesianIndex(1, 1):CartesianIndex(2, 3):CartesianIndex(4, 5) |
297 | 297 | @test R.indices == (1:2:3, 1:3:4) |
298 | | - i = CartesianIndex(4, 1) |
299 | | - i_next = CartesianIndex(1, 4) |
300 | | - @test !(i in R) && iterate(R, i) == (i_next, i_next) |
| 298 | + @test last(R) == CartesianIndex(3, 4) && iterate(R, last(R)) == nothing |
301 | 299 |
|
302 | 300 | for R in [ |
303 | 301 | CartesianIndices((1:-1:-1, 1:2:5)), |
@@ -398,31 +396,31 @@ end |
398 | 396 | @test iterate(I, i) === nothing |
399 | 397 |
|
400 | 398 | I = CartesianIndices((1:2:typemax(Int), )) |
401 | | - i = CartesianIndex(typemax(Int)-1) |
| 399 | + i = CartesianIndex(typemax(Int)) |
402 | 400 | @test iterate(I, i) === nothing |
403 | 401 |
|
404 | 402 | I = CartesianIndices((1:(typemax(Int)-1),)) |
405 | | - i = CartesianIndex(typemax(Int)) |
| 403 | + i = CartesianIndex(typemax(Int)-1) |
406 | 404 | @test iterate(I, i) === nothing |
407 | 405 |
|
408 | 406 | I = CartesianIndices((1:2:typemax(Int)-1, )) |
409 | | - i = CartesianIndex(typemax(Int)-1) |
| 407 | + i = CartesianIndex(typemax(Int)-2) |
410 | 408 | @test iterate(I, i) === nothing |
411 | 409 |
|
412 | 410 | I = CartesianIndices((1:typemax(Int), 1:typemax(Int))) |
413 | 411 | i = last(I) |
414 | 412 | @test iterate(I, i) === nothing |
415 | 413 |
|
416 | 414 | I = CartesianIndices((1:2:typemax(Int), 1:2:typemax(Int))) |
417 | | - i = CartesianIndex(typemax(Int)-1, typemax(Int)-1) |
| 415 | + i = last(I) |
418 | 416 | @test iterate(I, i) === nothing |
419 | 417 |
|
420 | 418 | I = CartesianIndices((1:typemax(Int), 1:typemax(Int))) |
421 | 419 | i = CartesianIndex(typemax(Int), 1) |
422 | 420 | @test iterate(I, i) === (CartesianIndex(1, 2), CartesianIndex(1,2)) |
423 | 421 |
|
424 | 422 | I = CartesianIndices((1:2:typemax(Int), 1:2:typemax(Int))) |
425 | | - i = CartesianIndex(typemax(Int)-1, 1) |
| 423 | + i = CartesianIndex(typemax(Int), 1) |
426 | 424 | @test iterate(I, i) === (CartesianIndex(1, 3), CartesianIndex(1, 3)) |
427 | 425 |
|
428 | 426 | I = CartesianIndices((typemin(Int):(typemin(Int)+3),)) |
|
496 | 494 |
|
497 | 495 | # test invalid state |
498 | 496 | I = CartesianIndices((2:4, 3:5)) |
499 | | - @test iterate(I, CartesianIndex(typemax(Int), 3))[1] == CartesianIndex(2,4) |
500 | | - @test iterate(I, CartesianIndex(typemax(Int), 4))[1] == CartesianIndex(2,5) |
501 | | - @test iterate(I, CartesianIndex(typemax(Int), 5)) === nothing |
| 497 | + @test iterate(I, CartesianIndex(4, typemax(Int))) === nothing |
502 | 498 |
|
503 | 499 | @test iterate(I, CartesianIndex(3, typemax(Int)))[1] == CartesianIndex(4,typemax(Int)) |
504 | 500 | @test iterate(I, CartesianIndex(4, typemax(Int))) === nothing |
|
0 commit comments