Skip to content

Commit

Permalink
Add constructor test for OffsetArray.
Browse files Browse the repository at this point in the history
  • Loading branch information
N5N3 committed May 6, 2022
1 parent 52de1e5 commit c16c367
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ julia = "1.6"
[extras]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["InteractiveUtils", "Test", "BenchmarkTools"]
test = ["InteractiveUtils", "Test", "BenchmarkTools", "OffsetArrays"]
9 changes: 9 additions & 0 deletions test/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,12 @@ struct BugStaticVector <: StaticVector{2,Int} end
@test_inlined f((1,2,3,4))
end

using OffsetArrays
@testset "constructor/convert from OffsetArray" begin
a = OffsetArray([-1 1;0 2], -1, -1)
b = OffsetArray([-1,0,1,2], -1)
c = OffsetArray(-1:2, -1)
d = Base.IdentityUnitRange(-1:2)
@test SVector{4}(a) === SVector{4}(b) === SVector{4}(c) === SVector{4}(d) == [-1,0,1,2]
@test SMatrix{2,2}(a) === SMatrix{2,2}(b) === SMatrix{2,2}(c) === SMatrix{2,2}(d) == [-1 1;0 2]
end

0 comments on commit c16c367

Please sign in to comment.