Skip to content

Commit 93c9ae4

Browse files
kshyattmbauman
authored andcommitted
A few missing indices tests (#31706)
* Missing IndexStyle tests * promote_shape for Tuples/Dims
1 parent e753c67 commit 93c9ae4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/abstractarray.jl

+17
Original file line numberDiff line numberDiff line change
@@ -970,3 +970,20 @@ end
970970
@test get(11:15, CartesianIndex(6), nothing) === nothing
971971
@test get(11:15, CartesianIndex(5), nothing) === 15
972972
end
973+
974+
@testset "IndexStyle for various types" begin
975+
@test Base.IndexStyle(UpperTriangular) == IndexCartesian() # subtype of AbstractArray, not of Array
976+
@test Base.IndexStyle(Vector) == IndexLinear()
977+
@test Base.IndexStyle(UnitRange) == IndexLinear()
978+
@test Base.IndexStyle(UpperTriangular(rand(3, 3)), [1; 2; 3]) == IndexCartesian()
979+
@test Base.IndexStyle(UpperTriangular(rand(3, 3)), rand(3, 3), [1; 2; 3]) == IndexCartesian()
980+
@test Base.IndexStyle(rand(3, 3), [1; 2; 3]) == IndexLinear()
981+
end
982+
983+
@testset "promote_shape for Tuples and Dims" begin
984+
@test promote_shape((2, 1), (2,)) == (2, 1)
985+
@test_throws DimensionMismatch promote_shape((2, 3), (2,))
986+
@test promote_shape(Dims((2, 1)), Dims((2,))) == (2, 1)
987+
@test_throws DimensionMismatch promote_shape(Dims((2, 2)), Dims((2,)))
988+
@test_throws DimensionMismatch promote_shape(Dims((2, 3, 1)), Dims((2,2)))
989+
end

0 commit comments

Comments
 (0)