From 5a44d8d4d638efb9f61ef94ae080f8a8e0f0b990 Mon Sep 17 00:00:00 2001
From: LolloBici <lorenzo.amici@skywarder.eu>
Date: Wed, 11 Jun 2025 15:39:53 +0200
Subject: [PATCH] [unit-test-updates] Moved simulator test type selection from
 saveTests to unitTestConfig

---
 unitTests/UnitTestConfig.m                    |  4 +---
 .../testSimulator/HRE/referenceState_HRE.mat  |  4 ++--
 .../ballistic/referenceState_ballistic.mat    |  4 ++--
 .../engineCut/referenceState_engineCut.mat    |  4 ++--
 .../multipleAB/referenceState_multipleAB.mat  |  4 ++--
 .../solid/referenceState_solid.mat            |  4 ++--
 unitTests/saveTests.m                         | 15 ++++++---------
 unitTests/tests/TestSimulator.m               | 19 +++----------------
 8 files changed, 20 insertions(+), 38 deletions(-)

diff --git a/unitTests/UnitTestConfig.m b/unitTests/UnitTestConfig.m
index 0a2f0208..b37ab83b 100644
--- a/unitTests/UnitTestConfig.m
+++ b/unitTests/UnitTestConfig.m
@@ -11,12 +11,10 @@ opt.testApogeeAnalysis = false;
 opt.testOptimization = false;
 opt.testSensitivity = false;
 
-
 %% UNIT TEST TO CREATE
 % choose which folders to create data for
-opt.saveTestSimulator = true;
+opt.saveTestSimulator = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'};       % Select the simulator tests to perform
 % opt.createTestCommonFunction = true;
 opt.saveTestApogeeAnalysis = false;
 opt.saveTestOptimization = false;
 opt.saveTestSensitivity = false;
-
diff --git a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat
index 481f5873..d1f3b29a 100644
--- a/unitTests/data/testSimulator/HRE/referenceState_HRE.mat
+++ b/unitTests/data/testSimulator/HRE/referenceState_HRE.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:7b93d349359893dc6b10a2959cb2b70f71ff1a4902280a50e795dde74db36285
-size 80208047
+oid sha256:8d44e6c60b057002f63ce0429a9c087f1bed08ab0aa14274f4dc2c1abf9700df
+size 80254417
diff --git a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat
index 1327f8c0..4b1b43c2 100644
--- a/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat
+++ b/unitTests/data/testSimulator/ballistic/referenceState_ballistic.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:db69488a839d1cbf7b6d1db8e05af0016098cc3910eb9c3fc95a076e126d48cd
-size 80208047
+oid sha256:c28b587fa822511881f0cca4502b512f6616c89bcb4587a263d264a5324c41cf
+size 80254417
diff --git a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat
index 0a01760d..61ed5521 100644
--- a/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat
+++ b/unitTests/data/testSimulator/engineCut/referenceState_engineCut.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:47a3834687056548eff3dd4e27da6a749687a78d052b85a3a589d46876d0e8e8
-size 80208047
+oid sha256:b248789765f30a8a556cde4222e5fd529e799d8f5718ea68d58746b1f5343aaf
+size 80254417
diff --git a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat
index 1cc02991..026b1ae5 100644
--- a/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat
+++ b/unitTests/data/testSimulator/multipleAB/referenceState_multipleAB.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:dac6eb6f3c456a77a3e4241643983218cad47f1dee15fc17317514dfbd581a2f
-size 80895844
+oid sha256:fbf1a2a08c2e412f580bb6080c03252451b950bcfdea85b10d8bc8b9b004167b
+size 80909350
diff --git a/unitTests/data/testSimulator/solid/referenceState_solid.mat b/unitTests/data/testSimulator/solid/referenceState_solid.mat
index e3e14a40..3f6dc484 100644
--- a/unitTests/data/testSimulator/solid/referenceState_solid.mat
+++ b/unitTests/data/testSimulator/solid/referenceState_solid.mat
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:d53b91bbb63edf70664108f16f383fd1f45289191bb675ac3713089da1a68b4e
-size 80208047
+oid sha256:3e87e622e0ac53cb9739316eaa723168f7a3496496b41e70989e80593d2d79b4
+size 80254417
diff --git a/unitTests/saveTests.m b/unitTests/saveTests.m
index fd096d82..763640b3 100644
--- a/unitTests/saveTests.m
+++ b/unitTests/saveTests.m
@@ -21,10 +21,9 @@ if isempty(rocket), rocket  = Rocket(mission); end
 if isempty(environment), environment  = Environment(mission, rocket.motor); end
 if isempty(wind), wind  = Wind(mission); end
 if isempty(settings)
