Skip to content

Commit

Permalink
Add several new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Benet committed Oct 9, 2015
1 parent e0ea364 commit a70a6e8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions test/interval_tests/consistency_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ facts("Consistency tests") do
@fact typeof(emptyinterval()) --> Interval{Float64}

@fact fma(emptyinterval(), a, b) --> emptyinterval()
@fact fma(entireinterval(), zero(a), b) --> b
@fact fma(zero(a), entireinterval(), b) --> b
@fact fma(a, zero(a), c) --> c
@fact fma(Interval(1//2), Interval(1//3), Interval(1//12)) --> Interval(3//12)
Expand Down Expand Up @@ -156,6 +157,10 @@ facts("Consistency tests") do
@fact max(emptyinterval(), Interval(3.0,4.0)) --> emptyinterval()
@fact max(Interval(-3.0,1.0), Interval(3.0,4.0)) --> Interval(3.0, 4.0)
@fact max(Interval(-3.0,-1.0), Interval(3.0,4.0)) --> Interval(3.0, 4.0)
@fact sign(entireinterval()) --> Interval(-1.0, 1.0)
@fact sign(emptyinterval()) --> emptyinterval()
@fact sign(Interval(-3.0,1.0)) --> Interval(-1.0, 1.0)
@fact sign(Interval(-3.0,-1.0)) --> Interval(-1.0, -1.0)

@fact log(@interval(-2,5)) --> @interval(-Inf,log(5.0))

Expand Down
6 changes: 6 additions & 0 deletions test/interval_tests/construct_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ facts("Constructing intervals") do
set_interval_precision(Float64)
@fact get_interval_precision() == (Float64,-1) --> true

# Checks for interval_parameters
@fact ValidatedNumerics.interval_parameters.precision_type --> Float64
@fact ValidatedNumerics.interval_parameters.precision --> 53
@fact ValidatedNumerics.interval_parameters.rounding --> :narrow
@fact ValidatedNumerics.interval_parameters.pi --> @biginterval(pi)

# Naive constructors, with no conversion involved
@fact Interval(1) --> Interval(1.0, 1.0)
@fact Interval(big(1)) --> Interval(1.0, 1.0)
Expand Down
3 changes: 3 additions & 0 deletions test/interval_tests/non_BigFloat_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ facts("Tests with rational intervals") do

@fact sqrt(a + b) --> Interval(0.9636241116594315, 1.224744871391589)

@fact rationalize(1//2) --> 1//2
@fact rationalize(BigInt, 1//2) --> BigInt(1)//2

end

facts("Tests with float intervals") do
Expand Down
13 changes: 12 additions & 1 deletion test/interval_tests/numeric_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,24 @@ facts("Numeric tests") do
@fact b/a --> Interval(8.18181818181818e-01, 2.0000000000000004e+01)
@fact a/c --> Interval(2.4999999999999998e-02, 4.4000000000000004e+00)
@fact c/4.0 --> Interval(6.25e-02, 1e+00)
@fact c/zero(c) --> emptyinterval(c)
@fact Interval(0.0, 1.0)/Interval(0.0,1.0) --> Interval(0.0, Inf)
@fact Interval(-1.0, 1.0)/Interval(0.0,1.0) --> entireinterval(c)

# Powers
@fact @interval(-3,2) ^ 2 --> Interval(0., 9.)#roughly(Interval(0., 9.))
@fact @interval(-3,2) ^ 2 --> Interval(0, 9)
@fact @interval(-3,2) ^ 3 --> @interval(-27, 8)
@fact @interval(2,3) ^ 2 --> Interval(4., 9.)
@fact @interval(-3,0) ^ 3 --> @interval(-27., 0.)
@fact @interval(-3,2) ^ 3 --> @interval(-27., 8.)
@fact @interval(-3,0) ^ -2 --> Interval(1/9, Inf)
@fact @interval(-3,2) ^ -2 --> Interval(1/9, Inf)
@fact @interval(2,3) ^ -2 --> Interval(1/9, 1/4)
@fact @interval(1,2) ^ -3 --> Interval(1/8, 1.0)
@fact @interval(-3,2) ^ (3//1) --> @interval(-27, 8)
@fact^ 0 -->
@fact Interval(2.5)^3 --> Interval(15.625, 15.625)
@fact Interval(5//2)^3.0 --> Interval(125//8)

x = @interval(-3,2)
@fact x^3 --> @interval(-27, 8)
Expand Down

0 comments on commit a70a6e8

Please sign in to comment.