|
| 1 | +function test_suite = test_removeDateSuffix %#ok<*STOUT> |
| 2 | + try % assignment of 'localfunctions' is necessary in Matlab >= 2016 |
| 3 | + test_functions = localfunctions(); %#ok<*NASGU> |
| 4 | + catch % no problem; early Matlab versions can use initTestSuite fine |
| 5 | + end |
| 6 | + initTestSuite; |
| 7 | +end |
| 8 | + |
| 9 | + |
| 10 | +function test_removeDateSuffixBasic() |
| 11 | + |
| 12 | + %% set up |
| 13 | + cfg.dir.output = fullfile(fileparts(mfilename('fullpath')), '..', 'output'); |
| 14 | + |
| 15 | + % clean up |
| 16 | + if isdir(cfg.dir.output) |
| 17 | + rmdir(cfg.dir.output, 's'); |
| 18 | + end |
| 19 | + [~, ~, ~] = mkdir(cfg.dir.output); |
| 20 | + |
| 21 | + % TODO |
| 22 | + % make sure we use the default date parameter (to implement?) |
| 23 | + % cfg = checkCFG(cfg); |
| 24 | + |
| 25 | + %% set up |
| 26 | + boldName = 'test_bold_date-202008050730.nii.gz'; |
| 27 | + boldName2 = 'test2_bold.nii.gz'; |
| 28 | + boldName3 = 'test3_bold_date-202008050730.nii'; |
| 29 | + jsonName = 'test_bold_date-202008050730.json'; |
| 30 | + eventsName = 'test_events_date-202008050730.tsv'; |
| 31 | + stimName = 'test_stim_date-202008050730.tsv'; |
| 32 | + stimNameZipped = 'test2_stim_date-202008050730.tsv.gz'; |
| 33 | + |
| 34 | + filesToProcess = { ... |
| 35 | + boldName ; |
| 36 | + boldName2 ; |
| 37 | + boldName3 ; |
| 38 | + jsonName ; |
| 39 | + eventsName ; |
| 40 | + stimName ; |
| 41 | + stimNameZipped ; |
| 42 | + }; |
| 43 | + |
| 44 | + for iFile = 1:numel(filesToProcess) |
| 45 | + copyfile( ... |
| 46 | + fullfile('..', 'dummyData', 'dummyData.nii.gz'), ... |
| 47 | + fullfile(cfg.dir.output, filesToProcess{iFile})); |
| 48 | + end |
| 49 | + |
| 50 | + %% do stuff |
| 51 | + filenames = file_utils('List', cfg.dir.output, '^test.*$'); |
| 52 | + |
| 53 | + removeDateSuffix(filenames, cfg.dir.output); |
| 54 | + |
| 55 | + %% expected data |
| 56 | + expectedBoldName = 'test_bold.nii.gz'; |
| 57 | + expectedBoldName2 = 'test2_bold.nii.gz'; |
| 58 | + expectedBoldName3 = 'test3_bold.nii'; |
| 59 | + expectedJsonName = 'test_bold.json'; |
| 60 | + expectedEventsName = 'test_events.tsv'; |
| 61 | + expectedStimName = 'test_stim.tsv'; |
| 62 | + expectedStimNameZipped = 'test2_stim.tsv.gz'; |
| 63 | + |
| 64 | + %% test |
| 65 | + assertEqual(exist(fullfile(cfg.dir.output, expectedBoldName3), 'file'), 2); |
| 66 | + assertEqual(exist(fullfile(cfg.dir.output, expectedJsonName), 'file'), 2); |
| 67 | + assertEqual(exist(fullfile(cfg.dir.output, expectedEventsName), 'file'), 2); |
| 68 | + assertEqual(exist(fullfile(cfg.dir.output, expectedStimName), 'file'), 2); |
| 69 | + assertEqual(exist(fullfile(cfg.dir.output, expectedStimNameZipped), 'file'), 2); |
| 70 | + assertEqual(exist(fullfile(cfg.dir.output, expectedBoldName2), 'file'), 2); |
| 71 | + assertEqual(exist(fullfile(cfg.dir.output, expectedBoldName), 'file'), 2); |
| 72 | + |
| 73 | +end |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
0 commit comments