Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

WIP: Test framework #3

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions test/TestProblems.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

module TestProblems

export IVPWithSolution, ODETest, A1, A2

type IVPWithSolution
name::String
f::Function # ODE definition y' = f(t,y)
y0::Number # Initial condition y(0) = 0
tspan::AbstractVector{Number} # Boundaries for time domain
sol::Function # Analytic solution y(t)
end

type ODETest
ivp::IVPWithSolution
solver::Function
rtol::Real
atol::Real
end

# Single equations

# A1: The negative potential
A1 = IVPWithSolution( "A1", (t,y)->-y , 1. , [0., 10.] , t->exp(-t) )
# A2: A special case of the Riccati equation
A2 = IVPWithSolution( "A1", (t,y)->-y^3 / 2, 1, [0, 5], t-> 1/sqrt(t+1) )



end
24 changes: 24 additions & 0 deletions test/test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using ODE
using TestProblems
using FactCheck

abstol = 1e-6
reltol = 1e-6

#require("nearequal")

#println("Running tests for package ODE")

problem_set = [
TestProblems.ODETest(TestProblems.A1, ode45, 1e-6, 1e-6)
]

@facts begin

for problem in problem_set
tout, yout = problem.solver(problem.ivp.f, problem.ivp.tspan, problem.ivp.y0)
soly = reshape(map(problem.ivp.sol,tout),size(yout))

@fact yout => roughly(soly, reltol)
end
end