Mercurial > hg > ltpda
diff testing/utp_1.1/generic_utps/utp_108.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_108.m Tue Dec 06 18:42:11 2011 +0100 @@ -0,0 +1,64 @@ + +% <TestDescription> +% +% Test that the <METHOD> method uses the plist to get the axis. This is +% intended to test methods like ao/mean and ao/std which return different +% data types depending on which axis is selected. +% +% </TestDescription> +function result = utp_108(method, obj1, ple1) + + % <SyntaxDescription> + % + % Test that the <METHOD> method uses the plist to get the axis. + % + % </SyntaxDescription> + + try + % <SyntaxCode> + plx = plist('axis', 'X'); + ply = plist('axis', 'Y'); + plxy = plist('axis', 'XY'); + out1 = feval(method, obj1, plx); + out2 = feval(method, obj1, ply); + out3 = feval(method, obj1, plxy); + mout1 = rebuild(out1); + mout2 = rebuild(out2); + mout3 = rebuild(out3); + % </SyntaxCode> + stest = true; + catch err + disp(err.message) + stest = false; + end + + % <AlgoDescription> + % + % 1) Check that the <METHOD> method applies to the x-axis + % 2) Check that the <METHOD> method applies to the y-axis + % 3) Check that the <METHOD> method applies to both axes + % 4) Check that the re-built object is the same as in 'out[1..3]'. + % + % </AlgoDescription> + + atest = true; + if stest + % <AlgoCode> + % Check each output against the correct values + if ~isequal(feval(method,obj1.data.getX), out1.data.getY), atest = false; end + if ~isequal(feval(method,obj1.data.getY), out2.data.getY), atest = false; end + if ~isequal(feval(method,obj1.data.getY), out3.data.getY), atest = false; end + % Check the re-built objects + if ~eq(mout1, out1, ple1), atest = false; end + if ~eq(mout2, out2, ple1), atest = false; end + if ~eq(mout3, out3, ple1), 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_108 \ No newline at end of file