Mercurial > hg > ltpda
diff testing/utp_1.1/generic_utps/check_aop_history.m @ 44:409a22968d5e default
Add unit tests
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Tue, 06 Dec 2011 18:42:11 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testing/utp_1.1/generic_utps/check_aop_history.m Tue Dec 06 18:42:11 2011 +0100 @@ -0,0 +1,43 @@ +% +% DESCRIPTION: Generic check for a arithmetic operator unit test which +% checks the history for a single inputs. +% +% CALL: atest = check_aop_history(fcn, in1, in2, out); +% +% VERSION: $Id: check_aop_history.m,v 1.4 2010/09/24 16:18:16 ingo Exp $ +% + +function atest = check_aop_history(fcn, in1, in2, out) + + atest = true; + % Check the last history step + for ii = 1:numel(out) + if ~strcmp(out(ii).hist.methodInfo.mname, func2str(fcn)), atest = false; end + end + + doCheck = round(rand(1,1)*10); + doCheck = 1; + + % Check the rebuild only in 10 percent of the unit test. I do this to + % speedup the tests. + if doCheck == 1 + try + ple = plist('Exceptions', {'created', 'proctime', 'UUID', 'param/desc', 'name', 'methodInvars', 'version'}); + + % Rebuild the output object + mout = rebuild(copy(out,1)); + + % The rebuilt object must be the same as 'out' + for ii=1:numel(mout) + if ~eq(mout(ii), out(ii), ple), atest = false; end + if atest == 0 + break; + end + end + + catch + atest = false; + end + end + +end