Mercurial > hg > ltpda
diff testing/utp_1.1/generic_utps/utp_genericList.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_genericList.m Tue Dec 06 18:42:11 2011 +0100 @@ -0,0 +1,63 @@ +% <TestDescription> +% +% Tests that the <METHOD> method works for a list of objects as input. +% +% </TestDescription> +function result = utp_genericList(method, obj1, obj2, obj3, args, algo) + + % <SyntaxDescription> + % + % Tests that the <METHOD> method works for a list of objects as input. + % + % </SyntaxDescription> + + try + % <SyntaxCode> + if isempty(args) + out = feval(method, obj1, obj2, obj3); + else + if iscell(args) + out = feval(method, obj1, obj2, obj3, args{:}); + else + out = feval(method, obj1, obj2, obj3, args); + end + end + % </SyntaxCode> + stest = true; + catch err + disp(err.message) + stest = false; + end + + % <AlgoDescription> + % + % 1) Check that the number of elements in 'out' is the same as in 'objs' + % 2) Check that each output object contains the correct data. + % + % </AlgoDescription> + + atest = true; + objIn = [reshape(obj1, 1, []) reshape(obj2, 1, []) reshape(obj3, 1, [])]; + if stest + % <AlgoCode> + % Check we have the correct number of outputs + if ~isequal(size(out), size(objIn)), atest = false; end + % Check each output against the correct value + for kk=1:numel(out) + + atest = algo(objIn, out, kk, args); + if ~atest + break; + end + + end + + % </AlgoCode> + else + atest = false; + end + + % Return a result structure + stack = dbstack; + result = utp_prepare_result(atest, stest, stack, ['utp_' class(obj1) '_' method]); +end