Files
2026-07-20 07:43:05 -04:00

73 lines
2.9 KiB
Matlab

classdef tLoadData < matlab.unittest.TestCase
%TLOADDATA Tests for tdcs_load_data / tdcs_config (Task 1).
%
% Authored per TDD: written before tdcs_load_data.m existed, so it is
% expected to fail until the loader is implemented. As of this
% commit MATLAB is not licensed in this environment, so this suite
% has been authored and reviewed by hand but has NOT been executed.
% Expected values (row count, group counts, load-check cells) were
% independently verified against analysis/matlab/raw/*.csv by a
% throwaway Python script (see task-1-report.md), not by running
% this test.
properties (Constant)
% Non-blank (subject, day) success cells for the 12 curated
% animals with day >= 0, counted directly from raw_success.csv.
ExpectedRowCount = 185
end
methods (Test)
function testTwelveCuratedSubjects(testCase)
T = tdcs_load_data();
testCase.verifyEqual(numel(unique(T.subject)), 12);
end
function testRowCountMatchesNonBlankDayGeq0Cells(testCase)
T = tdcs_load_data();
testCase.verifyEqual(height(T), tLoadData.ExpectedRowCount);
end
function testGroupSubjectCounts(testCase)
T = tdcs_load_data();
subjGroup = unique(T(:, {'subject', 'group'}));
counts = countcats(subjGroup.group);
catNames = categories(subjGroup.group);
expected = containers.Map( ...
{'Naive', 'Electrode-Box-A2', 'Electrode-Box-B2', ...
'Electrode-Box-A', 'Right-Electrode'}, ...
{4, 3, 3, 1, 1});
testCase.verifyEqual(numel(catNames), double(expected.Count));
for i = 1:numel(catNames)
name = catNames{i};
testCase.verifyTrue(isKey(expected, name), ...
sprintf('Unexpected group "%s" in loaded data.', name));
testCase.verifyEqual(counts(i), expected(name), ...
sprintf('Subject count mismatch for group "%s".', name));
end
end
function testVuVuongDayZeroLoadCheck(testCase)
T = tdcs_load_data();
row = T(T.subject == "Vu-vuong" & T.day == 0, {'success', 'total'});
testCase.verifyEqual(height(row), 1);
testCase.verifyEqual(row.success(1), 18);
testCase.verifyEqual(row.total(1), 61);
end
function testBanhMi1DayZeroLoadCheck(testCase)
T = tdcs_load_data();
row = T(T.subject == "Banh-mi-1" & T.day == 0, {'success', 'total'});
testCase.verifyEqual(height(row), 1);
testCase.verifyEqual(row.success(1), 13);
testCase.verifyEqual(row.total(1), 84);
end
function testNoNegativeDayRows(testCase)
T = tdcs_load_data();
testCase.verifyTrue(all(T.day >= 0));
end
end
end