Skip to content

Commit d0d8279

Browse files
committed
Add bounds-check tests
1 parent 18ff3ba commit d0d8279

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

test/bidiag.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,9 @@ end
12041204
B[LinearAlgebra.BandIndex(-1,1)] = 2
12051205
@test B[2,1] == 2
12061206
@test_throws "cannot set entry $((3,1)) off the lower bidiagonal band" B[LinearAlgebra.BandIndex(-2,1)] = 2
1207+
1208+
@test_throws BoundsError B[LinearAlgebra.BandIndex(size(B,1),1)]
1209+
@test_throws BoundsError B[LinearAlgebra.BandIndex(0,size(B,1)+1)]
12071210
end
12081211

12091212
end # module TestBidiagonal

test/diagonal.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,9 @@ end
14931493
D = Diagonal(zeros(2))
14941494
D[LinearAlgebra.BandIndex(0,2)] = 1
14951495
@test D[2,2] == 1
1496-
@test_throws "cannot set off-diagonal entry" D[LinearAlgebra.BandIndex(1,1)] = 1
1496+
@test_throws "cannot set off-diagonal entry $((1,2))" D[LinearAlgebra.BandIndex(1,1)] = 1
1497+
@test_throws BoundsError D[LinearAlgebra.BandIndex(size(D,1),1)]
1498+
@test_throws BoundsError D[LinearAlgebra.BandIndex(0,size(D,1)+1)]
14971499
end
14981500

14991501
end # module TestDiagonal

test/tridiag.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,12 +1195,16 @@ end
11951195

11961196
@test_throws "cannot set entry $((1,3)) off the tridiagonal band" T[LinearAlgebra.BandIndex(2,1)] = 1
11971197
@test_throws "cannot set entry $((3,1)) off the tridiagonal band" T[LinearAlgebra.BandIndex(-2,1)] = 1
1198+
@test_throws BoundsError T[LinearAlgebra.BandIndex(size(T,1),1)]
1199+
@test_throws BoundsError T[LinearAlgebra.BandIndex(0,size(T,1)+1)]
11981200

11991201
S = SymTridiagonal(zeros(4), zeros(3))
12001202
S[LinearAlgebra.BandIndex(0,2)] = 1
12011203
@test S[2,2] == 1
12021204

12031205
@test_throws "cannot set off-diagonal entry $((1,3))" S[LinearAlgebra.BandIndex(2,1)] = 1
1206+
@test_throws BoundsError S[LinearAlgebra.BandIndex(size(S,1),1)]
1207+
@test_throws BoundsError S[LinearAlgebra.BandIndex(0,size(S,1)+1)]
12041208
end
12051209

12061210
end # module TestTridiagonal

0 commit comments

Comments
 (0)