comparison testing/utp_1.1/utps/pest/utp_pest_setPdf.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 % UTP_PEST_SETPDF a set of UTPs for the pest/setPdf method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_pest_setPdf.m,v 1.3 2011/04/06 19:14:54 ingo Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The setPdf method of the pest class sets the pdf property.
11 %
12 % </MethodDescription>
13
14 function results = utp_pest_setPdf(varargin)
15
16 % Check the inputs
17 if nargin == 0
18
19 % Some keywords
20 class = 'pest';
21 mthd = 'setPdf';
22 prop = 'pdf';
23
24 disp('******************************************************');
25 disp(['**** Running UTPs for ' class '/' mthd]);
26 disp('******************************************************');
27
28 % Test objects
29 pe1 = pest([8, 9]);
30 pe1.setName;
31 pe2 = pest([1 2]);
32 pe2.setName;
33 pe3 = pe1;
34
35 pev = [pe1, pe2, pe1];
36 pem = [pe1, pe2, pe1; pe1, pe2, pe1];
37
38 % Exception list for the UTPs:
39 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
40
41 % The setter method have different possibilities to set a property
42 val1 = randn(2,2);
43 val2 = plist(prop, randn(3,3));
44
45 % Run the general tests
46 results(1) = utp_genericSet_minfo(mthd, pe1, prop, @algoTests_minfo); % test getInfo call
47 results(2) = utp_genericAnyShape(mthd, pev, val1, @algoTests); % test vector
48 results(3) = utp_genericAnyShape(mthd, pev, val2, @algoTests); % test vector call with plist
49 results(4) = utp_genericAnyShapeInternal(mthd, pev, val1, @algoTestsInternal); % test internal vector call
50 results(5) = utp_genericAnyShape(mthd, pem, val1, @algoTests); % test matrix call
51 results(6) = utp_genericAnyShape(mthd, pem, val2, @algoTests); % test matrix call with plist
52 results(7) = utp_genericAnyShapeInternal(mthd, pem, val1, @algoTestsInternal); % test internal matrix call
53 results(8) = utp_genericList(mthd, pe1, pe2, pe3, val1, @algoTests); % test list
54 results(9) = utp_genericList(mthd, pe1, pe2, pe3, val2, @algoTests); % test list with plist
55 results(10) = utp_genericList(mthd, pe1, pev, pem, val1, @algoTests); % test mixed shape of input objs
56 results(11) = utp_genericHistory(mthd, pe1, val1, ple2); % test the history
57 results(12) = utp_genericModify(mthd, pe1, val1, @algoTests, ple1); % test the modifier call
58 results(13) = utp_genericOutput(mthd, pe1, pe2, val1, @algoTests, ple2); % test the outputs
59
60 disp('Done.');
61 disp('******************************************************');
62
63 elseif nargin == 1 % Check for UTP functions
64 if strcmp(varargin{1}, 'isutp')
65 results = 1;
66 else
67 results = 0;
68 end
69 else
70 error('### Incorrect inputs')
71 end
72
73 % Check that the default value un the PLIST
74 function atest = algoTests_minfo(defVal)
75 atest = true;
76 % Check default value for the key 'pdf'
77 if ~eq(defVal, []), atest = false; end
78 end
79
80 % Check that the property have the correct value
81 function atest = algoTests(in, out, idx, value)
82 atest = true;
83 % Check that the input and output objects are the same except the
84 % property 'pdf' and the history
85 ple = plist('EXCEPTIONS', {'created', 'proctime', 'UUID', 'hist', prop});
86 if ~eq(in(idx), out(idx), ple), atest = false; end
87 if ~eq(in(idx).hist, out(idx).hist.inhists), atest = false; end
88 % Check that the parameter gets the correct value.
89 if isa(value, 'plist') && value.nparams == 1 && value.isparam(prop)
90 % The value was set with a plist.
91 if ~isequal(out(idx).(prop), value.find(prop)), atest = false; end
92 else
93 if ~isequal(out(idx).(prop), value), atest = false; end
94 end
95 end
96
97 % Check that the property have the correct value for an internal call
98 function atest = algoTestsInternal(in, out, idx, value)
99 atest = true;
100 % Check that the input and output objects are the same except the
101 % property 'pdf' and the history
102 ple = plist('EXCEPTIONS', {'created', 'proctime', 'UUID', prop});
103 if ~eq(in(idx), out(idx), ple), atest = false; end
104 % Check that the parameter gets the correct value.
105 if ~isequal(out(idx).(prop), value), atest = false; end
106 end
107
108
109 end