comparison 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
comparison
equal deleted inserted replaced
43:bc767aaa99a8 44:409a22968d5e
1
2 % <TestDescription>
3 %
4 % Test that the <METHOD> method uses the plist to get the axis. This is
5 % intended to test methods like ao/mean and ao/std which return different
6 % data types depending on which axis is selected.
7 %
8 % </TestDescription>
9 function result = utp_108(method, obj1, ple1)
10
11 % <SyntaxDescription>
12 %
13 % Test that the <METHOD> method uses the plist to get the axis.
14 %
15 % </SyntaxDescription>
16
17 try
18 % <SyntaxCode>
19 plx = plist('axis', 'X');
20 ply = plist('axis', 'Y');
21 plxy = plist('axis', 'XY');
22 out1 = feval(method, obj1, plx);
23 out2 = feval(method, obj1, ply);
24 out3 = feval(method, obj1, plxy);
25 mout1 = rebuild(out1);
26 mout2 = rebuild(out2);
27 mout3 = rebuild(out3);
28 % </SyntaxCode>
29 stest = true;
30 catch err
31 disp(err.message)
32 stest = false;
33 end
34
35 % <AlgoDescription>
36 %
37 % 1) Check that the <METHOD> method applies to the x-axis
38 % 2) Check that the <METHOD> method applies to the y-axis
39 % 3) Check that the <METHOD> method applies to both axes
40 % 4) Check that the re-built object is the same as in 'out[1..3]'.
41 %
42 % </AlgoDescription>
43
44 atest = true;
45 if stest
46 % <AlgoCode>
47 % Check each output against the correct values
48 if ~isequal(feval(method,obj1.data.getX), out1.data.getY), atest = false; end
49 if ~isequal(feval(method,obj1.data.getY), out2.data.getY), atest = false; end
50 if ~isequal(feval(method,obj1.data.getY), out3.data.getY), atest = false; end
51 % Check the re-built objects
52 if ~eq(mout1, out1, ple1), atest = false; end
53 if ~eq(mout2, out2, ple1), atest = false; end
54 if ~eq(mout3, out3, ple1), atest = false; end
55 % </AlgoCode>
56 else
57 atest = false;
58 end
59
60 % Return a result structure
61 dd = dbstack;
62 mfilename = dd(2).file(1:end-2);
63 result = utp_prepare_result(atest, stest, dbstack, mfilename);
64 end % END UTP_108