Skip to content

Commit 6591807

Browse files
committed
Added FixedSparseCSC tests
1 parent 59302e6 commit 6591807

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/fixed.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,26 @@ struct_eq(A::AbstractSparseVector, B::AbstractSparseVector) =
8989
B = similar(F)
9090
@test typeof(B) == typeof(F)
9191
@test struct_eq(B, F)
92+
93+
C = fixed(copy(A))
94+
copyto!(C, F)
95+
@test C == F
96+
@test struct_eq(C, F)
97+
98+
G = fixed(sparse([1.0 0.0; 0.0 2.0]))
99+
H = fixed(sparse([1.0 3.0; 0.0 2.0]))
100+
@test_throws DimensionMismatch copyto!(fixed(sprandn(9, 10, 0.3)), F)
101+
@test_throws ArgumentError copyto!(G, H)
102+
103+
Bsame = similar(F, Float32, size(F))
104+
@test typeof(Bsame) == typeof(FixedSparseCSC{Float32, eltype(rowvals(F))}(A))
105+
@test _is_fixed(Bsame)
106+
@test struct_eq(Bsame, F)
107+
108+
Bdiff = similar(F, Float32, (size(F, 1) + 1, size(F, 2)))
109+
@test typeof(Bdiff) == typeof(Bsame)
110+
@test _is_fixed(Bdiff)
111+
@test size(Bdiff) == (size(F, 1) + 1, size(F, 2))
92112
end
93113
@testset "SparseMatrixCSC conversions" begin
94114
A = sprandn(10, 10, 0.3)

0 commit comments

Comments
 (0)