Skip to content

Commit 18fb75d

Browse files
authored
Merge pull request #100 from control-toolbox/add-ctparser
add CTParser for tests
2 parents 0a1a773 + 11cd86c commit 18fb75d

3 files changed

Lines changed: 136 additions & 135 deletions

File tree

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[deps]
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
33
CTBase = "54762871-cc72-4466-b8e8-f6c8b58076cd"
4+
CTParser = "32681960-a1b1-40db-9bff-a1ca817385d1"
45
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
56
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
67
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ using Aqua
33
using CTBase
44
using CTModels
55

6-
# import CTParser: CTParser, @def
7-
# CTParser.set_prefix(:CTModels); # code generated by @def is prefixed by CTModels (not by OptimalControl - the default)
6+
import CTParser: CTParser, @def
7+
CTParser.set_prefix(:CTModels); # code generated by @def is prefixed by CTModels (not by OptimalControl - the default)
88

99
#
1010
include("solution_example.jl")
11-
#include("solution_example_path_constraints.jl")
11+
include("solution_example_path_constraints.jl")
1212

1313
#
1414
@testset verbose = true showtiming = true "CTModels tests" begin

test/test_plot.jl

Lines changed: 132 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -79,143 +79,143 @@ function test_plot()
7979
#
8080
@test display(sol) isa Nothing
8181

