From 4d49475f7b69a16a58acbdd82486ccc541a2fcb5 Mon Sep 17 00:00:00 2001
From: Thomas Lambert <t.lambert@uliege.be>
Date: Mon, 6 Jun 2022 21:34:03 +0200
Subject: [PATCH] refactor!: Change parsefileinputs

The previous way of doing stuff was not allowing to load files from
multiple (sub)directories. This commits allows the user to specify
files from various directories as a string array.

BREAKING: This commit changes the input arguments for **xf2mat** and
**formatairfoilcoord**.
---
 +af_tools/+utils/parsefileinputs.m | 82 ++++++------------------------
 +af_tools/formatairfoilcoord.m     | 29 +++++------
 +af_tools/xf2mat.m                 | 24 ++++-----
 CHANGELOG.md                       |  9 +++-
 README.md                          | 16 +++---
 tests/test_formatairfoilcoord.m    | 78 ++++++++++++++--------------
 tests/test_parsefileinputs.m       | 19 ++-----
 tests/test_xf2mat.m                | 41 +++++++--------
 8 files changed, 111 insertions(+), 187 deletions(-)

diff --git a/+af_tools/+utils/parsefileinputs.m b/+af_tools/+utils/parsefileinputs.m
index 7964f65..0e69edc 100644
--- a/+af_tools/+utils/parsefileinputs.m
+++ b/+af_tools/+utils/parsefileinputs.m
@@ -1,4 +1,4 @@
-function [filenames, filespath, idxOpts] = parsefileinputs(optList, filetype, varargin)
+function [filenames, filepaths, idxOpts] = parsefileinputs(optList, filetype, varargin)
     % PARSEFILEINPUTS Parses the input and checks their validity.
     %   Returns the filenames and filepaths for the input files, as well as the index where the
     %   remaining options start.
@@ -29,60 +29,50 @@ function [filenames, filespath, idxOpts] = parsefileinputs(optList, filetype, va
               filetype);
     end
 
-    % Constants and defaults
-    DEFAULT_INPUTFILES = '*';
-
     % Parse inputs
     hasNoInput = isempty(varargin) || isoption(optList, varargin{1});
     if hasNoInput
         % Prompt user to select files
         ext = ['*', filetype];
-        [filenames, filespath] = uigetfile(ext, 'Select all dat-files to aggregate', ...
+        [filenames, filepaths] = uigetfile(ext, 'Select all dat-files to aggregate', ...
                                            'MultiSelect', 'on');
         idxOpts = 1;
     else
-        inputDir = varargin{1};
         idxOpts = 2;
-        if nargin >= 4 && ~isoption(optList, varargin{2})
-            idxOpts = 3;
-            inputFiles = varargin{2};
-        else
-            inputFiles = DEFAULT_INPUTFILES;
-        end
 
-        % Validate inputs
-        validateinputdir(inputDir);
-        validateinputfiles(inputFiles);
+        % Check if filenames properly formatted
+        fullFiles = varargin{1};
+        validateattributes(fullFiles, {'char', 'cell'}, {'nonempty', 'vector'}, ...
+                           mfilename(), 'inputFiles', 3);
+        fullFiles = string(fullFiles);
 
         % ---------------------------------------
         % Look for files
+        AllFiles = [];
 
-        filespath = absolutepath(inputDir);
+        for i = 1:numel(fullFiles)
 
-        % Convert inputFiles to string for simpler handling
-        inputFiles = string(inputFiles);
+            file = appendextension(fullFiles(i), filetype); % Add extension
 
-        % Get all files
-        AllFiles = [];
-
-        for i = 1:length(inputFiles)
-            inputFiles(i) = appendextension(inputFiles(i), filetype); % Add extension
-            dummy = dir(fullfile(filespath, inputFiles(i)));
+            dummy = dir(file);  % List files properly
             if isempty(dummy)
                 warning('MATLAB:parsefileinputs:FileNotFound', ...
-                        'Could not find file %s.', fullfile(filespath, inputFiles(i)));
+                        'Could not find file %s.', fullFiles(i));
             end
