Skip to content

Commit b0b23a4

Browse files
committed
suggested tests as function
1 parent 8acb74a commit b0b23a4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/utils.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
function test_zero(DX::Union{ColVecs,RowVecs})
2+
zero_DX = zero(DX)
3+
@test all(iszero, zero_DX)
4+
@test zero_DX isa typeof(DX)
5+
@test size(zero_DX.X) == size(DX.X)
6+
end
7+
18
@testset "utils" begin
29
using KernelFunctions: vec_of_vecs, ColVecs, RowVecs
310
rng, N, D = MersenneTwister(123456), 10, 4
@@ -28,7 +35,7 @@
2835
DX[2] = v
2936
@test DX[2] == v
3037
@test X[:, 2] == v
31-
@test all(zero(DX) .== Ref(zeros(D)))
38+
test_zero(DX)
3239

3340
Y = randn(rng, D, N + 1)
3441
DY = ColVecs(Y)
@@ -86,7 +93,7 @@
8693
DX[2] = w
8794
@test DX[2] == w
8895
@test X[2, :] == w
89-
@test all(zero(DX) .== Ref(zeros(N)))
96+
test_zero(DX)
9097

9198
Y = randn(rng, D + 1, N)
9299
DY = RowVecs(Y)

0 commit comments

Comments
 (0)