diff --git a/CHANGELOG.md b/CHANGELOG.md index a1da4f7b8dccffa767dff218e05139692de956fa..eaaf910ecac260e5f9c4a30d0a80162faf3a5f23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/tests/test_lednicer.m b/tests/test_lednicer.m new file mode 100644 index 0000000000000000000000000000000000000000..772123b96d3b7fd89506206fb48b854cddfca676 --- /dev/null +++ b/tests/test_lednicer.m @@ -0,0 +1,69 @@ +% 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 diff --git a/tests/test_selig.m b/tests/test_selig.m new file mode 100644 index 0000000000000000000000000000000000000000..ffa89fe957ae4551765229184cf3204f78e785c0 --- /dev/null +++ b/tests/test_selig.m @@ -0,0 +1,69 @@ +% 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