Skip to content

Commit

Permalink
Two missing tests for sprand (#30551)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored and andreasnoack committed Jan 2, 2019
1 parent c154215 commit 2c64220
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions stdlib/SparseArrays/test/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ end
@test sprandn(r1, 100, .9) == sprandn(r2, 100, .9)
@test sprand(r1, Bool, 100, .9) == sprand(r2, Bool, 100, .9)
end

# test sprand with function inputs
let xr = sprand(1000, 0.9, rand)
@test isa(xr, SparseVector{Float64,Int})
@test length(xr) == 1000
if !isempty(nonzeros(xr))
@test all(nonzeros(xr) .> 0.0)
end
end
let xr = sprand(1000, 0.9, rand, Float32)
@test isa(xr, SparseVector{Float32,Int})
@test length(xr) == 1000
if !isempty(nonzeros(xr))
@test all(nonzeros(xr) .> 0.0)
end
end
end
end
### Element access
Expand Down

0 comments on commit 2c64220

Please sign in to comment.