Mercurial > hg > ltpda
diff testing/utp_1.1/generic_utps/utp_genericAnyShapeInternal.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_genericAnyShapeInternal.m Tue Dec 06 18:42:11 2011 +0100 @@ -0,0 +1,57 @@ +% <TestDescription> +% +% Tests that the internal call of general setter method works with any +% shape of objects as input. +% +% </TestDescription> +function result = utp_genericAnyShapeInternal(method, objs, values, algo) + + % <SyntaxDescription> + % + % Test that the internal call of a general setter method works with any + % shape of objects as input. + % + % </SyntaxDescription> + + try + % <SyntaxCode> + out = testCallerIsMethod(str2func(method), objs, values); + % </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; + if stest + % <AlgoCode> + % Check we have the correct number of outputs + if ~isequal(size(out), size(objs)), atest = false; end + % Check each output against the correct value + for kk=1:numel(out) + atest = algo(objs, out, kk, values); + if ~atest + break; + end + end + + % </AlgoCode> + else + atest = false; + end + + % Return a result structure + stack = dbstack; + if numel(objs) > 1 + stack(1).name = sprintf('%s %dx%d', stack(1).name, size(objs)); + end + result = utp_prepare_result(atest, stest, stack, ['utp_' class(objs) '_' method]); +end