%% BSM code validity check. % This code will check the BSM class code in a very basic way. % %% create an instance B=BSM; %% test initialization 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 %% initialize properly 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 %% 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 Prefix check try B.Prefix=""; %gives an error catch ME if strcmpi(ME.identifier,'BSM:SetPrefix:InvalidInput') disp('error properly handled') disp(ME); else rethrow(ME) end end B.Prefix='bs' %% set Clean check try B.Clean=""; %gives an error catch ME if strcmpi(ME.identifier,'BSM:SetClean:InvalidType') disp('error properly handled') disp(ME); else rethrow(ME) end end disp(B.Clean) B.Clean=true; %% Check Type set 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