+
             AllFiles = [AllFiles; dummy];
         end
-
         if isempty(AllFiles)
             error('MATLAB:parsefileinputs:noFilesFound', ...
                   'Impossible to find ANY file matching the input arguments.');
         end
 
+        % Output the proper file names and path
         filenames = cell(1, length(AllFiles));
+        filepaths = cell(1, length(AllFiles));
         for i = 1:length(AllFiles)
             filenames{i} = AllFiles(i).name;
+            filepaths{i} = AllFiles(i).folder;
         end
 
     end
@@ -99,43 +89,3 @@ function bool = isoption(optList, var)
         bool = any(strcmpi(var, optList));
     end
 end
-
-% --------------------------------------------------------------------------------------------------
-function abspath = absolutepath(directory)
-    % ABSOLUTEPATH Returns the absolute path to a directory
-
-    if contains(directory, pwd)
-        abspath = directory;
-    else
-        abspath = fullfile(pwd, directory);
-    end
-
-end
-
-% --------------------------------------------------------------------------------------------------
-function validateinputdir(inputDir)
-    % VALIDATEDIR Validates inputDir input.
-
-    validateattributes(inputDir, {'char', 'string'}, {'nonempty', 'vector'}, ...
-                       mfilename(), 'inputDir');
-
-    if ~exist(inputDir, 'dir')
-        error('MATLAB:parsefileinputs:dirNotFound', ...
-              'The directory specified as inputDir (%s) can not be found!\n', inputDir);
-    end
-end
-
-% --------------------------------------------------------------------------------------------------
-function validateinputfiles(inputFiles)
-    % VALIDATEDIR Validates inputDir input.
-
-    validateattributes(inputFiles, {'char', 'cell'}, {'nonempty', 'vector'}, ...
-                       mfilename(), 'inputFiles', 4);
-
-    if iscell(inputFiles) &&  ~iscellstr(inputFiles)
-        error('MATLAB:parsefileinputs:wrongInputFiles', ...
-              ['If inpuFiles is given as a cell array, '...
-               'it must contain only character vectors!\n']);
-    end
-
-end
diff --git a/+af_tools/formatairfoilcoord.m b/+af_tools/formatairfoilcoord.m
index 8bd986f..7d684b9 100644
--- a/+af_tools/formatairfoilcoord.m
+++ b/+af_tools/formatairfoilcoord.m
@@ -1,5 +1,5 @@
 function Dat = formatairfoilcoord(varargin)
-    % FORMATAIRFOILCOORD Re-format airfoil coordinates.
+    % FORMATAIRFOILCOORD Load and re-format airfoil coordinates.
     %   The UIUC airfoil database from the University of Illinois gathers the coordinates for more
     %   than 1600 airfoils. Two different standards are used to represent the coordinates of the
     %   airfoil:
@@ -33,10 +33,7 @@ function Dat = formatairfoilcoord(varargin)
     %   DAT = FORMATAIRFOILCOORD prompts the user for all inputs, then converts the coordinates to
     %   the Selig format.
     %
-    %   DAT = FORMATAIRFOILCOORD(INPUTDIR) converts all dat files found in INPUTDIR.
-    %
-    %   DAT = FORMATAIRFOILCOORD(INPUTDIR, INPUTFILES) converts only the polars specified by
-    %   INPUTFILES found in INPUTDIR.
+    %   DAT = FORMATAIRFOILCOORD(INPUTFILES) converts all files specified in INPUTFILES.
     %
     %   DAT = FORMATAIRFOILCOORD(..., 'autosave', true) saves the resulting coordinates in a new
     %   dat-file.
@@ -54,8 +51,7 @@ function Dat = formatairfoilcoord(varargin)
     %   Lednicer). Selig by default.
     %
     % Inputs:
-    %   inputDir   : Path of the directory with the UIUC oridinal dat-files
-    %   inputFiles : Files to select (ex: '*' (default), '*0012*', {'file1','file2'}, etc)
+    %   inputFiles : Files to select (ex: 'dir/file', 'subdir/*' , 'dir/*0012*', {'file1','file2'})
     %
     % Output:
     %   Dat : A structure for the results for each input file.
@@ -69,13 +65,12 @@ function Dat = formatairfoilcoord(varargin)
     %
     % Example:
     %   FORMATAIRFOILCOORD
-    %   FORMATAIRFOILCOORD('test_data')
-    %   FORMATAIRFOILCOORD('test_data', '*0012*')
-    %   FORMATAIRFOILCOORD('test_data', {'0012_re1e5', '0012_re1e6'})
-    %   FORMATAIRFOILCOORD('test_data', 'autosave', true)
-    %   FORMATAIRFOILCOORD('test_data', 'overwrite', true)
-    %   FORMATAIRFOILCOORD('test_data', 'refine', true)
-    %   FORMATAIRFOILCOORD('test_data', 'outputFormat', 'Lednicer')
+    %   FORMATAIRFOILCOORD('data/*0012*')
+    %   FORMATAIRFOILCOORD({'data/0012_re1e5', 'data/0012_re1e6'})
+    %   FORMATAIRFOILCOORD('test_data/*', 'autosave', true)
+    %   FORMATAIRFOILCOORD('test_data/*', 'overwrite', true)
+    %   FORMATAIRFOILCOORD('test_data/*', 'refine', true)
+    %   FORMATAIRFOILCOORD('test_data/*', 'outputFormat', 'Lednicer')
     %
     % See also: NACAAIRFOIL.
     %
@@ -102,7 +97,7 @@ function Dat = formatairfoilcoord(varargin)
     REFINED_NPOINTS = ceil((100 + 1) / 2);
 
     % Parse inputs
-    [allFileNames, fullpath, idxOpts] = parsefileinputs(OPTION_LIST, FILETYPE, varargin{:});
+    [allFileNames, fullpaths, idxOpts] = parsefileinputs(OPTION_LIST, FILETYPE, varargin{:});
     [autosave, overwrite, refine, outputFormat] = parseoptioninputs(varargin{idxOpts:end});
 
     % Convert filenames to string array
@@ -122,7 +117,7 @@ function Dat = formatairfoilcoord(varargin)
 
         % Load file and start parsing
         % No matter the file type, line 1 should always be the airfoil name
-        fileID = fopen(fullfile(fullpath, allFileNames{i}));
+        fileID = fopen(fullfile(fullpaths{i}, allFileNames{i}));
         tmpAirfoil = textscan(fileID, '%s', 1, 'Delimiter', '\n:', 'HeaderLines', 0);
         tmpCoord = cell2mat(textscan(fileID, '%f %f %*[^\n]', 'HeaderLines', 0));
         fclose(fileID);
@@ -144,7 +139,7 @@ function Dat = formatairfoilcoord(varargin)
         end
 
         % Output structure
-        Dat(i).path = fullpath;
+        Dat(i).path = fullpaths;
         Dat(i).file = allFileNames{i};
         Dat(i).airfoil = char(cellstr(tmpAirfoil{:}));
         Dat(i).format = outputFormat;
diff --git a/+af_tools/xf2mat.m b/+af_tools/xf2mat.m
index 7ec4c2e..224492f 100644
--- a/+af_tools/xf2mat.m
+++ b/+af_tools/xf2mat.m
@@ -27,11 +27,8 @@ function Polar = xf2mat(varargin)
     %   POLAR = XF2MAT prompts the user for all inputs, then aggregate and convert the polar in a
     %   single POLAR structure.
     %
