Skip to content

Commit 4180a5b

Browse files
kanav99ChrisRackauckas
authored andcommitted
Add small test
1 parent 5290ea4 commit 4180a5b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/common_interface/callbacks.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ sol = solve(prob,CVODE_Adams(),callback=callback)
2525
sol = solve(prob,CVODE_BDF(),callback=callback)
2626
@test sol(4.0)[1] > 0
2727

28+
condition = function (out,u,t,integrator)
29+
out[1] = u[1]
30+
end
31+
32+
affect! = nothing
33+
affect_neg! = function (integrator, idx)
34+
if idx == 1
35+
integrator.u[2] = -integrator.u[2]
36+
end
37+
end
38+
39+
callback = VectorContinuousCallback(condition, affect!, affect_neg!, 1)
40+
sol = solve(prob,CVODE_Adams(),callback=callback)
41+
@test sol(4.0)[1] > 0
42+
sol = solve(prob,CVODE_BDF(),callback=callback)
43+
@test sol(4.0)[1] > 0
44+
2845
u0 = [1.,0.]
2946
function fun2(du, u, p, t)
3047
du[2] = -u[1]

0 commit comments

Comments
 (0)