Skip to content

Commit

Permalink
Added constructor with three parametric types
Browse files Browse the repository at this point in the history
Added tests for using matrix data with different constructors.

Closes #17.
  • Loading branch information
Vexatos committed May 27, 2022
1 parent 1e6ad99 commit 6e55e60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CircularArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export CircularArray, CircularVector
struct CircularArray{T, N, A <: AbstractArray{T,N}} <: AbstractArray{T,N}
data::A
CircularArray{T,N}(data::A) where A <: AbstractArray{T,N} where {T,N} = new{T,N,A}(data)
CircularArray{T,N,A}(data::A) where A <: AbstractArray{T,N} where {T,N} = new{T,N,A}(data)
end

"""
Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ end
@test all(a == first(arrays) for a in arrays)
@test all(a isa CircularVector{T,Vector{T}} for a in arrays)
end

@testset "matrix construction" begin
data = zeros(Float64, 2, 2)
ref = CircularArray(data)
@test CircularArray{Float64}(data) == ref
@test CircularArray{Float64, 2}(data) == ref
@test CircularArray{Float64, 2, Array{Float64, 2}}(data) == ref
@test CircularArray{Float64, 2, Matrix{Float64}}(data) == ref
end
end

@testset "type stability" begin
Expand Down

0 comments on commit 6e55e60

Please sign in to comment.