Browse Source

get rid of clear functions as a workaround for gnu octave

master
Markus Bergholz 7 years ago
parent
commit
28ca326d7d
  1. 20
      mUnittest.m

20
mUnittest.m

@ -30,7 +30,9 @@ end%function mUnittest
function summary()
% get number of passed and failed tests
result = assert('this', 'will', 'end', 'here', ':-)');
result = assert();
assert('this', 'will', 'end', 'here', ':-)');
f = result.countFailed;
p = result.countPassed;
@ -46,6 +48,7 @@ function summary()
fid = fopen(sprintf('%sReport.xml', className()), 'w');
fprintf(fid, '<testsuite tests="%d" time="%.f">%s\n</testsuite>',num, t, xml);
fclose(fid);
end
% overloaded assert
@ -60,6 +63,12 @@ function ret = assert(cond, msg, errormsg, successmsg, varargin)
if (nargin == 5)
[t, countTests, countFailed, countPassed, countBlocks] = deal(0);
xml = '';
protectCount('this', 'will', 'end', 'here', ':-)');
elseif (nargout == 1)
% five inputs will clear all variables and flush the xml file
% return results
@ -115,6 +124,11 @@ function ret = assert(cond, msg, errormsg, successmsg, varargin)
% concatinate global string for xml output
xml = [xml sprintf('\n\t<testcase classname="%s #%d " name="%s" time="%.2f">', className(), protectCount() , msg, this_time)];
elseif cond == -1
%% SKIP
% TODO
else
%% FAILED
% increase number of failed tests
@ -161,7 +175,7 @@ function clear()
end%function
function ret = protectCount(in)
function ret = protectCount(in, varargin)
persistent n
if isempty(n), n = 0; end
@ -171,7 +185,7 @@ function ret = protectCount(in)
elseif nargout == 1
ret = n;
elseif nargin == 5
builtin('clear', 'n');
n = 0;
else
ret = n;
end

Loading…
Cancel
Save