44
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % Tests that the <METHOD> method works with a vector of objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % $Id: utp_02.m,v 1.3 2010/07/27 07:13:59 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 function result = utp_02(method, vec, algo, pli, ple3)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % Test that the <METHOD> method works for a vector of objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 if isempty(pli)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 out = feval(method, vec);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 out = feval(method, vec, pli);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 % 1) Check that the number of elements in 'out' is the same as in 'vec'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 % 2) Check that each output object contains the correct data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 if ~isequal(size(out), size(vec)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 % Check each output against the correct value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 for kk=1:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 % extra tests for constructors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 if utils.helper.ismember(method, utils.helper.ltpda_userclasses)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 % Check that the output is the same except the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 if ~eq(vec(kk), out(kk), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 % Check the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 if ~eq(vec(kk).hist, out(kk).hist.inhists), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 % Change the output to make sure that it is a 'real' copy
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 out(kk).setDescription('my desc');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 if eq(vec(kk), out(kk), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 atest = algo(vec(kk), out(kk), pli);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 if ~atest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 break;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 dd = dbstack;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 mfilename = dd(2).file(1:end-2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 end % END UTP_02 |