-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathtest_composable.jl
66 lines (46 loc) · 1.51 KB
/
test_composable.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Simple tests to make sure Roots works with other
# packages. This is not part of runtests, as no expectation
# that CI should run these
using Roots
using Test
using Unitful
using SymEngine
@testset "Test composability with other packages" begin
orders = [Order0(), Order1(), Roots.Order1B(), Order2(), Roots.Order2B(), Order5(),
Order8(), Order16()]
# Unitful
@testset "find zero(s) with Unitful" begin
s = u"s"; m = u"m"
g = 9.8*m/s^2
v0 = 10m/s
y0 = 16m
y(t) = -g*t^2 + v0*t + y0
for order in orders
@test find_zero(y, 1.8s, order) ≈ 1.886053370668014s
end
for M in [Roots.Bisection(), Roots.A42(), Roots.AlefeldPotraShi()]
@test find_zero(y, (1.8s, 1.9s), M) ≈ 1.886053370668014s
end
xrts = find_zeros(y, 0s, 10s)
@test length(xrts) == 1
@test xrts[1] ≈ 1.886053370668014s
end
# SymEngine
@testset "find zero(s) with SymEngine" begin
m = s = 1.0
g = 9.8*m/s^2
v0 = 10m/s
y0 = 16m
y(t) = -g*t^2 + v0*t + y0
@vars x
for order in orders
@test find_zero(y(x), 1.8, order) ≈ 1.8860533706680143
end
for M in [Roots.Bisection(), Roots.A42(), Roots.AlefeldPotraShi()]
@test find_zero(y(x), (1.8, 1.9), M) ≈ 1.8860533706680143
end
xrts = find_zeros(y(x), 0, 10)
@test length(xrts) == 1
@test xrts[1] ≈ 1.8860533706680143
end
end