Skip to content

Commit 3ea322d

Browse files
committed
Stronger tests
1 parent 6ff16a0 commit 3ea322d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/components.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function check_contract(sys)
1919
end
2020

2121
function check_rc_sol(sol)
22+
rpi = sol[rc_model.resistor.p.i]
23+
@test any(!isequal(rpi[1]), rpi) # test that we don't have a constant system
2224
@test sol[rc_model.resistor.p.i] == sol[resistor.p.i] == sol[capacitor.p.i]
2325
@test sol[rc_model.resistor.n.i] == sol[resistor.n.i] == -sol[capacitor.p.i]
2426
@test sol[rc_model.capacitor.n.i] == sol[capacitor.n.i] == -sol[capacitor.p.i]
@@ -31,8 +33,9 @@ end
3133
include("../examples/rc_model.jl")
3234

3335
@test ModelingToolkit.n_extra_equations(capacitor) == 2
34-
@test length(equations(structural_simplify(rc_model, allow_parameter = false))) > 1
36+
@test length(equations(structural_simplify(rc_model, allow_parameter = false))) == 2
3537
sys = structural_simplify(rc_model)
38+
@test length(equations(sys)) == 1
3639
check_contract(sys)
3740
@test !isempty(ModelingToolkit.defaults(sys))
3841
u0 = [capacitor.v => 0.0
@@ -141,6 +144,7 @@ sol = solve(prob, Tsit5())
141144

142145
include("../examples/serial_inductor.jl")
143146
sys = structural_simplify(ll_model)
147+
@test length(equations(sys)) == 2
144148
check_contract(sys)
145149
u0 = states(sys) .=> 0
146150
@test_nowarn ODEProblem(sys, u0, (0, 10.0))

0 commit comments

Comments
 (0)