I am just beginning to dive into testing in Matlab, and I am trying to write a test which will check whether inputParser is properly catching incorrect function argument values. For example:
function [imageNamesForImport] = imageFileSearch(fileList, stringToMatch)
iP = inputParser;
iP.addRequired('fileList', @isstruct);
iP.addRequired('stringToMatch', @ischar);
iP.parse(fileList, stringToMatch);
will throw an error if I pass a variable as fileList which is not a structure
fileList = 'foo'
stringToMatch = 'bar'
imageNamesForImport = imageFileSearch(fileList, stringToMatch)
Error using imageFileSearch (line 7)
The value of 'fileList' is invalid. It must satisfy the function: isstruct.
Is it possible to write a unit test to check for this output without having to use a series of try / catch statements to assign custom errors for verifyError?
Aucun commentaire:
Enregistrer un commentaire