Skip to content

Commit

Permalink
Add bounds-check tests [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Feb 23, 2015
1 parent dcf3ec8 commit e1d28e3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,13 @@ msk[2,1] = false
sA = sub(A, :, :, 1)
sA[msk] = 1.0
@test sA[msk] == ones(countnz(msk))

# bounds checking upon construction; see #4044, #10296
@test_throws BoundsError sub(1:10, 8:11)
A = reshape(1:20, 5, 4)
sA = sub(A, 1:2, 1:3)
@test_throws BoundsError sub(sA, 1:3, 1:3)
@test_throws BoundsError sub(sA, 1:2, 1:4)
sub(sA, 1:2, 1:2)
@test_throws BoundsError sub(A, 17:23)
sub(A, 17:20)

0 comments on commit e1d28e3

Please sign in to comment.