Mercurial > hg > ltpda
diff testing/utp_1.1/generic_utps/utp_06.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/utp_06.m Tue Dec 06 18:42:11 2011 +0100 @@ -0,0 +1,53 @@ +% <TestDescription> +% +% Tests that the <METHOD> method properly applies history. +% +% </TestDescription> +function result = utp_06(method, obj1, pli, epl) + + % <SyntaxDescription> + % + % Test that the result of applying the <METHOD> method can be processed back. + % + % </SyntaxDescription> + + try + % <SyntaxCode> + if isempty(pli) + out = feval(method, obj1); + else + out = feval(method, obj1, pli); + end + mout = rebuild(out); + % </SyntaxCode> + stest = true; + catch err + disp(err.message) + stest = false; + end + + % <AlgoDescription> + % + % 1) Check that the last entry in the history of 'out' corresponds to + % '<METHOD>'. + % 2) Check that the re-built object is the same object as the input. + % + % </AlgoDescription> + + atest = true; + if stest + % <AlgoCode> + % Check the last step in the history of 'out' + if ~strcmp(out.hist.methodInfo.mname, method), atest = false; end + % The rebuilt object must be the same as 'out' + if ~eq(mout, out, epl), atest = false; end + % </AlgoCode> + else + atest = false; + end + + % Return a result structure + dd = dbstack; + mfilename = dd(2).file(1:end-2); + result = utp_prepare_result(atest, stest, dbstack, mfilename); +end % END UTP_06 \ No newline at end of file