Skip to content

Commit 4b31589

Browse files
committed
Add tests
1 parent dcc02b2 commit 4b31589

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ SymmetrySectors = "f8a8ad64-adbc-4fce-92f7-ffe2bb36a86e"
1919
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
2020
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2121
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
22+
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

test/test_basics.jl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ using SparseArraysBase: SparseArrayDOK, SparseMatrixDOK, SparseVectorDOK, stored
3838
using TensorAlgebra: contract
3939
using Test: @test, @test_broken, @test_throws, @testset, @inferred
4040
using TestExtras: @constinferred
41+
using TypeParameterAccessors: TypeParameterAccessors, Position
4142
include("TestBlockSparseArraysUtils.jl")
4243

4344
arrayts = (Array, JLArray)
@@ -1084,13 +1085,35 @@ arrayts = (Array, JLArray)
10841085
@test storedlength(b) == 17
10851086
end
10861087
@testset "show" begin
1088+
vectort_elt = arrayt{elt,1}
1089+
matrixt_elt = arrayt{elt,2}
1090+
arrayt_elt = arrayt{elt,3}
1091+
1092+
a = BlockSparseVector{elt,arrayt{elt,1}}([2, 2])
1093+
@test sprint(summary, a) ==
1094+
"2-blocked 4-element BlockSparseVector{$(elt), $(vectort_elt), …}"
1095+
1096+
a = BlockSparseMatrix{elt,arrayt{elt,2}}([2, 2], [2, 2])
1097+
@test sprint(summary, a) ==
1098+
"2×2-blocked 4×4 BlockSparseMatrix{$(elt), $(matrixt_elt), …}"
1099+
1100+
a = BlockSparseArray{elt,3,arrayt{elt,3}}([2, 2], [2, 2], [2, 2])
1101+
@test sprint(summary, a) ==
1102+
"2×2×2-blocked 4×4×4 BlockSparseArray{$(elt), 3, $(arrayt_elt), …}"
1103+
10871104
if elt === Float64
10881105
# Not testing other element types since they change the
10891106
# spacing so it isn't easy to make the test general.
1090-
a = BlockSparseArray{elt}([2, 2], [2, 2])
1107+
a = BlockSparseMatrix{elt,arrayt{elt,2}}([2, 2], [2, 2])
10911108
a[1, 2] = 12
10921109
@test sprint(show, "text/plain", a) ==
10931110
"$(summary(a)):\n $(zero(eltype(a))) $(eltype(a)(12)) │ . .\n $(zero(eltype(a))) $(zero(eltype(a))) │ . .\n ───────────┼──────\n . . │ . .\n . . │ . ."
10941111
end
10951112
end
1113+
@testset "TypeParameterAccessors.position" begin
1114+
@test TypeParameterAccessors.position(BlockSparseArray, eltype) == Position(1)
1115+
@test TypeParameterAccessors.position(BlockSparseArray, ndims) == Position(2)
1116+
@test TypeParameterAccessors.position(BlockSparseArray, blocktype) == Position(3)
1117+
@test TypeParameterAccessors.position(BlockSparseArray, blockstype) == Position(4)
1118+
end
10961119
end

0 commit comments

Comments
 (0)