1 classdef TestCase<matlab.unittest.TestCase
2 properties (Access=
private)
7 function runAndCheckError(self,commandStr,expIdentifierList,varargin)
10 import
mxberry.core.check.lib.*;
12 isNoIdentPatternSpec=false;
13 if ischar(expIdentifierList)
14 expIdentifierList={expIdentifierList};
15 elseif isempty(expIdentifierList)
16 isNoIdentPatternSpec=
true;
19 nExpIdentifiers=length(expIdentifierList);
21 [reg,isRegSpec,causeCheckDepth,reportStr,~,isRepStrSpec]=...
23 {
'causeCheckDepth',
'reportStr';...
24 0,
'successful execution when failure is expected';...
25 'isscalar(x)&&isnumeric(x)',@
isstring},...
28 'regCheckList',{@(x)(iscellstr(x)||
isstring(x))});
31 expMsgCodeList=reg{1};
32 if ischar(expMsgCodeList)
33 expMsgCodeList={expMsgCodeList};
35 isNoMsgPatternSpecVec=
false(1,numel(expMsgCodeList));
37 isNoMsgPatternSpecVec=
true(1,nExpIdentifiers);
38 expMsgCodeList=
repmat({
''},1,nExpIdentifiers);
40 nMsgCodes=numel(expMsgCodeList);
41 if isNoIdentPatternSpec
42 expIdentifierList=
repmat({
''},1,nMsgCodes);
43 isNoIdentPatternSpecVec=
true(1,nMsgCodes);
45 isNoIdentPatternSpecVec=
false(1,nMsgCodes);
49 size(y,2) == size(x,2),2,expIdentifierList,expMsgCodeList);
53 evalin(
'caller',commandStr);
59 [isIdentMatchVec,identPatternStr] =checkCode(meObj,...
60 'identifier',expIdentifierList);
61 [isMsgMatchVec,msgPatternStr] =checkCode(meObj,...
62 'message',expMsgCodeList);
64 isOk=any((isIdentMatchVec|isNoIdentPatternSpecVec)&...
65 (isMsgMatchVec|isNoMsgPatternSpecVec));
66 patternStr=[
'identifier(',identPatternStr,
')',...
67 'message(',msgPatternStr,
')'];
71 addArgList={reportStr};
77 self.verifyEqual(
true,isOk,...
79 [
'\n no match found for pattern %s',...
80 ' exception details: \n %s',addSuffix],...
81 patternStr,errMsg,addArgList{:}))
84 self.verifyEqual(
true,
false,reportStr);
85 function [isMatchVec,patternsStr]=checkCode(inpMeObj,fieldName,codeList)
90 isMatchVec=cellfun(...
91 @(x)getIsCodeMatch(...
92 inpMeObj,causeCheckDepth,fieldName,x),codeList);
98 function isPositive=getIsCodeMatch(inpMeObj,checkDepth,fieldName,codeStr)
99 fieldValue = inpMeObj.(fieldName);
100 if isempty(fieldValue)
101 isPositive= isempty(codeStr);
103 isPositive=~isempty(strfind(fieldValue,codeStr));
105 causeList=inpMeObj.cause;
106 nCauses=length(causeList);
107 if checkDepth>0&&nCauses>0
109 isPositive=isPositive||getIsCodeMatch(...
110 causeList{iCause},checkDepth-1,...
116 function resTime=runAndMeasureTime(
self,varargin)
118 self.PROF_MODE,
self.PROF_DIR);
function throwerror(in msgTag, in varargin)
THROWERROR works similarly to built-in ERROR function in case when there is no output arguments but s...
function checkmultvar(in typeSpec, in nPlaceHolders, in varargin)
CHECKMULTVAR checks a generic condition provided by typeSpec string in the following format: 'isnumer...
function repmat(in inpArray, in varargin)
function isstring(in inpArray)
function runAndProcess(in self, in fRun, in varargin)
RUNANDPROCESS executes the specified command and generates a profiling report using the specified nam...