-            simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m');
-            %odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings ', 'odeConfig.m');
-            settings  = Settings(simPath, 'ode','unitTest');
-           
+    simPath = fullfile(fileparts(mfilename('fullpath')),'..', 'simulator', 'simulatorConfig.m');
+    %odePath = fullfile(fileparts(mfilename('fullpath')), '..', '..', 'common', 'settings ', 'odeConfig.m');
+    settings  = Settings(simPath, 'ode','unitTest');
 end
 Settings.read(settings, options, 'opt');
 
@@ -32,14 +31,12 @@ Settings.read(settings, options, 'opt');
 
 
 %% CREATING SIMULATOR TESTS
-if settings.opt.saveTestSimulator
-    verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'};
-    for k = 1:length(verifiable)
-        TestSimulator.saveTest(verifiable{k}, mission,rocket, wind, environment, settings );
+if ~isempty(settings.opt.saveTestSimulator)
+    for k = 1:length(settings.opt.saveTestSimulator)
+        TestSimulator.saveTest(settings.opt.saveTestSimulator{k}, mission, rocket, wind, environment, settings );
     end
 end
 
-
 % %% TEST COMMONFUNCTIONS
 % if opt.createTestCommonFunction
 %     vars.mach = 0.05:0.05:1;
diff --git a/unitTests/tests/TestSimulator.m b/unitTests/tests/TestSimulator.m
index c6fde689..061a3b4c 100644
--- a/unitTests/tests/TestSimulator.m
+++ b/unitTests/tests/TestSimulator.m
@@ -1,7 +1,5 @@
 classdef TestSimulator < UnitTest
 
-    % TEST FUNZIONANTE, DA RISOLVERE PATH PER simulatorConfig.m in saveTest
-
     properties
         settings
         refSimulator
@@ -11,10 +9,7 @@ classdef TestSimulator < UnitTest
         verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'};
     end
 
-    % properties (TestParameter)
-    %     verifiable = {'multipleAB', 'ballistic', 'engineCut', 'solid', 'HRE'};
-    % end
-
+    
     methods (TestMethodSetup)
         function setup(testCase, verifiable)
             currentPath = fileparts(mfilename('fullpath'));
@@ -45,18 +40,13 @@ classdef TestSimulator < UnitTest
     end
 
     methods (Test)
-        function mainSimulatorTest(testCase, verifiable)
-            
-            % testCase.createTest(verifiable);
-            
+        function mainSimulatorTest(testCase)            
             mainSimPath = fullfile('..', '..', 'simulator');
             addpath(genpath(mainSimPath));
 
             % Run main simulator
             [postp.stateA, postp.stateF] = mainSimulator(testCase.rocket, testCase.wind, testCase.environment, testCase.settings);
             
-            max(abs(postp.stateA.state.Y(3,:)))      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
             % Verify results
             testCase.verifyEqual(postp, testCase.refSimulator);
         end
@@ -68,15 +58,12 @@ classdef TestSimulator < UnitTest
             currentPath = fileparts(mfilename('fullpath'));
             addpath(genpath(currentPath));
 
-
             disp('Started saving simulator tests')
 
-
             if strcmp(verifiable, 'ballistic')
                 settings.simulator.ballistic = 1;
                 settings.simulator.parafoil = 0;
             end
-
             
             if verifiable == "multipleAB"
                 rocket.airbrakes.enabled = 1;
@@ -87,7 +74,7 @@ classdef TestSimulator < UnitTest
             % end
            
             % simulator
-            [stateA, stateF, settings] = mainSimulator(rocket, wind, environment, settings,'unitTest',true);
+            [stateA, stateF, settings] = mainSimulator(rocket, wind, environment, settings, 'unitTest', true);
 
             % Save final state
             fileName = sprintf("referenceState_%s.mat", verifiable);
-- 
GitLab