Skip to content
Snippets Groups Projects
Verified Commit 6d74c642 authored by Thomas Lambert's avatar Thomas Lambert :helicopter:
Browse files

test: add tests for selig and lednicer

parent e57ca58e
No related branches found
No related tags found
No related merge requests found
Pipeline #6229 passed
......@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Unit tests for **utils.selig** and **utils.lednicer**
### Changed
### Deprecated
......
% TEST_LEDNICER Unitary tests for the lednicer sub-function
% Note:
% Matlab package functionality is not very test-framework friendly.
% Either the whole package has to be imported in EVERY SINGLE TEST or the
% functions must be called as <package>.function() everytime.
% The second option is preferred for the tests as it has the smaller scope.
%
% -----
% (c) Copyright 2022 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% Apache 2.0 License
% https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox
% --------------------------------------------------------------------------------------------------
%% Main test function
function tests = test_lednicer
tests = functiontests(localfunctions);
end
%% Setup and teardown
function setupOnce(testCase)
addpath('../.'); % Add repository to Matlab Path
addpath('./test_utils'); % Add utils to Matlab Path
% Set random number generator settings
testCase.TestData.currentRNG = rng;
end
function teardownOnce(testCase)
rmpath('../.'); % Remove repository from Matlab Path
rmpath('./test_utils'); % Remove utils from Matlab Path
% Restore the random number generator settings
s = testCase.TestData.currentRNG;
rng(s);
end
function teardown(~)
close all; % Close all figures that would have been openend
end
%% Test for correct output
function test_scalar(testCase)
% If input is scalar, output should be same scalar
x = (0:0.1:1)';
yup = x;
ylow = -x;
upper = [x, yup];
lower = [x, ylow];
coord = af_tools.utils.lednicer(upper, lower);
verifyEqual(testCase, coord, [upper; lower]);
end
% TEST_SELIG Unitary tests for the selig sub-function
% Note:
% Matlab package functionality is not very test-framework friendly.
% Either the whole package has to be imported in EVERY SINGLE TEST or the
% functions must be called as <package>.function() everytime.
% The second option is preferred for the tests as it has the smaller scope.
%
% -----
% (c) Copyright 2022 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% Apache 2.0 License
% https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox
% --------------------------------------------------------------------------------------------------
%% Main test function
function tests = test_selig
tests = functiontests(localfunctions);
end
%% Setup and teardown
function setupOnce(testCase)
addpath('../.'); % Add repository to Matlab Path
addpath('./test_utils'); % Add utils to Matlab Path
% Set random number generator settings
testCase.TestData.currentRNG = rng;
end
function teardownOnce(testCase)
rmpath('../.'); % Remove repository from Matlab Path
rmpath('./test_utils'); % Remove utils from Matlab Path
% Restore the random number generator settings
s = testCase.TestData.currentRNG;
rng(s);
end
function teardown(~)
close all; % Close all figures that would have been openend
end
%% Test for correct output
function test_scalar(testCase)
% If input is scalar, output should be same scalar
x = (0:0.1:1)';
yup = x;
ylow = -x;
upper = [x, yup];
lower = [x, ylow];
coord = af_tools.utils.selig(upper, lower);
verifyEqual(testCase, coord, [flipud(upper); lower(2:end, :)]);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment