Skip to content

Commit

Permalink
some more checks
Browse files Browse the repository at this point in the history
  • Loading branch information
meggart authored and rafaqz committed Oct 6, 2023
1 parent cbac1f2 commit 4aecd55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/chunks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct RegularChunks <: ChunkType
s::Int
function RegularChunks(cs::Int,offset::Int,s::Int)
cs>0 || throw(ArgumentError("Chunk sizes must be strictly positive"))
-1 < offset < cs || throw(ArgumentError("Offsets must be positive and smaller than the chunk size"))
s >= 0 || throw(ArgumentError("Negative dimension lengths are not allowed"))
new(cs,offset,s)
end
end
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ end
@test_throws BoundsError a2[0]
@test_throws BoundsError a2[11]
@test_throws ArgumentError RegularChunks(0,2,10)
@test_throws ArgumentError RegularChunks(2,-1,10)
@test_throws ArgumentError RegularChunks(2,2,10)
@test_throws ArgumentError RegularChunks(5,2,-1)
b1 = IrregularChunks(; chunksizes=[3, 3, 4, 3, 3])
@test b1[1] == 1:3
@test b1[2] == 4:6
Expand Down

0 comments on commit 4aecd55

Please sign in to comment.