matlab(tdcs): report, switch/case entry, runners, README

This commit is contained in:
Experiments DB Dev
2026-07-20 08:00:40 -04:00
parent 27d388530a
commit 01f59a5265
6 changed files with 413 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
classdef tReport < matlab.unittest.TestCase
%TREPORT Tests for tdcs_glm / tdcs_report (Task 4: entry point + report).
%
% MATLAB R2025b + Statistics and Machine Learning Toolbox IS licensed
% in this environment, so this suite is actually run. It does not
% re-check golden values (tModels already does that); it checks the
% wiring: tdcs_glm(scenario) runs end-to-end without error and writes
% results/<scenario>.txt, and the otherwise-branch errors on an
% unrecognized scenario name.
methods (Test)
function testRunsScenarioAndWritesResultFile(testCase)
thisDir = fileparts(mfilename('fullpath'));
resultsDir = fullfile(fileparts(thisDir), 'results');
outFile = fullfile(resultsDir, 'mergeB2_full.txt');
if exist(outFile, 'file')
delete(outFile);
end
tdcs_glm('mergeB2_full');
testCase.verifyTrue(exist(outFile, 'file') == 2, ...
'tdcs_glm did not write results/mergeB2_full.txt.');
txt = fileread(outFile);
testCase.verifyNotEmpty(txt);
testCase.verifyTrue(contains(txt, 'DESCRIPTIVES'));
testCase.verifyTrue(contains(txt, 'INTERPRETATION'));
testCase.verifyTrue(contains(txt, 'CAVEATS'));
% Command-Window-only markup must be stripped from the report.
testCase.verifyFalse(contains(txt, '<strong>'));
end
function testUnmergedScenarioIncludesClassification(testCase)
thisDir = fileparts(mfilename('fullpath'));
resultsDir = fullfile(fileparts(thisDir), 'results');
outFile = fullfile(resultsDir, 'unmerged_full.txt');
tdcs_glm('unmerged_full');
txt = fileread(outFile);
testCase.verifyTrue(contains(txt, 'Classification'));
testCase.verifyTrue(contains(txt, 'Electrode-Box-A'));
testCase.verifyTrue(contains(txt, 'Right-Electrode'));
end
function testBadScenarioErrors(testCase)
testCase.verifyError(@() tdcs_glm('not_a_real_scenario'), ...
'tdcs_glm:badScenario');
end
end
end