Skip to content

Commit c82eb54

Browse files
committed
new unit tests for some uncovered lines
1 parent 0ae316a commit c82eb54

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
docs/build/
33
JuliaSysimage.so
44
LocalPreferences.toml
5-
.vscode/
5+
.vscode/
6+
*.cov

docs/src/internals/sim_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SimModel Internals
1+
# Functions: SimModel Internals
22

33
```@docs
44
ModelPredictiveControl.steadystate

test/test_sim_model.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,17 @@ Gss2 = c2d(sys_ss[:,1:2], 0.5Ts, :zoh)
5555
@test linmodel6.nx == 6
5656
@test sum(eigvals(linmodel6.A) .≈ 0) == 2
5757

58+
linmodel7 = LinModel(
59+
ss(diagm( .1: .1: .3), I(3), diagm( .4: .1: .6), 0, 1.0),
60+
i_u=[1, 2],
61+
i_d=[3])
62+
@test linmodel7.A diagm( .1: .1: .3)
63+
@test linmodel7.C diagm( .4: .1: .6)
64+
5865
@test_throws ErrorException LinModel(sys)
5966
@test_throws ErrorException LinModel(sys,-Ts)
6067
@test_throws ErrorException LinModel(sys,Ts,i_u=[1,1])
68+
@test_throws ErrorException LinModel(sys,Ts,i_d=[3,3])
6169
@test_throws ErrorException LinModel(sys_ss,Ts+1)
6270
@test_throws ErrorException setop!(linmodel5, uop=[0,0,0,0,0])
6371
@test_throws ErrorException setop!(linmodel5, yop=[0,0,0,0,0])

test/test_state_estim.jl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ end
124124
@test_throws ErrorException Luenberger(linmodel1, nint_ym=[-1,0])
125125
@test_throws ErrorException Luenberger(linmodel1, p̂=[0.5])
126126
@test_throws ErrorException Luenberger(linmodel1, p̂=fill(1.5, lo1.nx̂))
127-
end
127+
@test_throws ErrorException Luenberger(LinModel(tf(1,[1, 0]),0.1), p̂=[0.5,0.6])
128+
end
128129

129130
@testset "Luenberger estimator methods" begin
130131
linmodel1 = setop!(LinModel(sys,Ts,i_u=[1,2]), uop=[10,50], yop=[50,30])
@@ -176,10 +177,10 @@ end
176177
@test internalmodel5.nyu == 0
177178
@test internalmodel5.nxs == 4
178179
@test internalmodel5.nx̂ == 4
179-
@test internalmodel5.As == stoch_ym_ss.A
180-
@test internalmodel5.Bs == stoch_ym_ss.B
181-
@test internalmodel5.Cs == stoch_ym_ss.C
182-
@test internalmodel5.Ds == stoch_ym_ss.D
180+
@test internalmodel5.As stoch_ym_ss.A
181+
@test internalmodel5.Bs stoch_ym_ss.B
182+
@test internalmodel5.Cs stoch_ym_ss.C
183+
@test internalmodel5.Ds stoch_ym_ss.D
183184

184185
stoch_ym_resample = c2d(d2c(ss(1,1,1,1,linmodel2.Ts), :tustin), 2linmodel2.Ts, :tustin)
185186
internalmodel6 = InternalModel(linmodel2, i_ym=[2], stoch_ym=stoch_ym_resample)
@@ -188,6 +189,14 @@ end
188189
@test internalmodel6.Cs internalmodel2.Cs
189190
@test internalmodel6.Ds internalmodel2.Ds
190191

192+
stoch_ym_cont = ss(zeros(2,2), I(2), I(2), zeros(2,2))
193+
stoch_ym_disc = c2d(stoch_ym_cont, linmodel2.Ts, :tustin)
194+
internalmodel7 = InternalModel(linmodel2, stoch_ym=stoch_ym_cont)
195+
@test internalmodel7.As stoch_ym_disc.A
196+
@test internalmodel7.Bs stoch_ym_disc.B
197+
@test internalmodel7.Cs stoch_ym_disc.C
198+
@test internalmodel7.Ds stoch_ym_disc.D
199+
191200
unstablemodel = LinModel(ss(diagm([0.5, -0.5, 1.5]), ones(3,1), I, 0, 1))
192201
@test_throws ErrorException InternalModel(unstablemodel)
193202
@test_throws ErrorException InternalModel(linmodel1, i_ym=[1,4])

0 commit comments

Comments
 (0)