2020-03-28 08:29:41 +01:00
|
|
|
%% BSM code validity check.
|
|
|
|
% This code will check the BSM class code in a very basic way.
|
|
|
|
%
|
2020-03-26 07:10:38 +01:00
|
|
|
%% create an instance
|
|
|
|
B=BSM;
|
2020-03-30 07:29:01 +02:00
|
|
|
%% test initialization
|
2020-03-26 07:10:38 +01:00
|
|
|
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
|
2020-03-30 07:29:01 +02:00
|
|
|
%% initialize properly
|
2020-03-26 07:10:38 +01:00
|
|
|
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
|
2020-03-30 07:29:01 +02:00
|
|
|
%%
|
|
|
|
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
|
2020-03-26 07:10:38 +01:00
|
|
|
B.SPMs=tmp;
|
2020-03-30 07:29:01 +02:00
|
|
|
%% set Prefix check
|
2020-03-26 07:10:38 +01:00
|
|
|
try
|
2020-03-30 07:29:01 +02:00
|
|
|
B.Prefix=""; %gives an error
|
2020-03-26 07:10:38 +01:00
|
|
|
catch ME
|
2020-03-30 07:29:01 +02:00
|
|
|
if strcmpi(ME.identifier,'BSM:SetPrefix:InvalidInput')
|
2020-03-26 07:10:38 +01:00
|
|
|
disp('error properly handled')
|
|
|
|
disp(ME);
|
|
|
|
else
|
|
|
|
rethrow(ME)
|
|
|
|
end
|
|
|
|
end
|
2020-03-30 07:29:01 +02:00
|
|
|
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
|
2020-03-26 07:10:38 +01:00
|
|
|
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
|
|
|
|
%%
|
2020-03-28 08:29:41 +01:00
|
|
|
B.Acfl=[];
|
|
|
|
%% Test Calc routine
|
|
|
|
B.Calc
|