-    %   POLAR = XF2MAT(INPUTDIR) aggregates all polars found in INPUTDIR into a single Polar
-    %   structure.
-    %
-    %   POLAR = XF2MAT(INPUTDIR, INPUTFILES) aggregates only the polars specified by INPUTFILES
-    %   found in INPUTDIR into a single Polar structure.
+    %   POLAR = XF2MAT(INPUTFILES) aggregates only the polars specified by INPUTFILES into a single
+    %   Polar structure.
     %
     %   POLAR = XF2MAT(..., 'autosave', true) saves the resulting POLAR structure automatically in
     %   a MAT-file.
@@ -40,8 +37,7 @@ function Polar = xf2mat(varargin)
     %   angles of attack to prevent NaN values in the ouput.
     %
     % Inputs:
-    %   inputDir   : Path of the directory with the XFOIL/XFLR5 data
-    %   inputFiles : Files to select (ex: '*' (default), '*0012*', {'file1','file2'}, etc)
+    %   inputFiles : Files to select (ex: 'dir/file', 'subdir/*' , 'dir/*0012*', {'file1','file2'})
     %
     % Output:
     %   Polar : Structure collecting the results
@@ -57,11 +53,11 @@ function Polar = xf2mat(varargin)
     %
     % Example:
     %   XF2MAT
-    %   XF2MAT('test_data')
-    %   XF2MAT('test_data', '*0012*')
-    %   XF2MAT('test_data', {'0012_re1e5', '0012_re1e6'})
-    %   XF2MAT('test_data', 'autosave', true)
-    %   XF2MAT('test_data', '*', 'trimAoas', true)
+    %   XF2MAT('test_data/*')
+    %   XF2MAT('data/*0012*')
+    %   XF2MAT({'data/0012_re1e5', 'data/0012_re1e6'})
+    %   XF2MAT('test_data/*', 'autosave', true)
+    %   XF2MAT('test_data/*', 'trimAoas', true)
     %
     % See also: EXTENDPOLAR, PLOTPOLARS.
     %
@@ -87,7 +83,7 @@ function Polar = xf2mat(varargin)
     FILETYPE = '.txt';
 
     % Parse inputs
-    [allFileNames, fullpath, idxOpts] = parsefileinputs(OPTION_LIST, FILETYPE, varargin{:});
+    [allFileNames, fullpaths, idxOpts] = parsefileinputs(OPTION_LIST, FILETYPE, varargin{:});
     [autosave, trimAoas] = parseoptioninputs(varargin{idxOpts:end});
 
     % Convert filenames to string array
@@ -112,7 +108,7 @@ function Polar = xf2mat(varargin)
     for i = 1:nbFiles
 
         % Load file and extract parameters and results
-        fileID = fopen(fullfile(fullpath, allFileNames{i}));
+        fileID = fopen(fullfile(fullpaths{i}, allFileNames{i}));
 
         % Scan file header to determine if it is from XFOIL or XFLR5
         % (this also position the pointer at the correct location for reading the rest)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1f8403c..0a65c90 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 
+## [3.0.0] - 2022-06-06
+
+### Changed
+
+- **BREAKING**: Change file input type for **xf2mat** and **formatairfoilcoord**
+
 ## [2.0.1] - 2022-05-24
 
 ### Added
@@ -84,7 +90,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - Initial release
 
-[Unreleased]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/v2.0.1...master
+[Unreleased]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/v3.0.0...master
+[3.0.1]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/v2.0.1...v3.0.0
 [2.0.1]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/v2.0.0...v2.0.1
 [2.0.0]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/v1.2.0...v2.0.0
 [1.2.0]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/v1.1.0...v1.2.0
diff --git a/README.md b/README.md
index 11ce282..892bc2b 100644
--- a/README.md
+++ b/README.md
@@ -108,15 +108,14 @@ data into a Matlab-ready structure.
 ```matlab
 import af_tools.xf2mat
 Polar = xf2mat
-Polar = xf2mat(inputDir, inputFiles, 'autosave', true)
-Polar = xf2mat(inputDir, inputFiles, 'trimAoas', true)
-Polar = xf2mat(inputDir, inputFiles, 'autosave', true, 'trimAoas', true)
+Polar = xf2mat(inputFiles, 'autosave', true)
+Polar = xf2mat(inputFiles, 'trimAoas', true)
+Polar = xf2mat(inputFiles, 'autosave', true, 'trimAoas', true)
 ```
 
 | Input        | Example                                        | Default |
 |------------- | ---------------------------------------------- | --------|
