Skip to content

Commit

Permalink
adds test for getindex function
Browse files Browse the repository at this point in the history
  • Loading branch information
navidcy committed Jul 11, 2019
1 parent 1a8280e commit 7adabed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using FourierFlows: parsevalsum2
using LinearAlgebra: mul!, ldiv!, norm

const rtol_fft = 1e-12
const rtol_output = 1e-12
const rtol_timesteppers = 1e-12

const steppers = [
Expand Down Expand Up @@ -203,4 +204,5 @@ end
@test test_withoutjld2()
@test test_uniquepath()
@test test_outputconstructor()
@test test_getindex()
end
14 changes: 14 additions & 0 deletions test/test_output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,18 @@ function test_outputconstructor()
out2 = Output(prob, filename, (:sol, get_sol), (:c, get_c))

return typeof(out1)<:Output && typeof(out2)<:Output
end

function test_getindex()
prob = FourierFlows.Diffusion.Problem(nx=32, Lx=2π, kappa=1e-2, dt=1e-7, stepper="ForwardEuler")
filename = joinpath(".", "testoutput.jld2")

ctest = zeros((prob.grid.nx, ))
ctest[3] = π
prob.vars.c .= ctest

get_c(prob) = prob.vars.c
out = Output(prob, filename, (:c, get_c))

return isapprox(ctest, getindex(out, :c), rtol=rtol_output)
end

0 comments on commit 7adabed

Please sign in to comment.