Skip to content

Commit

Permalink
adds some tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomRiem committed Jul 22, 2021
1 parent 4303f48 commit 56aa73c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/fastsum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,23 @@ mutable struct FASTSUM
flags::UInt32,
)
if N <= 0
error("N has to be a positive Integer.")
throw(DomainError(M, "argument must be a positive integer"))
end

if M <= 0
error("M has to be a positive Integer.")
throw(DomainError(M, "argument must be a positive integer"))
end

if n <= 0
error("n has to be a positive Integer. ")
throw(DomainError(n, "argument must be a positive integer"))
end

if (m_x <= 0) || (m_y <= 0)
error("m has to be a positive Integer.")
if m_x <= 0
throw(DomainError(m_x, "argument must be a positive integer"))
end

if m_y <= 0
throw(DomainError(m_y, "argument must be a positive integer"))
end

new(
Expand Down
18 changes: 17 additions & 1 deletion test/fastsum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,20 @@ E_2 = norm(error_vector) / norm(f1)
E_infty = norm(error_vector, Inf) / norm(plan.alpha, 1)

@test E_2 < 10^(-5)
@test E_infty < 10^(-5)
@test E_infty < 10^(-5)

# Error tests
@test_throws DomainError FASTSUM(d, -1, M, kernel, c)

@test_throws DomainError FASTSUM(d, N, -1, kernel, c)

@test_throws DomainError FASTSUM(d, N, M, kernel, c, -1)

@test_throws DomainError FASTSUM(d, N, M, kernel, c, 256, 8, 256/8, 1/16, 512, -1)

cv = Vector{Float64}(undef, 1)
cv[1] = Float64(c)

@test_throws DomainError FASTSUM(d, N, M, 1, 1, kernel, cv, 256/8, 1/16, 512, 512, -1, 1, UInt32(0))

@test_throws DomainError FASTSUM(d, N, M, 1, 1, kernel, cv, 256/8, 1/16, 512, 512, 1, -1, UInt32(0))

0 comments on commit 56aa73c

Please sign in to comment.