|
970 | 970 | @test get(11:15, CartesianIndex(6), nothing) === nothing
|
971 | 971 | @test get(11:15, CartesianIndex(5), nothing) === 15
|
972 | 972 | 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