Skip to content

Commit

Permalink
Add corner case tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tansongchen committed Sep 26, 2024
1 parent c11dd72 commit c90fc69
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/primitive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,25 @@ end
@test derivative(f, 0, order)fdm(f, 0) atol=1e-6
end
end

@testset "Corner cases" begin
offenders = (
TaylorDiff.TaylorScalar{Float64, 4}((Inf, 1.0, 0.0, 0.0)),
TaylorDiff.TaylorScalar{Float64, 4}((Inf, 0.0, 0.0, 0.0)),
TaylorDiff.TaylorScalar{Float64, 4}((1.0, 0.0, 0.0, 0.0)),
TaylorDiff.TaylorScalar{Float64, 4}((1.0, Inf, 0.0, 0.0)),
TaylorDiff.TaylorScalar{Float64, 4}((0.0, 1.0, 0.0, 0.0)),
TaylorDiff.TaylorScalar{Float64, 4}((0.0, Inf, 0.0, 0.0)) # Others ?
)
f_id = (
:id => x -> x,
:add0 => x -> x + 0,
:sub0 => x -> x - 0,
:mul1 => x -> x * 1,
:div1 => x -> x / 1,
:pow1 => x -> x^1
)
for (name, f) in f_id, t in offenders
@test f(t) == t
end
end

0 comments on commit c90fc69

Please sign in to comment.