82-
# # --------------------------------------------------------
83-
# # --------------------------------------------------------
84-
# # other example with path constraints
85-
# ocp, sol = solution_example_path_constraints()
86-
87-
# #
88-
# @test plot(sol; time=:default) isa Plots.Plot
89-
# @test plot(sol; time=:normalize) isa Plots.Plot
90-
# @test plot(sol; time=:normalise) isa Plots.Plot
91-
# @test_throws CTBase.IncorrectArgument plot(sol; time=:wrong_choice)
92-
93-
# @test plot(sol, ocp; time=:default) isa Plots.Plot
94-
# @test plot(sol, ocp; time=:normalize) isa Plots.Plot
95-
# @test plot(sol, ocp; time=:normalise) isa Plots.Plot
96-
# @test_throws CTBase.IncorrectArgument plot(sol, ocp; time=:wrong_choice)
97-
98-
# #
99-
# @test plot(sol; layout=:group, control=:components) isa Plots.Plot
100-
# @test plot(sol; layout=:group, control=:norm) isa Plots.Plot
101-
# @test plot(sol; layout=:group, control=:all) isa Plots.Plot
102-
# @test_throws CTBase.IncorrectArgument plot(sol; layout=:group, control=:wrong_choice)
103-
104-
# @test plot(sol, ocp; layout=:group, control=:components) isa Plots.Plot
105-
# @test plot(sol, ocp; layout=:group, control=:norm) isa Plots.Plot
106-
# @test plot(sol, ocp; layout=:group, control=:all) isa Plots.Plot
107-
# @test_throws CTBase.IncorrectArgument plot(sol, ocp; layout=:group, control=:wrong_choice)
108-
109-
# #
110-
# @test plot(sol; layout=:split, control=:components) isa Plots.Plot
111-
# @test plot(sol; layout=:split, control=:norm) isa Plots.Plot
112-
# @test plot(sol; layout=:split, control=:all) isa Plots.Plot
113-
# @test_throws CTBase.IncorrectArgument plot(sol; layout=:split, control=:wrong_choice)
114-
115-
# @test plot(sol, ocp; layout=:split, control=:components) isa Plots.Plot
116-
# @test plot(sol, ocp; layout=:split, control=:norm) isa Plots.Plot
117-
# @test plot(sol, ocp; layout=:split, control=:all) isa Plots.Plot
118-
# @test_throws CTBase.IncorrectArgument plot(sol, ocp; layout=:split, control=:wrong_choice)
119-
120-
# #
121-
# @test plot(sol; layout=:split) isa Plots.Plot
122-
# @test plot(sol; layout=:group) isa Plots.Plot
123-
# @test_throws CTBase.IncorrectArgument plot(sol; layout=:wrong_choice)
124-
125-
# @test plot(sol, ocp; layout=:split) isa Plots.Plot
126-
# @test plot(sol, ocp; layout=:group) isa Plots.Plot
127-
# @test_throws CTBase.IncorrectArgument plot(sol, ocp; layout=:wrong_choice)
128-
129-
# #
130-
# plt = plot(sol; time=:default)
131-
# @test plot!(plt, sol; time=:default) isa Plots.Plot
132-
# @test plot!(plt, sol; time=:normalize) isa Plots.Plot
133-
# @test plot!(plt, sol; time=:normalise) isa Plots.Plot
134-
# @test_throws CTBase.IncorrectArgument plot!(plt, sol; time=:wrong_choice)
135-
136-
# plt = plot(sol, ocp; time=:default)
137-
# @test plot!(plt, sol, ocp; time=:default) isa Plots.Plot
138-
# @test plot!(plt, sol, ocp; time=:normalize) isa Plots.Plot
139-
# @test plot!(plt, sol, ocp; time=:normalise) isa Plots.Plot
140-
# @test_throws CTBase.IncorrectArgument plot!(plt, sol, ocp; time=:wrong_choice)
141-
142-
# #
143-
# plt = plot(sol; layout=:group, control=:components)
144-
# @test plot!(plt, sol; layout=:group, control=:components) isa Plots.Plot
145-
# @test plot!(plt, sol; layout=:group, control=:norm) isa Plots.Plot
146-
147-
# plt = plot(sol; layout=:group, control=:norm)
148-
# @test plot!(plt, sol; layout=:group, control=:components) isa Plots.Plot
149-
# @test plot!(plt, sol; layout=:group, control=:norm) isa Plots.Plot
150-
151-
# plt = plot(sol; layout=:group, control=:all)
152-
# @test plot!(plt, sol; layout=:group, control=:all) isa Plots.Plot
153-
154-
# @test_throws CTBase.IncorrectArgument plot!(
155-
# plt, sol; layout=:group, control=:wrong_choice
156-
# )
157-
158-
# plt = plot(sol, ocp; layout=:group, control=:components)
159-
# @test plot!(plt, sol, ocp; layout=:group, control=:components) isa Plots.Plot
160-
# @test plot!(plt, sol, ocp; layout=:group, control=:norm) isa Plots.Plot
161-
162-
# plt = plot(sol, ocp; layout=:group, control=:norm)
163-
# @test plot!(plt, sol, ocp; layout=:group, control=:components) isa Plots.Plot
164-
# @test plot!(plt, sol, ocp; layout=:group, control=:norm) isa Plots.Plot
165-
166-
# plt = plot(sol, ocp; layout=:group, control=:all)
167-
# @test plot!(plt, sol, ocp; layout=:group, control=:all) isa Plots.Plot
168-
169-
# @test_throws CTBase.IncorrectArgument plot!(
170-
# plt, sol, ocp; layout=:group, control=:wrong_choice
171-
# )
172-
173-
# #
174-
# plt = plot(sol, ocp; layout=:split, control=:components)
175-
# @test plot!(plt, sol, ocp; layout=:split, control=:components) isa Plots.Plot
176-
# @test plot!(plt, sol, ocp; layout=:split, control=:norm) isa Plots.Plot
177-
178-
# plt = plot(sol, ocp; layout=:split, control=:norm)
179-
# @test plot!(plt, sol, ocp; layout=:split, control=:components) isa Plots.Plot
180-
# @test plot!(plt, sol, ocp; layout=:split, control=:norm) isa Plots.Plot
181-
182-
# plt = plot(sol, ocp; layout=:split, control=:all)
183-
# @test plot!(plt, sol, ocp; layout=:split, control=:all) isa Plots.Plot
184-
185-
# @test_throws CTBase.IncorrectArgument plot!(
186-
# plt, sol, ocp; layout=:split, control=:wrong_choice
187-
# )
188-
189-
# plt = plot(sol, ocp; layout=:split, control=:components)
190-
# @test plot!(plt, sol, ocp; layout=:split, control=:components) isa Plots.Plot
191-
# @test plot!(plt, sol, ocp; layout=:split, control=:norm) isa Plots.Plot
192-
193-
# plt = plot(sol, ocp; layout=:split, control=:norm)
194-
# @test plot!(plt, sol, ocp; layout=:split, control=:components) isa Plots.Plot
195-
# @test plot!(plt, sol, ocp; layout=:split, control=:norm) isa Plots.Plot
196-
197-
# plt = plot(sol, ocp; layout=:split, control=:all)
198-
# @test plot!(plt, sol, ocp; layout=:split, control=:all) isa Plots.Plot
199-
200-
# @test_throws CTBase.IncorrectArgument plot!(
201-
# plt, sol, ocp; layout=:split, control=:wrong_choice
202-
# )
82+
# --------------------------------------------------------
83+
# --------------------------------------------------------
84+
# other example with path constraints
85+
ocp, sol = solution_example_path_constraints()
20386

