|
467 | 467 | BA_1 = BlockArray(undef_blocks, Vector{Float64}, [1,2,3])
|
468 | 468 | @test Base.IndexStyle(typeof(BA_1)) == IndexCartesian()
|
469 | 469 |
|
| 470 | + @test checkbounds(Bool, BA_1, Block(1)) |
| 471 | + @test isnothing(checkbounds(BA_1, Block(1))) |
| 472 | + @test blockcheckbounds(Bool, BA_1, 1) |
| 473 | + @test isnothing(blockcheckbounds(BA_1, 1)) |
| 474 | + @test checkbounds(Bool, BA_1, Block(2)) |
| 475 | + @test isnothing(checkbounds(BA_1, Block(2))) |
| 476 | + @test blockcheckbounds(Bool, BA_1, 2) |
| 477 | + @test isnothing(blockcheckbounds(BA_1, 2)) |
| 478 | + @test checkbounds(Bool, BA_1, Block(3)) |
| 479 | + @test isnothing(checkbounds(BA_1, Block(3))) |
| 480 | + @test blockcheckbounds(Bool, BA_1, 3) |
| 481 | + @test isnothing(blockcheckbounds(BA_1, 3)) |
| 482 | + @test !checkbounds(Bool, BA_1, Block(4)) |
| 483 | + @test_throws BlockBoundsError checkbounds(BA_1, Block(4)) |
| 484 | + @test !blockcheckbounds(Bool, BA_1, 4) |
| 485 | + @test_throws BlockBoundsError blockcheckbounds(BA_1, 4) |
| 486 | + |
| 487 | + @test checkbounds(Bool, BA_1, Block.(1:3)) |
| 488 | + @test isnothing(checkbounds(BA_1, Block.(1:3))) |
| 489 | + @test blockcheckbounds(Bool, BA_1, 1:3) |
| 490 | + @test isnothing(blockcheckbounds(BA_1, 1:3)) |
| 491 | + @test !checkbounds(Bool, BA_1, Block.(1:4)) |
| 492 | + @test_throws BlockBoundsError checkbounds(BA_1, Block.(1:4)) |
| 493 | + @test !blockcheckbounds(Bool, BA_1, 1:4) |
| 494 | + @test_throws BlockBoundsError blockcheckbounds(BA_1, 1:4) |
| 495 | + |
| 496 | + @test checkbounds(Bool, BA_1, [Block(1), Block(3)]) |
| 497 | + @test isnothing(checkbounds(BA_1, [Block(1), Block(3)])) |
| 498 | + @test blockcheckbounds(Bool, BA_1, [1, 3]) |
| 499 | + @test isnothing(blockcheckbounds(BA_1, [1, 3])) |
| 500 | + @test !checkbounds(Bool, BA_1, [Block(1), Block(4)]) |
| 501 | + @test_throws BlockBoundsError checkbounds(BA_1, [Block(1), Block(4)]) |
| 502 | + @test !blockcheckbounds(Bool, BA_1, [1, 4]) |
| 503 | + @test_throws BlockBoundsError blockcheckbounds(BA_1, [1, 4]) |
| 504 | + |
| 505 | + @test checkbounds(Bool, BA_1, Block(2)[2]) |
| 506 | + @test isnothing(checkbounds(BA_1, Block(2)[2])) |
| 507 | + @test !checkbounds(Bool, BA_1, Block(2)[3]) |
| 508 | + @test_throws BoundsError checkbounds(BA_1, Block(2)[3]) |
| 509 | + @test !checkbounds(Bool, BA_1, Block(4)[2]) |
| 510 | + @test_throws BoundsError checkbounds(BA_1, Block(4)[2]) |
| 511 | + |
| 512 | + @test checkbounds(Bool, BA_1, Block(2)[1:2]) |
| 513 | + @test isnothing(checkbounds(BA_1, Block(2)[1:2])) |
| 514 | + @test !checkbounds(Bool, BA_1, Block(2)[1:3]) |
| 515 | + @test_throws BoundsError checkbounds(BA_1, Block(2)[1:3]) |
| 516 | + |
| 517 | + @test checkbounds(Bool, BA_1, [Block(2)[2], Block(3)[3]]) |
| 518 | + @test isnothing(checkbounds(BA_1, [Block(2)[2], Block(3)[3]])) |
| 519 | + @test !checkbounds(Bool, BA_1, [Block(2)[2], Block(2)[3]]) |
| 520 | + @test_throws BoundsError checkbounds(BA_1, [Block(2)[2], Block(2)[3]]) |
| 521 | + @test !checkbounds(Bool, BA_1, [Block(2)[2], Block(4)[2]]) |
| 522 | + @test_throws BoundsError checkbounds(BA_1, [Block(2)[2], Block(4)[2]]) |
| 523 | + |
470 | 524 | a_1 = rand(2)
|
471 | 525 | BA_1[Block(2)] = a_1
|
472 | 526 | @test BA_1[BlockIndex(2, 1)] == a_1[1]
|
|
491 | 545 | @test BA_2[Block(1,2)] == a_2
|
492 | 546 | BA_2[Block(1,2)] = a_2
|
493 | 547 |
|
| 548 | + @test checkbounds(Bool, BA_2, Block(1,1)) |
| 549 | + @test isnothing(checkbounds(BA_2, Block(1,1))) |
| 550 | + @test checkbounds(Bool, BA_2, Block(1), Block(1)) |
| 551 | + @test isnothing(checkbounds(BA_2, Block(1), Block(1))) |
| 552 | + @test !checkbounds(Bool, BA_2, Block(1,3)) |
| 553 | + @test_throws BlockBoundsError checkbounds(BA_2, Block(1,3)) |
| 554 | + @test !checkbounds(Bool, BA_2, Block(1), Block(3)) |
| 555 | + @test_throws BlockBoundsError checkbounds(BA_2, Block(1), Block(3)) |
| 556 | + |
| 557 | + @test checkbounds(Bool, BA_2, BlockRange(1:2,1:2)) |
| 558 | + @test blockcheckbounds(Bool, BA_2, BlockRange(1:2,1:2)) |
| 559 | + @test isnothing(checkbounds(BA_2, BlockRange(1:2,1:2))) |
| 560 | + @test isnothing(blockcheckbounds(BA_2, BlockRange(1:2,1:2))) |
| 561 | + @test checkbounds(Bool, BA_2, Block.(1:2), Block.(1:2)) |
| 562 | + @test checkbounds(Bool, BA_2, Block.([1,2]), Block.([1,2])) |
| 563 | + @test isnothing(checkbounds(BA_2, Block.(1:2), Block.(1:2))) |
| 564 | + @test isnothing(checkbounds(BA_2, Block.([1,2]), Block.([1,2]))) |
| 565 | + @test blockcheckbounds(Bool, BA_2, 1:2, 1:2) |
| 566 | + @test blockcheckbounds(Bool, BA_2, [1,2], [1,2]) |
| 567 | + @test isnothing(blockcheckbounds(BA_2, 1:2, 1:2)) |
| 568 | + @test isnothing(blockcheckbounds(BA_2, Block.(1:2), Block.(1:2))) |
| 569 | + @test isnothing(blockcheckbounds(BA_2, [1,2], [1,2])) |
| 570 | + @test isnothing(blockcheckbounds(BA_2, Block.([1,2]), Block.([1,2]))) |
| 571 | + |
| 572 | + @test !checkbounds(Bool, BA_2, BlockRange(1:2,1:3)) |
| 573 | + @test !blockcheckbounds(Bool, BA_2, BlockRange(1:2,1:3)) |
| 574 | + @test_throws BlockBoundsError checkbounds(BA_2, BlockRange(1:2,1:3)) |
| 575 | + @test_throws BlockBoundsError blockcheckbounds(BA_2, BlockRange(1:2,1:3)) |
| 576 | + @test !checkbounds(Bool, BA_2, Block.(1:2), Block.(1:3)) |
| 577 | + @test !checkbounds(Bool, BA_2, Block.([1,2]), Block.([1,3])) |
| 578 | + @test_throws BlockBoundsError checkbounds(BA_2, Block.(1:2), Block.(1:3)) |
| 579 | + @test_throws BlockBoundsError checkbounds(BA_2, Block.([1,2]), Block.([1,3])) |
| 580 | + @test !blockcheckbounds(Bool, BA_2, 1:2, 1:3) |
| 581 | + @test !blockcheckbounds(Bool, BA_2, [1,2], [1,3]) |
| 582 | + @test_throws BlockBoundsError blockcheckbounds(BA_2, 1:2, 1:3) |
| 583 | + @test_throws BlockBoundsError blockcheckbounds(BA_2, Block.(1:2), Block.(1:3)) |
| 584 | + @test_throws BlockBoundsError blockcheckbounds(BA_2, [1,2], [1,3]) |
| 585 | + @test_throws BlockBoundsError blockcheckbounds(BA_2, Block.([1,2]), Block.([1,3])) |
| 586 | + |
| 587 | + @test checkbounds(Bool, BA_2, Block(1,1)[1,1]) |
| 588 | + @test isnothing(checkbounds(BA_2, Block(1,1)[1,1])) |
| 589 | + @test checkbounds(Bool, BA_2, Block(1)[1], Block(1)[1]) |
| 590 | + @test checkbounds(Bool, BA_2, Block(1,2)[1,2]) |
| 591 | + @test !checkbounds(Bool, BA_2, Block(1,2)[2,2]) |
| 592 | + @test checkbounds(Bool, BA_2, Block(2,2)[1:1,1:2]) |
| 593 | + @test checkbounds(Bool, BA_2, Matrix(Block(2,2)[1:1,1:2])) |
| 594 | + @test isnothing(checkbounds(BA_2, Matrix(Block(2,2)[1:1,1:2]))) |
| 595 | + @test checkbounds(Bool, BA_2, Block(1,2)[1:1,1:2]) |
| 596 | + @test checkbounds(Bool, BA_2, Block(1)[1:1], Block(2)[1:2]) |
| 597 | + @test !checkbounds(Bool, BA_2, Block(2,2)[1:3,1:2]) |
| 598 | + @test !checkbounds(Bool, BA_2, Block(2)[1:3], Block(2)[1:2]) |
| 599 | + @test checkbounds(Bool, BA_2, [Block(2)[1], Block(2)[2]], Block(2)[1:2]) |
| 600 | + @test !checkbounds(Bool, BA_2, [Block(2)[1], Block(2)[3]], Block(2)[1:2]) |
| 601 | + |
494 | 602 | @test BA_2[1,5] == a_2[2]
|
495 | 603 | @test_throws DimensionMismatch BA_2[Block(1,2)] = rand(1,5)
|
496 | 604 |
|
|
0 commit comments