Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/smodel/utp_smodel_clearAliases.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_SMODEL_CLEARALIASES a set of UTPs for the smodel/clearAliases method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_smodel_clearAliases.m,v 1.1 2011/04/11 19:45:22 ingo Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The clearAliases method of the smodel class clears the 'aliasNames' and | |
11 % 'aliasValues' properties. | |
12 % | |
13 % </MethodDescription> | |
14 | |
15 function results = utp_smodel_clearAliases(varargin) | |
16 | |
17 % Check the inputs | |
18 if nargin == 0 | |
19 | |
20 % Some keywords | |
21 cl = 'smodel'; | |
22 mthd = 'clearAliases'; | |
23 | |
24 disp('******************************************************'); | |
25 disp(['**** Running UTPs for ' cl '/' mthd]); | |
26 disp('******************************************************'); | |
27 | |
28 % Test objects | |
29 s1 = smodel('a1*x1 + a2*x2 + a3*x3'); | |
30 s1.setName(); | |
31 | |
32 s2 = smodel('a1*x1 + a2*x2'); | |
33 s2.setName(); | |
34 | |
35 s3 = smodel('a1*x1'); | |
36 s3.setName(); | |
37 | |
38 sv = [s1, s2, s1]; | |
39 sm = [s1, s2, s1; s1, s2, s1]; | |
40 | |
41 % Exception list for the UTPs: | |
42 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); | |
43 | |
44 % The setter method have different possibilities to set a property | |
45 | |
46 % Run the general tests | |
47 results(1) = utp_01(); | |
48 results(2) = utp_genericAnyShape(mthd, s1, {}, @algoTests); | |
49 results(3) = utp_genericAnyShape(mthd, sv, {}, @algoTests); | |
50 results(4) = utp_genericAnyShape(mthd, sm, {}, @algoTests); | |
51 results(5) = utp_genericList(mthd, s1, s2, s3, {}, @algoTests); | |
52 results(6) = utp_genericHistory(mthd, s1, {}, ple2); | |
53 results(7) = utp_genericModify(mthd, s1, {}, @algoTests, ple1); | |
54 results(8) = utp_genericOutput(mthd, s1, s2, {}, @algoTests, ple2); % test the outputs | |
55 | |
56 disp('Done.'); | |
57 disp('******************************************************'); | |
58 | |
59 elseif nargin == 1 % Check for UTP functions | |
60 if strcmp(varargin{1}, 'isutp') | |
61 results = 1; | |
62 else | |
63 results = 0; | |
64 end | |
65 else | |
66 error('### Incorrect inputs') | |
67 end | |
68 | |
69 % Check that the property have the correct value | |
70 function atest = algoTests(in, out, idx, argsin) | |
71 atest = true; | |
72 % Check that the input and output objects are the same except the | |
73 % property 'aliases' and the history | |
74 ple = plist('EXCEPTIONS', {'created', 'proctime', 'UUID', 'hist', 'aliasNames', 'aliasValues'}); | |
75 if ~eq(in(idx), out(idx), ple), atest = false; end | |
76 if ~eq(in(idx).hist, out(idx).hist.inhists), atest = false; end | |
77 | |
78 % Check 'aliasNames' and 'aliasValues' | |
79 if ~isequal(out(idx).aliasNames, {}), atest = false; end | |
80 if ~isequal(out(idx).aliasValues, {}), atest = false; end | |
81 end | |
82 | |
83 %% UTP_01 | |
84 | |
85 % <TestDescription> | |
86 % | |
87 % Tests that the getInfo call works for this method. | |
88 % | |
89 % </TestDescription> | |
90 function result = utp_01 | |
91 | |
92 | |
93 % <SyntaxDescription> | |
94 % | |
95 % Test that the getInfo call works for no sets, all sets, and each set | |
96 % individually. | |
97 % | |
98 % </SyntaxDescription> | |
99 | |
100 try | |
101 % <SyntaxCode> | |
102 % Call for no sets | |
103 io(1) = feval('smodel.getInfo', mthd, 'none'); | |
104 % Call for all sets | |
105 io(2) = feval('smodel.getInfo', mthd); | |
106 % Call for each set | |
107 for kk=1:numel(io(2).sets) | |
108 io(kk+2) = feval('smodel.getInfo', mthd, io(2).sets{kk}); | |
109 end | |
110 % </SyntaxCode> | |
111 stest = true; | |
112 catch err | |
113 disp(err.message) | |
114 stest = false; | |
115 end | |
116 | |
117 % <AlgoDescription> | |
118 % | |
119 % 1) Check that getInfo call returned an minfo object in all cases. | |
120 % 2) Check that all plists have the correct parameters. | |
121 % | |
122 % </AlgoDescription> | |
123 | |
124 atest = true; | |
125 if stest | |
126 % <AlgoCode> | |
127 % check we have minfo objects | |
128 if isa(io, 'minfo') | |
129 % SET 'None' | |
130 if ~isempty(io(1).sets), atest = false; end | |
131 if ~isempty(io(1).plists), atest = false; end | |
132 % Check all Sets | |
133 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end | |
134 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end | |
135 % SET 'Default' | |
136 if io(3).plists.nparams ~= 0, atest = false; end | |
137 % Check key | |
138 % Check default value | |
139 % Check options | |
140 end | |
141 % </AlgoCode> | |
142 else | |
143 atest = false; | |
144 end | |
145 | |
146 % Return a result structure | |
147 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
148 end % END UTP_01 | |
149 | |
150 end |