Skip to content

Commit 6dc2081

Browse files
lkdvoskshyatt
authored andcommitted
add various test utility
1 parent a118e5d commit 6dc2081

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

test/testsuite/TestSuite.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Suite of tests that may be used for all packages inheriting from MatrixAlgebraKi
88
"""
99
module TestSuite
1010

11+
using Test, TestExtras
12+
using MatrixAlgebraKit
13+
using MatrixAlgebraKit: diagview
14+
using LinearAlgebra: norm, istriu
15+
1116
const tests = Dict()
1217

1318
macro testsuite(name, ex)
@@ -20,6 +25,25 @@ macro testsuite(name, ex)
2025
end
2126
end
2227

28+
testargs_summary(args...) = string(args)
29+
30+
instantiate_matrix(::Type{T}, size) where {T <: Number} = randn(T, size)
31+
instantiate_matrix(::Type{AT}, size) where {AT <: Array} = randn(eltype(AT), size)
32+
33+
function has_positive_diagonal(A)
34+
T = eltype(A)
35+
return if T <: Real
36+
all((zero(T)), diagview(A))
37+
else
38+
all((zero(real(T))), real(diagview(A))) &&
39+
all((zero(real(T))), imag(diagview(A)))
40+
end
41+
end
42+
isleftnull(N, A; kwargs...) = isapprox(norm(N' * A), 0; kwargs...)
43+
44+
# TODO: actually make this a test
45+
macro testinferred(ex)
46+
return esc(:(@inferred $ex))
2347
end
2448

2549
end

0 commit comments

Comments
 (0)