204-
# #
205-
# plt = plot(sol; layout=:split)
206-
# @test plot!(plt, sol; layout=:split) isa Plots.Plot
87+
#
88+
@test plot(sol; time=:default) isa Plots.Plot
89+
@test plot(sol; time=:normalize) isa Plots.Plot
90+
@test plot(sol; time=:normalise) isa Plots.Plot
91+
@test_throws CTBase.IncorrectArgument plot(sol; time=:wrong_choice)
92+
93+
@test plot(sol, ocp; time=:default) isa Plots.Plot
94+
@test plot(sol, ocp; time=:normalize) isa Plots.Plot
95+
@test plot(sol, ocp; time=:normalise) isa Plots.Plot
96+
@test_throws CTBase.IncorrectArgument plot(sol, ocp; time=:wrong_choice)
97+
98+
#
99+
@test plot(sol; layout=:group, control=:components) isa Plots.Plot
100+
@test plot(sol; layout=:group, control=:norm) isa Plots.Plot
101+
@test plot(sol; layout=:group, control=:all) isa Plots.Plot
102+
@test_throws CTBase.IncorrectArgument plot(sol; layout=:group, control=:wrong_choice)
103+
104+
@test plot(sol, ocp; layout=:group, control=:components) isa Plots.Plot
105+
@test plot(sol, ocp; layout=:group, control=:norm) isa Plots.Plot
106+
@test plot(sol, ocp; layout=:group, control=:all) isa Plots.Plot
107+
@test_throws CTBase.IncorrectArgument plot(sol, ocp; layout=:group, control=:wrong_choice)
108+
109+
#
110+
@test plot(sol; layout=:split, control=:components) isa Plots.Plot
111+
@test plot(sol; layout=:split, control=:norm) isa Plots.Plot
112+
@test plot(sol; layout=:split, control=:all) isa Plots.Plot
113+
@test_throws CTBase.IncorrectArgument plot(sol; layout=:split, control=:wrong_choice)
114+
115+
@test plot(sol, ocp; layout=:split, control=:components) isa Plots.Plot
116+
@test plot(sol, ocp; layout=:split, control=:norm) isa Plots.Plot
117+
@test plot(sol, ocp; layout=:split, control=:all) isa Plots.Plot
118+
@test_throws CTBase.IncorrectArgument plot(sol, ocp; layout=:split, control=:wrong_choice)
119+
120+
#
121+
@test plot(sol; layout=:split) isa Plots.Plot
122+
@test plot(sol; layout=:group) isa Plots.Plot
123+
@test_throws CTBase.IncorrectArgument plot(sol; layout=:wrong_choice)
124+
125+
@test plot(sol, ocp; layout=:split) isa Plots.Plot
126+
@test plot(sol, ocp; layout=:group) isa Plots.Plot
127+
@test_throws CTBase.IncorrectArgument plot(sol, ocp; layout=:wrong_choice)
128+
129+
#
130+
plt = plot(sol; time=:default)
131+
@test plot!(plt, sol; time=:default) isa Plots.Plot
132+
@test plot!(plt, sol; time=:normalize) isa Plots.Plot
133+
@test plot!(plt, sol; time=:normalise) isa Plots.Plot
134+
@test_throws CTBase.IncorrectArgument plot!(plt, sol; time=:wrong_choice)
135+
136+
plt = plot(sol, ocp; time=:default)
137+
@test plot!(plt, sol, ocp; time=:default) isa Plots.Plot
138+
@test plot!(plt, sol, ocp; time=:normalize) isa Plots.Plot
139+
@test plot!(plt, sol, ocp; time=:normalise) isa Plots.Plot
140+
@test_throws CTBase.IncorrectArgument plot!(plt, sol, ocp; time=:wrong_choice)
141+
142+
#
143+
plt = plot(sol; layout=:group, control=:components)
144+
@test plot!(plt, sol; layout=:group, control=:components) isa Plots.Plot
145+
@test plot!(plt, sol; layout=:group, control=:norm) isa Plots.Plot
146+
147+
plt = plot(sol; layout=:group, control=:norm)
148+
@test plot!(plt, sol; layout=:group, control=:components) isa Plots.Plot
149+
@test plot!(plt, sol; layout=:group, control=:norm) isa Plots.Plot
150+
151+
plt = plot(sol; layout=:group, control=:all)
152+
@test plot!(plt, sol; layout=:group, control=:all) isa Plots.Plot
153+
154+
@test_throws CTBase.IncorrectArgument plot!(
155+
plt, sol; layout=:group, control=:wrong_choice
156+
)
157+
158+
plt = plot(sol, ocp; layout=:group, control=:components)
159+
@test plot!(plt, sol, ocp; layout=:group, control=:components) isa Plots.Plot
160+
@test plot!(plt, sol, ocp; layout=:group, control=:norm) isa Plots.Plot
161+
162+
plt = plot(sol, ocp; layout=:group, control=:norm)
163+
@test plot!(plt, sol, ocp; layout=:group, control=:components) isa Plots.Plot
164+
@test plot!(plt, sol, ocp; layout=:group, control=:norm) isa Plots.Plot
165+
166+
plt = plot(sol, ocp; layout=:group, control=:all)
167+
@test plot!(plt, sol, ocp; layout=:group, control=:all) isa Plots.Plot
168+
169+
@test_throws CTBase.IncorrectArgument plot!(
170+
plt, sol, ocp; layout=:group, control=:wrong_choice
171+
)
172+
173+
#
174+
plt = plot(sol, ocp; layout=:split, control=:components)
175+
@test plot!(plt, sol, ocp; layout=:split, control=:components) isa Plots.Plot
176+
@test plot!(plt, sol, ocp; layout=:split, control=:norm) isa Plots.Plot
177+
178+
plt = plot(sol, ocp; layout=:split, control=:norm)
179+
@test plot!(plt, sol, ocp; layout=:split, control=:components) isa Plots.Plot
180+
@test plot!(plt, sol, ocp; layout=:split, control=:norm) isa Plots.Plot
181+
182+
plt = plot(sol, ocp; layout=:split, control=:all)
183+
@test plot!(plt, sol, ocp; layout=:split, control=:all) isa Plots.Plot
184+
185+
@test_throws CTBase.IncorrectArgument plot!(
186+
plt, sol, ocp; layout=:split, control=:wrong_choice
187+
)
188+
189+
plt = plot(sol, ocp; layout=:split, control=:components)
190+
@test plot!(plt, sol, ocp; layout=:split, control=:components) isa Plots.Plot
191+
@test plot!(plt, sol, ocp; layout=:split, control=:norm) isa Plots.Plot
192+
193+
plt = plot(sol, ocp; layout=:split, control=:norm)
194+
@test plot!(plt, sol, ocp; layout=:split, control=:components) isa Plots.Plot
195+
@test plot!(plt, sol, ocp; layout=:split, control=:norm) isa Plots.Plot
207196