-| `inputDir`   | `'.'`, `'xf_results'`                          | -       |
-| `inputFiles` | `'*'`, `'*0012*'`, `'{'*0012_1*', '*0012_2*'}` | `'*'`   |
+| `inputFiles` | `'data/*'`, `'data/*0012*'`, `'{'data/*0012_1*', 'data/*0012_2*'}` | `'*'`   |
 |              |                                                |         |
 | 'autosave'   | `false`, `true`                                | `false` |
 | 'trimAoas'   | `false`, `true`                                | `false` |
@@ -168,14 +167,13 @@ points for each surface.
 ```matlab
 import af_tools.xf2mat
 Af = formatairfoilcoord
-Af = formatairfoilcoord(inputDir, inputFiles, 'autosave', true)
-Af = formatairfoilcoord(inputDir, inputFiles, 'overwrite', true)
+Af = formatairfoilcoord(inputFiles, 'autosave', true)
+Af = formatairfoilcoord(inputFiles, 'overwrite', true)
 ```
 
 | Input          | Example                                        | Default |
 |--------------- | ---------------------------------------------- | --------|
-| `inputDir`     | `'.'`, `'xf_results'`                          | -       |
-| `inputFiles`   | `'*'`, `'*0012*'`, `'{'*0012_1*', '*0012_2*'}` | `'*'`   |
+| `inputFiles` | `'data/*'`, `'data/*0012*'`, `'{'data/*0012_1*', 'data/*0012_2*'}` | `'*'`   |
 |                |                                                |         |
 | 'autosave'     | `false`, `true`                                | `false` |
 | 'overwrite'    | `false`, `true`                                | `false` |
diff --git a/tests/test_formatairfoilcoord.m b/tests/test_formatairfoilcoord.m
index d1660f5..1e0e0e0 100644
--- a/tests/test_formatairfoilcoord.m
+++ b/tests/test_formatairfoilcoord.m
@@ -91,15 +91,15 @@ function test_invalidOptions(testCase)
     % Error if invalid option name or missing parameter value
 
     wrongName = 'wrongOption';
-    testdir = [pwd, '/test_utils'];
+    testFiles = [pwd, '/test_utils/*'];
 
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, '*', wrongName), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, wrongName), ...
                 'MATLAB:InputParser:ParamMissingValue');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, '*', wrongName, true), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, wrongName, true), ...
                 'MATLAB:InputParser:UnmatchedParameter');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'autosave', true, wrongName), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'autosave', true, wrongName), ...
                 'MATLAB:InputParser:ParamMissingValue');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'autosave', true, wrongName, true), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'autosave', true, wrongName, true), ...
                 'MATLAB:InputParser:UnmatchedParameter');
 
 end
@@ -113,73 +113,69 @@ function test_invalidOptionsVal(testCase)
     Struct = struct;
     vect = 1:10;
 
