Skip to content

Commit b8bfd78

Browse files
committed
improve coverage for errorMessageCatalog
1 parent 44a3679 commit b8bfd78

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

+llms/+utils/errorMessageCatalog.m

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
end
2929
end
3030
end
31+
32+
function s = createCatalog()
33+
%createCatalog will run the initialization code and return the catalog
34+
% This is only meant to get more correct test coverage reports:
35+
% The test coverage reports do not include the properties initialization
36+
% for Catalog from above, so we have a test seam here to re-run it
37+
% within the framework, where it is reported.
38+
s = buildErrorMessageCatalog;
39+
end
3140
end
3241
end
3342

tests/terrorMessageCatalog.m

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
classdef terrorMessageCatalog < matlab.unittest.TestCase
2+
% Tests for errorMessageCatalog
3+
4+
% Copyright 2024 The MathWorks, Inc.
5+
6+
methods(Test)
7+
function ensureCorrectCoverage(testCase)
8+
testCase.verifyClass( ...
9+
llms.utils.errorMessageCatalog.createCatalog,"dictionary");
10+
end
11+
12+
function holeValuesAreUsed(testCase)
13+
import matlab.unittest.constraints.IsEqualTo
14+
15+
% we do not check the whole string, because error message
16+
% text *should* be able to change without test points changing.
17+
% That is necessary to enable localization.
18+
messageID = "llms:mustBeValidIndex";
19+
20+
message1 = llms.utils.errorMessageCatalog.getMessage(messageID, "input1");
21+
message2 = llms.utils.errorMessageCatalog.getMessage(messageID, "input2");
22+
23+
testCase.verifyThat(message1, ~IsEqualTo(message2));
24+
testCase.verifyThat(replace(message1, "input1", "input2"), IsEqualTo(message2));
25+
end
26+
end
27+
end

0 commit comments

Comments
 (0)