%% BSM code validity check. % This code will check the BSM class code in a very basic way. % %% create an instance B=BSM; %% clear B try B=BSM('type',3,'Acfl',[],'SPMs'); %#ok<*NASGU> %will create an error catch ME if strcmpi(ME.identifier,'BSM:getval:ReadBeyondEndInput') disp('error properly handled') disp(ME); else rethrow(ME); end end %% clear B B=BSM('type',1,'Acfl',[],'SPMs',{}); %% set SPMs validity check B.SPMs=''; %should produce instructions on how to set SPMs B.SPMs={'ui'}; %get input from the user tmp=B.SPMs; %store for future use %B.SPMs={'ui'}; %calling it again will allow me to edit the list B.SPMs={}; %clear out SPMs try B.SPMs={'SPM.mat';'onzin.mat'}; %provides an error if file does not exist catch ME if strcmpi(ME.identifier,'BSM:SetSPMs:FileNotFound') disp('error properly handled') disp(ME); else rethrow(ME) end end B.SPMs=tmp; %% set Type check try B.Type='onzin'; %gives an error catch ME if strcmpi(ME.identifier,'BSM:Type:invalid') disp('error properly handled') disp(ME); else rethrow(ME) end end %% try B.Type=0; %gives an error catch ME if strcmpi(ME.identifier,'BSM:Type:invalid') disp('error properly handled') disp(ME); else rethrow(ME) end end %% B.Type=1; % correct call %% set Acfl check try B.Acfl=0; catch ME if strcmpi(ME.identifier,'BSM:Acfl:invalid') disp('error properly handled') disp(ME); else rethrow(ME) end end %% try B.Acfl=-5; catch ME if strcmpi(ME.identifier,'BSM:Acfl:invalid') disp('error properly handled') disp(ME); else rethrow(ME) end end %% try B.Acfl='test'; catch ME if strcmpi(ME.identifier,'BSM:Acfl:invalid') disp('error properly handled') disp(ME); else rethrow(ME) end end %% B.Acfl=[]; %% Test Calc routine B.Calc