-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_arithmetics.jl
26 lines (24 loc) · 1.29 KB
/
test_arithmetics.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using FunctionMaps:
interval_map,
bounded_interval_map
@testset "map interval" begin
@test interval_map(1.0, Inf, 2.0, Inf) == AffineMap(1.0, 1.0)
@test interval_map(1.0, Inf, Inf, 2.0) == AffineMap(-1.0, 3.0)
@test interval_map(Inf, 1.0, 2.0, Inf) == AffineMap(-1.0, 3.0)
@test interval_map(Inf, 1.0, Inf, 2.0) == AffineMap(1.0, 1.0)
@test interval_map(-Inf, Inf, -Inf, Inf) == IdentityMap()
@test interval_map(-Inf, Inf, Inf, -Inf) == LinearMap(-1)
@test interval_map(Inf, -Inf, -Inf, Inf) == LinearMap(-1)
@test interval_map(Inf, -Inf, Inf, -Inf) == IdentityMap()
@test interval_map(Inf, Inf, Inf, Inf) == IdentityMap()
@test interval_map(-Inf, -Inf, -Inf, -Inf) == IdentityMap()
@test interval_map(Inf, Inf, -Inf, -Inf) == LinearMap(-1)
@test interval_map(-Inf, -Inf, Inf, Inf) == LinearMap(-1)
@test_throws ArgumentError interval_map(-Inf, Inf, -Inf, -Inf)
@test_throws ArgumentError interval_map(-1, 1, -1, Inf)
@test_throws ArgumentError interval_map(-1, 1, -1, Inf)
a = 1.0; b = 2.0; c = 3.0; d = 5;
@test interval_map(a, b, c, d)(a) == c
@test interval_map(a, b, c, d)(b) == d
@test interval_map(a, b, c, d) == bounded_interval_map(a, b, c, d)
end