Skip to content

Commit b6ccf93

Browse files
committed
Add tests
1 parent 874047a commit b6ccf93

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/basics/test_diagonal.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using LinearAlgebra: Diagonal, diagind
2+
using SparseArraysBase:
3+
eachstoredindex,
4+
getstoredindex,
5+
getunstoredindex,
6+
setstoredindex!,
7+
isstored,
8+
storedlength,
9+
storedpairs,
10+
storedvalues
11+
12+
using Test: @test, @testset
13+
14+
elts = (Float32, Float64, Complex{Float32}, Complex{Float64})
15+
16+
@testset "Diagonal{$T}" for T in elts
17+
L = 4
18+
D = Diagonal(rand(T, 4))
19+
@test storedlength(D) == 4
20+
@test eachstoredindex(D) == diagind(D, IndexCartesian())
21+
@test isstored(D, 2, 2)
22+
@test getstoredindex(D, 2, 2) == D[2, 2]
23+
@test !isstored(D, 2, 1)
24+
@test getunstoredindex(D, 2, 2) == zero(T)
25+
end

0 commit comments

Comments
 (0)