0001 classdef dsUnitTest_autogenDirs_all < matlab.unittest.TestCase
0002 properties
0003 unitTestDataPath = dsGetConfig('ds_unitTestData_path');
0004 end
0005
0006 properties (TestParameter)
0007 dataDirName = dsUnitGetAutogenDirs();
0008 end
0009
0010 methods (Test, TestTags = {'autogen'})
0011 function testCellIn(testCase, dataDirName)
0012 dataDirPath = fullfile(testCase.unitTestDataPath, 'autogenDirs', dataDirName);
0013
0014
0015 import matlab.unittest.fixtures.WorkingFolderFixture
0016 tempDirFixture = testCase.applyFixture(WorkingFolderFixture('WithSuffix', ['_' dataDirName]));
0017 tempDirPath = tempDirFixture.Folder;
0018
0019
0020
0021 args = load(fullfile(dataDirPath, 'args.mat'));
0022 expectedOut = args.argout;
0023
0024 fnName = strsplit(dataDirName,'_autogen_');
0025 fh = str2func(fnName{1});
0026
0027 [testOut{1:length(expectedOut)}] = feval(fh, args.argin{:});
0028
0029
0030
0031 if all(isValidFigHandle(testOut{1}))
0032 handles = testOut{1};
0033
0034 dsUnitSave_figHandles( handles, tempDirPath )
0035
0036 close all
0037 end
0038
0039
0040 for ind = 1:length(expectedOut)
0041 testCase.verifyEqual(testOut{ind}, expectedOut{ind});
0042 end
0043
0044
0045 expectedOutputDir = fullfile(dataDirPath, 'output');
0046 if exist(expectedOutputDir, 'dir')
0047 expectedOutputFiles = rls(expectedOutputDir);
0048 expectedOutputFiles(1) = [];
0049 testOutputFiles = rls(tempDirPath);
0050 testOutputFiles(1) = [];
0051
0052
0053 testCase.assertLength(testOutputFiles, length(expectedOutputFiles));
0054
0055
0056 for iFile = 1:length(expectedOutputFiles)
0057
0058 thisExpectedOutputFilePath = expectedOutputFiles{iFile};
0059
0060
0061 thistestOutputFilePath = testOutputFiles{iFile};
0062
0063 [~,~,ext] = fileparts2(thistestOutputFilePath);
0064 switch ext
0065 case ''
0066 continue
0067 case '.fig'
0068
0069 testCase.verifyEmpty( compareFigFiles2(thistestOutputFilePath, thisExpectedOutputFilePath, true) );
0070 case '.mat'
0071
0072 thistest = load(thistestOutputFilePath);
0073 thisExpected = load(thisExpectedOutputFilePath);
0074 testCase.verifyEqual(thistest, thisExpected);
0075 case '.mex4unittest'
0076 continue
0077 otherwise
0078
0079 testCase.verifyFalse( logical(system(sprintf('diff -qr %s %s', thistestOutputFilePath, thisExpectedOutputFilePath))) );
0080 end
0081 end
0082 end
0083
0084 end
0085 end
0086
0087 end