File size: 4,040 Bytes
5ab75a9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | classdef (SharedTestFixtures = { ...
matlab.unittest.fixtures.PathFixture('../') ...
matlab.unittest.fixtures.PathFixture('../src') ...
matlab.unittest.fixtures.PathFixture('../../Utils/AugmentedMath') ...
matlab.unittest.fixtures.PathFixture('../../Utils/General') ...
matlab.unittest.fixtures.PathFixture('../../Utils/LoggingAndStringReporting') ...
matlab.unittest.fixtures.PathFixture('../../Utils/Plotting') ...
}) ...
EvaluateLightPollutionUnitTest < matlab.unittest.TestCase
% EvaluateLightPollutionUnitTest - Unit Test for EvaluateLightPollution
%
% Syntax: results = runtests('EvaluateLightPollutionUnitTest')
%
% =========================================================================
%
% Copyright (c) 2024 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================
%
% Initial version: Nov 2024; Latest update: Nov 2024
%
% ----------------- BEGIN CODE -----------------
methods (Test)
function testLightPollutionEvaluation(testCase)
% Load expected outputs
ExpectedOutputs = load('ExpectedOutputs.mat').ExpectedOutputs;
% Run test case
output = run_EvaluateLightPollution_Test();
% Verify all outputs
testCase.verifyEqual(output.EvalTable, ExpectedOutputs.EvalTable, 'AbsTol', 1e-10);
testCase.verifyEqual(output.Fbright, ExpectedOutputs.Fbright, 'AbsTol', 1e-10);
testCase.verifyEqual(output.LightPollutionLevel, ExpectedOutputs.LightPollutionLevel, 'AbsTol', 1e-10);
testCase.verifyEqual(output.LightPollutionRisk, ExpectedOutputs.LightPollutionRisk);
testCase.verifyEqual(output.RedesignRecommendedFlag, ExpectedOutputs.RedesignRecommendedFlag);
testCase.verifyEqual(output.LowLatEvalTable, ExpectedOutputs.LowLatEvalTable, 'AbsTol', 1e-10);
testCase.verifyEqual(output.MidLatEvalTable, ExpectedOutputs.MidLatEvalTable, 'AbsTol', 1e-10);
testCase.verifyEqual(output.HighLatEvalTable, ExpectedOutputs.HighLatEvalTable, 'AbsTol', 1e-10);
% Cleanup outputs
cleanup
end
end
end
function Output = run_EvaluateLightPollution_Test
% Set up test parameters
params.New.Nc = 1584;
params.New.Altitude_km = 550;
params.New.Inclination_deg = 53.0;
params.New.Mzen50 = 6.12;
params.New.Mzen05 = 6.67;
params.New.Mzen95 = 4.68;
params.New.MzenAltkm = 550;
params.Evaluation.SDAPoints = [0 45];
% Suppress plots and output files (not needed for unit test)
params.Plotting.On = false;
params.Output.WriteMetricVsSDATable = false;
params.Output.WriteEvalReport = false;
params.Output.WriteEvalTable = false;
% Execute EvaluateLightPollution
Output = EvaluateLightPollution(params);
end
function cleanup
clear ans example examples failures i ME paramPath printStatement;
if exist('output', 'dir')
rmdir('output','s');
end
end
% ----------------- END OF CODE -------------------------------------------
%
% Please record any changes to the software in the change history
% shown below:
%
% ----------------- CHANGE HISTORY ----------------------------------------
% Developer | Date | Description
% -------------------------------------------------------------------------
% J.Halpin | 11-25-24 | Initial development of unit test
% =========================================================================
%
% Copyright (c)�2024�United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% ========================================================================= |