-    testdir = [pwd, '/test_utils'];
+    testFiles = [pwd, '/test_utils/*'];
 
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'autosave', empty), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'autosave', empty), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'autosave', scal), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'autosave', scal), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'autosave', char), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'autosave', char), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'autosave', Struct), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'autosave', Struct), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'autosave', vect), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'autosave', vect), ...
                 'MATLAB:formatairfoilcoord:invalidType');
 
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'overwrite', empty), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'overwrite', empty), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'overwrite', scal), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'overwrite', scal), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'overwrite', char), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'overwrite', char), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'overwrite', Struct), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'overwrite', Struct), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'overwrite', vect), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'overwrite', vect), ...
                 'MATLAB:formatairfoilcoord:invalidType');
 
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'refine', empty), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'refine', empty), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'refine', scal), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'refine', scal), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'refine', char), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'refine', char), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'refine', Struct), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'refine', Struct), ...
                 'MATLAB:formatairfoilcoord:invalidType');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'refine', vect), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'refine', vect), ...
                 'MATLAB:formatairfoilcoord:invalidType');
 
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'outputFormat', empty), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'outputFormat', empty), ...
                 'MATLAB:formatairfoilcoord:unrecognizedStringChoice');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'outputFormat', scal), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'outputFormat', scal), ...
                 'MATLAB:formatairfoilcoord:unrecognizedStringChoice');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'outputFormat', char), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'outputFormat', char), ...
                 'MATLAB:formatairfoilcoord:unrecognizedStringChoice');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'outputFormat', Struct), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'outputFormat', Struct), ...
                 'MATLAB:formatairfoilcoord:unrecognizedStringChoice');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'outputFormat', vect), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord(testFiles, 'outputFormat', vect), ...
                 'MATLAB:formatairfoilcoord:unrecognizedStringChoice');
 
 end
 
 % -------------------------------------
-function test_dirNotFound(testCase)
-    % Error if valid inputDir not found
-
-    verifyError(testCase, @() af_tools.formatairfoilcoord('missingdir'), 'MATLAB:parsefileinputs:dirNotFound');
-
-end
-
 function test_fileNotFound(testCase)
     % Error if valid inputDir not found
 
-    testdir = [pwd, '/test_utils'];
+    testDir = [pwd, '/test_utils/'];
+    invalidDir = 'invaliddirectory';
 
