From 53251c2841bc559ebd49a6c09dc0e51d21b7a536 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Wed, 30 Oct 2024 16:34:22 +0100 Subject: [PATCH] Add test class for internal functions --- .../+internal/+utility/+dir/listFiles.m | 22 +------------------ tools/tests/unitTests/InternalFunctionsTest.m | 20 +++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 tools/tests/unitTests/InternalFunctionsTest.m diff --git a/code/internal/+openminds/+internal/+utility/+dir/listFiles.m b/code/internal/+openminds/+internal/+utility/+dir/listFiles.m index fe7c323c..0ad0d717 100644 --- a/code/internal/+openminds/+internal/+utility/+dir/listFiles.m +++ b/code/internal/+openminds/+internal/+utility/+dir/listFiles.m @@ -30,7 +30,7 @@ keep = ~ strncmp({L.name}, '.', 1); L = L(keep); - if ~strncmp(filetype, '.', 1) + if ~isempty(filetype) && ~strncmp(filetype, '.', 1) filetype = strcat('.', filetype); end @@ -47,23 +47,3 @@ filename = {L.name}; end end - -% % function [folders, names, ext] = fileparts(varargin) -% % -% % [folders, names, ext] = deal(cell(1, numel(varargin))); -% % -% % for i = 1:numel(varargin) -% % [folders{i}, names{i}, ext{i}] = builtin('fileparts', varargin{i}); -% % end -% % -% % if nargin == 1 -% % folders = folders{1}; names = names{1}; ext = ext{1}; -% % end -% % -% % if nargout == 1 -% % clear names ext -% % elseif nargout == 2 -% % clear ext -% % end -% % -% % end diff --git a/tools/tests/unitTests/InternalFunctionsTest.m b/tools/tests/unitTests/InternalFunctionsTest.m new file mode 100644 index 00000000..ad54ad9a --- /dev/null +++ b/tools/tests/unitTests/InternalFunctionsTest.m @@ -0,0 +1,20 @@ +classdef InternalFunctionsTest < matlab.unittest.TestCase + + methods(TestClassSetup) + % Shared setup for the entire test class + end + + methods(TestMethodSetup) + % Setup for each test + end + + methods(Test) + + function testListFiles(testCase) + codeFolder = openminds.toolboxdir(); + [filePath, filename] = openminds.internal.utility.dir.listFiles(codeFolder); + testCase.verifyClass(filePath, 'cell'); + testCase.verifyClass(filename, 'cell'); + end + end +end \ No newline at end of file