208-
# plt = plot(sol; layout=:group)
209-
# @test plot!(plt, sol; layout=:group) isa Plots.Plot
197+
plt = plot(sol, ocp; layout=:split, control=:all)
198+
@test plot!(plt, sol, ocp; layout=:split, control=:all) isa Plots.Plot
210199

211-
# @test_throws CTBase.IncorrectArgument plot!(plt, sol; layout=:wrong_choice)
200+
@test_throws CTBase.IncorrectArgument plot!(
201+
plt, sol, ocp; layout=:split, control=:wrong_choice
202+
)
203+
204+
#
205+
plt = plot(sol; layout=:split)
206+
@test plot!(plt, sol; layout=:split) isa Plots.Plot
207+
208+
plt = plot(sol; layout=:group)
209+
@test plot!(plt, sol; layout=:group) isa Plots.Plot
210+
211+
@test_throws CTBase.IncorrectArgument plot!(plt, sol; layout=:wrong_choice)
212212

213-
# plt = plot(sol, ocp; layout=:split)
214-
# @test plot!(plt, sol, ocp; layout=:split) isa Plots.Plot
213+
plt = plot(sol, ocp; layout=:split)
214+
@test plot!(plt, sol, ocp; layout=:split) isa Plots.Plot
215215

216-
# plt = plot(sol, ocp; layout=:group)
217-
# @test plot!(plt, sol, ocp; layout=:group) isa Plots.Plot
216+
plt = plot(sol, ocp; layout=:group)
217+
@test plot!(plt, sol, ocp; layout=:group) isa Plots.Plot
218218

219-
# @test_throws CTBase.IncorrectArgument plot!(plt, sol, ocp; layout=:wrong_choice)
219+
@test_throws CTBase.IncorrectArgument plot!(plt, sol, ocp; layout=:wrong_choice)
220220

221221
end

0 commit comments

Comments
 (0)