Skip to content

Commit 88e65c2

Browse files
committed
improve coverage
1 parent 39c605c commit 88e65c2

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/StaticArraysCore.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ Base.@pure function size_to_tuple(::Type{S}) where S<:Tuple
5656
end
5757

5858
# Something doesn't match up type wise
59-
function check_array_parameters(Size, T, N, L)
60-
(!isa(Size, DataType) || (Size.name !== Tuple.name)) && throw(ArgumentError("Static Array parameter Size must be a Tuple type, got $Size"))
61-
!isa(T, Type) && throw(ArgumentError("Static Array parameter T must be a type, got $T"))
62-
!isa(N.parameters[1], Int) && throw(ArgumentError("Static Array parameter N must be an integer, got $(N.parameters[1])"))
63-
!isa(L.parameters[1], Int) && throw(ArgumentError("Static Array parameter L must be an integer, got $(L.parameters[1])"))
64-
# shouldn't reach here. Anything else should have made it to the function below
65-
error("Internal error. Please file a bug")
66-
end
6759
@generated function check_array_parameters(::Type{Size}, ::Type{T}, ::Type{Val{N}}, ::Type{Val{L}}) where {Size,T,N,L}
6860
if !all(x->isa(x, Int), Size.parameters)
6961
return :(throw(ArgumentError("Static Array parameter Size must be a tuple of Ints (e.g. `SArray{Tuple{3,3}}` or `SMatrix{3,3}`).")))
@@ -77,8 +69,6 @@ end
7769
end
7870

7971
# Cast any Tuple to an TupleN{T}
80-
@inline convert_ntuple(::Type{T},d::T) where {T} = T # For zero-dimensional arrays
81-
@inline convert_ntuple(::Type{T},d::NTuple{N,T}) where {N,T} = d
8272
@generated function convert_ntuple(::Type{T}, d::NTuple{N,Any}) where {N,T}
8373
exprs = ntuple(i -> :(convert(T, d[$i])), Val(N))
8474
return quote

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ using StaticArraysCore: SizedArray, SizedVector, SizedMatrix
66

77
@testset "types" begin
88
@test SArray{Tuple{2},Int,1}((1, 2)) isa SArray
9+
@test_throws ArgumentError SArray{Tuple{2},Int,2}((1, 2))
910
@test SArray{Tuple{2},Float64,1}((1, 2)) isa SVector{2,Float64}
1011
@test SVector{2,Int}((1, 2)) isa SVector
1112
@test SMatrix{1,2,Int}((1, 2)) isa SMatrix
@@ -17,5 +18,12 @@ using StaticArraysCore: SizedArray, SizedVector, SizedMatrix
1718
@test MMatrix{1,2,Int}((1, 2)) isa MMatrix
1819

1920
@test SizedArray{Tuple{2},Int,2,1,Vector{Int}}([1, 2]) isa SizedArray
21+
@test_throws DimensionMismatch SizedArray{Tuple{2},Int,2,1,Vector{Int}}([1, 2, 3]) isa SizedArray
2022
@test SizedArray{Tuple{2},Int,2,1,Vector{Int}}(undef) isa SizedArray
23+
@test SizedArray{Tuple{2,3},Int,2,2,Matrix{Int}}(undef) isa SizedArray
24+
25+
@test_throws ArgumentError StaticArraysCore.check_array_parameters(Tuple{2.0}, Int, Val{2}, Val{2})
26+
@test StaticArraysCore.tuple_length((5, 3)) == 2
27+
@test StaticArraysCore.tuple_prod((5, 3)) == 15
28+
@test StaticArraysCore.tuple_minimum((5, 3)) == 3
2129
end

0 commit comments

Comments
 (0)