Skip to content

Commit

Permalink
Unit tests for Float32
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst committed Sep 21, 2020
1 parent 4182cdd commit 33236df
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/interval_tests/construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ end
@test isequal(hash(x), hash(y))

x = @interval(0.1)
y = IntervalArithmetic.big53(x)
y = IntervalArithmetic.bigequiv(x)
@test isequal(x, y)
@test isequal(hash(x), hash(y))

Expand Down
8 changes: 8 additions & 0 deletions test/interval_tests/hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ setprecision(Interval, Float64)
@test tanh(@biginterval(-4.5, 0.1)) tanh(@interval(-4.5, 0.1))
@test tanh(@biginterval(1.3, 6.3)) tanh(@interval(1.3, 6.3))

@test tanh(@interval(0.5)) tanh(@typeinterval(Float32, 0.5))
@test tanh(@interval(0.5, 1.67)) tanh(@typeinterval(Float32, 0.5, 1.67))
@test tanh(@interval(1.67, 3.2)) tanh(@typeinterval(Float32, 1.67, 3.2))
@test tanh(@interval(2.1, 5.6)) tanh(@typeinterval(Float32, 2.1, 5.6))
@test tanh(@interval(0.5, 8.5)) tanh(@typeinterval(Float32, 0.5, 8.5))
@test tanh(@interval(-4.5, 0.1)) tanh(@typeinterval(Float32, -4.5, 0.1))
@test tanh(@interval(1.3, 6.3)) tanh(@typeinterval(Float32, 1.3, 6.3))

@test asinh(@biginterval(1)) asinh(@interval(1))
@test asinh(@biginterval(0.9, 2)) asinh(@interval(0.9, 2))
@test asinh(@biginterval(3, 4)) asinh(@interval(3, 4))
Expand Down
3 changes: 3 additions & 0 deletions test/interval_tests/numeric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ end
@test cbrt(big(2..3)) cbrt(2..3)

@test cbrt(big(3..4)) != cbrt(3..4)

@test cbrt(2f0..3f0) == Interval(1.259921f0, 1.4422497f0)
@test cbrt(2..3) cbrt(2f0..3f0)
end

@testset "inv" begin
Expand Down
15 changes: 15 additions & 0 deletions test/interval_tests/trig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@ end
Interval(-1.5707963267948968, 1.5707963267948968)
@test atan(@biginterval(-0.1, 0.1), @biginterval(-0.0, 0.1))
atan(@interval(-0.1, 0.1), @interval(0.0, 0.1))

@test atan(@typeinterval(Float32, -0.1, 0.1), @typeinterval(Float32, 0.1, 0.1)) ==
Interval(-0.78539824f0, 0.78539824f0)
@test atan(@interval(-0.1, 0.1), @interval(0.1, 0.1))
atan(@typeinterval(Float32, -0.1, 0.1), @typeinterval(Float32, 0.1, 0.1))
@test atan(@typeinterval(Float32, 0.0), @typeinterval(Float32, -0.0, 0.1)) ==
@typeinterval(Float32, 0.0)
@test atan(@typeinterval(Float32, 0.0, 0.1), @typeinterval(Float32, -0.0, 0.1)) ==
Interval(0.0, 1.5707964f0)
@test atan(@typeinterval(Float32, -0.1, 0.0), @typeinterval(Float32, 0.0, 0.1)) ==
Interval(-1.5707964f0, 0.0)
@test atan(@typeinterval(Float32, -0.1, 0.1), @typeinterval(Float32, -0.0, 0.1)) ==
Interval(-1.5707964f0, 1.5707964f0)
@test atan(@interval(-0.1, 0.1), @interval(-0.0, 0.1))
atan(@typeinterval(Float32, -0.1, 0.1), @typeinterval(Float32, 0.0, 0.1))
end

@testset "Trig" begin
Expand Down

0 comments on commit 33236df

Please sign in to comment.