Skip to content

Commit 35fb57e

Browse files
committed
refactor: Modularize 8 ocp test files
- test_constraints.jl: Wrap in TestOCPConstraints module - test_dynamics.jl: Wrap in TestOCPDynamics module - test_model.jl: Wrap in TestOCPModel module - test_objective.jl: Wrap in TestOCPObjective module - test_ocp.jl: Wrap in TestOCP module - test_ocp_solution_types.jl: Wrap in TestOCPSolutionTypes module - test_solution.jl: Wrap in TestOCPSolution module - test_times.jl: Wrap in TestOCPTimes module All files now follow the standard test module pattern with VERBOSE/SHOWTIMING support. All 388 tests pass.
1 parent ffb4671 commit 35fb57e

8 files changed

Lines changed: 86 additions & 0 deletions

File tree

test/suite/ocp/test_constraints.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
module TestOCPConstraints
2+
3+
using Test
4+
using CTModels
5+
using CTBase
6+
using Main.TestOptions: VERBOSE, SHOWTIMING
7+
18
"""
29
test_constraints()
310
@@ -217,3 +224,7 @@ function test_constraints()
217224
end
218225
end
219226
end
227+
228+
end # module
229+
230+
test_constraints() = TestOCPConstraints.test_constraints()

test/suite/ocp/test_dynamics.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
module TestOCPDynamics
2+
3+
using Test
4+
using CTModels
5+
using CTBase
6+
using Main.TestOptions: VERBOSE, SHOWTIMING
7+
18
function test_partial_dynamics()
29

310
# Sample full dynamics function for comparison
@@ -291,3 +298,7 @@ function test_dynamics()
291298
test_full_dynamics()
292299
test_partial_dynamics()
293300
end
301+
302+
end # module
303+
304+
test_dynamics() = TestOCPDynamics.test_dynamics()

test/suite/ocp/test_model.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
module TestOCPModel
2+
3+
using Test
4+
using CTModels
5+
using CTBase
6+
using Main.TestOptions: VERBOSE, SHOWTIMING
7+
18
function test_model()
29

310
# create a pre-model
@@ -194,3 +201,7 @@ function test_model()
194201
io = IOBuffer()
195202
show(io, MIME"text/plain"(), pre_ocp)
196203
end
204+
205+
end # module
206+
207+
test_model() = TestOCPModel.test_model()

test/suite/ocp/test_objective.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
module TestOCPObjective
2+
3+
using Test
4+
using CTModels
5+
using CTBase
6+
using Main.TestOptions: VERBOSE, SHOWTIMING
7+
18
function test_objective()
29

310
# is concretetype
@@ -151,3 +158,7 @@ function test_objective()
151158
@test CTModels.is_lagrange_cost_defined(obj_bolza) === true
152159
end
153160
end
161+
162+
end # module
163+
164+
test_objective() = TestOCPObjective.test_objective()

test/suite/ocp/test_ocp.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
module TestOCP
2+
3+
using Test
4+
using CTModels
5+
using CTBase
6+
using Main.TestOptions: VERBOSE, SHOWTIMING
7+
18
function test_ocp()
29

310
#
@@ -399,3 +406,7 @@ function test_ocp()
399406
io = IOBuffer()
400407
show(io, MIME"text/plain"(), ocp)
401408
end
409+
410+
end # module
411+
412+
test_ocp() = TestOCP.test_ocp()

test/suite/ocp/test_ocp_solution_types.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
module TestOCPSolutionTypes
2+
3+
using Test
4+
using CTModels
5+
using Main.TestOptions: VERBOSE, SHOWTIMING
6+
17
function test_ocp_solution_types()
28
# TODO: add tests for src/core/types/ocp_solution.jl.
39

@@ -211,3 +217,7 @@ function test_ocp_solution_types()
211217
Test.@test summary.objective == 42.0
212218
end
213219
end
220+
221+
end # module
222+
223+
test_ocp_solution_types() = TestOCPSolutionTypes.test_ocp_solution_types()

test/suite/ocp/test_solution.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
module TestOCPSolution
2+
3+
using Test
4+
using CTModels
5+
using Main.TestOptions: VERBOSE, SHOWTIMING
6+
17
function test_solution()
28

39
# create an ocp
@@ -266,3 +272,7 @@ function test_solution()
266272
@test CTModels.dual(sol_, ocp, :variable_rg) == [1.0, 2.0] - (-[1.0, 2.0])
267273
end
268274
end
275+
276+
end # module
277+
278+
test_solution() = TestOCPSolution.test_solution()

test/suite/ocp/test_times.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
module TestOCPTimes
2+
3+
using Test
4+
using CTModels
5+
using CTBase
6+
using Main.TestOptions: VERBOSE, SHOWTIMING
7+
18
struct FakeTimeVector{T} <: AbstractVector{T}
29
data::Vector{T}
310
end
@@ -175,3 +182,7 @@ function test_times()
175182
@test CTModels.is_final_time_free(times_free_tf) == true
176183
end
177184
end
185+
186+
end # module
187+
188+
test_times() = TestOCPTimes.test_times()

0 commit comments

Comments
 (0)