0e9263b958
Add tdcs_model_summary as the single place that renders a fitted model verbatim (disp(model) with the Command-Window <strong> markup stripped), and route every report through it so all scenarios emit the complete model-fitting output: - tdcs_report: adds the learning-rate GLMM's full summary (count/rate already had theirs); localCleanDisp now delegates to the shared helper. - tdcs_lme_report / tdcs_paper_lme: embed the full fitlme summary before the curated effect table. - tdcs_phase_lme: appends each phase's full fitlme summary. Tests: tReport asserts 3 native summaries in a GLMM report; tLme asserts the lme_*/paper_*/phase_* reports embed 1/1/3 summaries with markup stripped. Suite 39/39. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
56 lines
2.5 KiB
Matlab
56 lines
2.5 KiB
Matlab
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>'));
|
|
% Full native GLMM summary is present for all three models
|
|
% (count, rate, learning-rate): each disp() prints this header.
|
|
testCase.verifyEqual(count(txt, 'Fixed effects coefficients (95% CIs):'), 3, ...
|
|
'Expected the full fitglme summary for count, rate, and learning GLMMs.');
|
|
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
|