Mercurial > hg > ltpda
diff testing/utp_1.1/utps/pest/utp_pest_setCov.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/utps/pest/utp_pest_setCov.m Tue Dec 06 18:42:11 2011 +0100 @@ -0,0 +1,109 @@ +% UTP_PEST_SETCOV a set of UTPs for the pest/setCov method +% +% M Hewitson 06-08-08 +% +% $Id: utp_pest_setCov.m,v 1.3 2011/04/06 19:14:54 ingo Exp $ +% + +% <MethodDescription> +% +% The setCov method of the pest class sets the cov property. +% +% </MethodDescription> + +function results = utp_pest_setCov(varargin) + + % Check the inputs + if nargin == 0 + + % Some keywords + class = 'pest'; + mthd = 'setCov'; + prop = 'cov'; + + disp('******************************************************'); + disp(['**** Running UTPs for ' class '/' mthd]); + disp('******************************************************'); + + % Test objects + pe1 = pest([8, 9]); + pe1.setName; + pe2 = pest([1 2]); + pe2.setName; + pe3 = pe1; + + pev = [pe1, pe2, pe1]; + pem = [pe1, pe2, pe1; pe1, pe2, pe1]; + + % Exception list for the UTPs: + [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); + + % The setter method have different possibilities to set a property + val1 = magic(2); + val2 = plist(prop, rand(2,2)); + + % Run the general tests + results(1) = utp_genericSet_minfo(mthd, pe1, prop, @algoTests_minfo); % test getInfo call + results(2) = utp_genericAnyShape(mthd, pev, val1, @algoTests); % test vector + results(3) = utp_genericAnyShape(mthd, pev, val2, @algoTests); % test vector call with plist + results(4) = utp_genericAnyShapeInternal(mthd, pev, val1, @algoTestsInternal); % test internal vector call + results(5) = utp_genericAnyShape(mthd, pem, val1, @algoTests); % test matrix call + results(6) = utp_genericAnyShape(mthd, pem, val2, @algoTests); % test matrix call with plist + results(7) = utp_genericAnyShapeInternal(mthd, pem, val1, @algoTestsInternal); % test internal matrix call + results(8) = utp_genericList(mthd, pe1, pe2, pe3, val1, @algoTests); % test list + results(9) = utp_genericList(mthd, pe1, pe2, pe3, val2, @algoTests); % test list with plist + results(10) = utp_genericList(mthd, pe1, pev, pem, val1, @algoTests); % test mixed shape of input objs + results(11) = utp_genericHistory(mthd, pe1, val1, ple2); % test the history + results(12) = utp_genericModify(mthd, pe1, val1, @algoTests, ple1); % test the modifier call + results(13) = utp_genericOutput(mthd, pe1, pe2, val1, @algoTests, ple2); % test the outputs + + disp('Done.'); + disp('******************************************************'); + + elseif nargin == 1 % Check for UTP functions + if strcmp(varargin{1}, 'isutp') + results = 1; + else + results = 0; + end + else + error('### Incorrect inputs') + end + + % Check that the default value un the PLIST + function atest = algoTests_minfo(defVal) + atest = true; + % Check default value for the key 'cov' + if ~eq(defVal, []), atest = false; end + end + + % Check that the property have the correct value + function atest = algoTests(in, out, idx, value) + atest = true; + % Check that the input and output objects are the same except the + % property 'cov' and the history + ple = plist('EXCEPTIONS', {'created', 'proctime', 'UUID', 'hist', prop}); + if ~eq(in(idx), out(idx), ple), atest = false; end + if ~eq(in(idx).hist, out(idx).hist.inhists), atest = false; end + % Check that the parameter gets the correct value. + if isa(value, 'plist') && value.nparams == 1 && value.isparam(prop) + % The value was set with a plist. + if ~isequal(out(idx).(prop), value.find(prop)), atest = false; end + else + if ~isequal(out(idx).(prop), value), atest = false; end + end + end + + % Check that the property have the correct value for an internal call + function atest = algoTestsInternal(in, out, idx, value) + atest = true; + % Check that the input and output objects are the same except the + % property 'cov' and the history + ple = plist('EXCEPTIONS', {'created', 'proctime', 'UUID', prop}); + if ~eq(in(idx), out(idx), ple), atest = false; end + % Check that the parameter gets the correct value. + if ~isequal(out(idx).(prop), value), atest = false; end + end + + +end