-    verifyWarning(testCase, @() af_tools.formatairfoilcoord(testdir, {'clarky.dat', 'testdummy.dat'}), ...
+    verifyWarning(testCase, @() af_tools.formatairfoilcoord({[testDir, 'clarky.dat'], [testDir, 'testdummy.dat']}), ...
                   'MATLAB:parsefileinputs:FileNotFound');
     % remove warning first warning about FileNotFound before it throws the error
     warning('off', 'MATLAB:parsefileinputs:FileNotFound');
-    verifyError(testCase, @() af_tools.formatairfoilcoord(testdir, 'randomFile'), ...
+    verifyError(testCase, @() af_tools.formatairfoilcoord([testDir, 'randomFile']), ...
                 'MATLAB:parsefileinputs:noFilesFound');
+    verifyError(testCase, @() af_tools.formatairfoilcoord(invalidDir), 'MATLAB:parsefileinputs:noFilesFound');
+
     warning on; % Reactivate warnings
 
 end
@@ -189,9 +185,9 @@ end
 function test_correctOrder(testCase)
     % Verify if the output starts and ends at X = 1;
 
-    testdir = [pwd, '/test_utils'];
+    testFiles = [pwd, '/test_utils/*'];
 
-    Dat = af_tools.formatairfoilcoord(testdir, '*');
+    Dat = af_tools.formatairfoilcoord(testFiles);
 
     verifyEqual(testCase, Dat(1).coord(1, 1), 1);
     verifyEqual(testCase, Dat(1).coord(end, 1), 1);
@@ -203,11 +199,11 @@ end
 function test_correctRefinePoints(testCase)
     % Verify if the output of refined solution has 101 points
 
-    testdir = [pwd, '/test_utils'];
+    testFiles = [pwd, '/test_utils/*'];
     nPoints = 101;
 
-    DatNoRefine = af_tools.formatairfoilcoord(testdir, '*');
-    Dat = af_tools.formatairfoilcoord(testdir, '*', 'refine', true);
+    DatNoRefine = af_tools.formatairfoilcoord(testFiles);
+    Dat = af_tools.formatairfoilcoord(testFiles, 'refine', true);
 
     for i = 1:length(Dat)
         if length(DatNoRefine(i).coord(:, 1)) > nPoints
diff --git a/tests/test_parsefileinputs.m b/tests/test_parsefileinputs.m
index 4fd6a08..884b59c 100644
--- a/tests/test_parsefileinputs.m
+++ b/tests/test_parsefileinputs.m
@@ -112,32 +112,21 @@ function test_invalidInputTypeWhenNoOpts(testCase)
 end
 
 % -------------------------------------
-function test_dirNotFound(testCase)
-    % Error if valid inputDir not found
-
-    EMPTY_OPTS = {};
-    FILETYPE = '.dat';
-
-    verifyError(testCase, @() af_tools.utils.parsefileinputs(EMPTY_OPTS, FILETYPE, 'missingdir'), ...
-                'MATLAB:parsefileinputs:dirNotFound');
-
-end
-
 function test_fileNotFound(testCase)
     % Error if valid inputDir not found
 
     EMPTY_OPTS = {'test'};
     FILETYPE = '.dat';
-    testdir = [pwd, '/test_utils'];
+    testdir = [pwd, '/test_utils/'];
 
     verifyWarning(testCase, ...
-                  @() af_tools.utils.parsefileinputs(EMPTY_OPTS, FILETYPE, testdir, ...
-                                                     {'clarky.dat', 'testdummy.dat'}), ...
+                  @() af_tools.utils.parsefileinputs(EMPTY_OPTS, FILETYPE, ...
+                                                     {[testdir, 'clarky.dat'], [testdir, 'testdummy.dat']}), ...
                   'MATLAB:parsefileinputs:FileNotFound');
     % Remove warning first warning about FileNotFound before it throws the error
     warning('off', 'MATLAB:parsefileinputs:FileNotFound');
     verifyError(testCase, ...
-                @() af_tools.utils.parsefileinputs(EMPTY_OPTS, FILETYPE, testdir, 'randomFile'), ...
+                @() af_tools.utils.parsefileinputs(EMPTY_OPTS, FILETYPE, [testdir, 'randomFile']), ...
                 'MATLAB:parsefileinputs:noFilesFound');
     warning on; % Reactivate warnings
 
diff --git a/tests/test_xf2mat.m b/tests/test_xf2mat.m
index a9e0b37..de7b0ee 100644
--- a/tests/test_xf2mat.m
+++ b/tests/test_xf2mat.m
@@ -90,11 +90,11 @@ function test_invalidOptions(testCase)
     % Error if invalid option name or missing parameter value
 
     wrongName = 'wrongOption';
-    testdir = [pwd, '/test_utils'];
+    testdir = [pwd, '/test_utils/*'];
 
-    verifyError(testCase, @() af_tools.xf2mat(testdir, '*', wrongName), ...
+    verifyError(testCase, @() af_tools.xf2mat(testdir, wrongName), ...
                 'MATLAB:InputParser:ParamMissingValue');
-    verifyError(testCase, @() af_tools.xf2mat(testdir, '*', wrongName, true), ...
+    verifyError(testCase, @() af_tools.xf2mat(testdir, wrongName, true), ...
                 'MATLAB:InputParser:UnmatchedParameter');
     verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', true, wrongName), ...
                 'MATLAB:InputParser:ParamMissingValue');
@@ -112,7 +112,7 @@ function test_invalidOptionsVal(testCase)
     Struct = struct;
     vect = 1:10;
 
-    testdir = [pwd, '/test_utils'];
+    testdir = [pwd, '/test_utils/*'];
 
     verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', empty), 'MATLAB:xf2mat:invalidType');
     verifyError(testCase, @() af_tools.xf2mat(testdir, 'autosave', scal), 'MATLAB:xf2mat:invalidType');
@@ -129,23 +129,16 @@ function test_invalidOptionsVal(testCase)
 end
 
 % -------------------------------------
-function test_dirNotFound(testCase)
-    % Error if valid inputDir not found
-
-    verifyError(testCase, @() af_tools.xf2mat('missingdir'), 'MATLAB:parsefileinputs:dirNotFound');
-
-end
-
 function test_fileNotFound(testCase)
     % Error if valid inputDir not found
 
-    testdir = [pwd, '/test_utils'];
+    testdir = [pwd, '/test_utils/'];
 
-    verifyWarning(testCase, @() af_tools.xf2mat(testdir, {'xflr*', 'randomFile'}), ...
+    verifyWarning(testCase, @() af_tools.xf2mat({[testdir, 'xflr*'], [testdir, 'randomFile']}), ...
                   'MATLAB:parsefileinputs:FileNotFound');
     % Remove warning first warning about FileNotFound before it throws the error
     warning('off', 'MATLAB:parsefileinputs:FileNotFound');
-    verifyError(testCase, @() af_tools.xf2mat(testdir, 'randomFile'), 'MATLAB:parsefileinputs:noFilesFound');
+    verifyError(testCase, @() af_tools.xf2mat([testdir, 'randomFile']), 'MATLAB:parsefileinputs:noFilesFound');
     warning on; % Reactivate warnings
 
 end
@@ -155,9 +148,9 @@ end
 function test_correctNbOfPolars(testCase)
     % Verify if the output has the correct number of polars (columns in arrays)
 
-    testdir = [pwd, '/test_utils'];
+    testfiles = [pwd, '/test_utils/*'];
 
-    Polar = af_tools.xf2mat(testdir, '*');
+    Polar = af_tools.xf2mat(testfiles);
 
     verifyEqual(testCase, size(Polar.alpha, 2), 3);
     verifyEqual(testCase, size(Polar.alpha, 2), 3);
@@ -173,9 +166,9 @@ end
 function test_correctDimensions(testCase)
     % Verify if the output has the correct number of polars (columns in arrays)
 
-    testdir = [pwd, '/test_utils'];
+    testfiles = [pwd, '/test_utils/*'];
 
-    Polar = af_tools.xf2mat(testdir, '*');
+    Polar = af_tools.xf2mat(testfiles);
 
     verifyEqual(testCase, size(Polar.alpha, 1), size(Polar.cl, 1));
     verifyEqual(testCase, size(Polar.alpha, 1), size(Polar.cd, 1));
@@ -186,9 +179,9 @@ end
 function test_correctPolarOrder(testCase)
     % Verify if the output is properly ordered by Reynolds
 
-    testdir = [pwd, '/test_utils'];
+    testfile = [pwd, '/test_utils/xfoil*'];
 
-    Polar = af_tools.xf2mat(testdir, 'xfoil*');
+    Polar = af_tools.xf2mat(testfile);
     import matlab.unittest.constraints.IsLessThanOrEqualTo
     verifyThat(testCase, Polar.reynolds(1), IsLessThanOrEqualTo(Polar.reynolds(2)));
 
@@ -197,9 +190,9 @@ end
 function test_correctOutputValues(testCase)
     % Verify if the output has the correct values
 
-    testdir = [pwd, '/test_utils'];
+    testfile = [pwd, '/test_utils/xfoil-naca2412_re1e6'];
 
-    Polar = af_tools.xf2mat(testdir, 'xfoil-naca2412_re1e6');
+    Polar = af_tools.xf2mat(testfile);
 
     verifyEqual(testCase, Polar.alpha(1), deg2rad(-20));
     verifyEqual(testCase, Polar.cl(1), -0.4490);
@@ -216,9 +209,9 @@ end
 function test_autosave(testCase)
     % Verify if file is properly saved
 
-    testdir = [pwd, '/test_utils'];
+    testfile = [pwd, '/test_utils/xfoil-naca2412_re1e6'];
 
-    Polar = af_tools.xf2mat(testdir, 'xfoil-naca2412_re1e6', 'autosave', true);
+    Polar = af_tools.xf2mat(testfile, 'autosave', true);
     savedPolar = load('NACA_2412-Re_1e6.mat');
     savedPolar = savedPolar.Polar;
 
-- 
GitLab