Skip to content

Commit f837caf

Browse files
committed
Add tests
1 parent 0c76318 commit f837caf

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ using Base.Test
55
#include("findroots.jl")
66
include("roots.jl")
77
include("newton1d.jl")
8+
include("slopes.jl")

test/slopes.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using IntervalArithmetic, IntervalRootFinding
2+
using ForwardDiff
3+
using Base.Test
4+
5+
struct Slopes{T}
6+
f::Function
7+
x::Interval{T}
8+
c::T
9+
sol::Interval{T}
10+
end
11+
12+
@testset "Automatic slope expansion" begin
13+
rts = Slopes{Float64}[]
14+
push!(rts, Slopes(x->((x + sin(x)) * exp(-x^2)), interval(0.75, 1.75), 1.25, interval(-2.8, 0.1)))
15+
push!(rts, Slopes(x->(x^4 - 10x^3 + 35x^2 - 50x + 24), interval(0.75, 1.75), 1.25, interval(-44, 38.5)))
16+
push!(rts, Slopes(x->((log(x + 1.25) - 0.84x) ^ 2), interval(0.75, 1.75), 1.25, interval(-0.16, 0.44)))
17+
push!(rts, Slopes(x->(0.02x^2 - 0.03exp(-(20(x - 0.875))^2)), interval(0.75, 1.75), 1.25, interval(0.04, 0.33)))
18+
push!(rts, Slopes(x->(exp(x^2)), interval(0.75, 1.75), 1.25, interval(6.03, 33.23)))
19+
push!(rts, Slopes(x->(x^4 - 12x^3 + 47x^2 - 60x - 20exp(-x)), interval(0.75, 1.75), 1.25, interval(-39, 65.56)))
20+
push!(rts, Slopes(x->(x^6 - 15x^4 + 27x^2 + 250), interval(0.75, 1.75), 1.25, interval(-146.9, 67.1)))
21+
22+
for i in 1:length(rts)
23+
@test slope(rts[i].f, rts[i].x, rts[i].c) rts[i].sol
24+
end
25+
end

0 commit comments

Comments
 (0)