Mercurial > hg > ltpda
comparison testing/utp_1.1/generic_utps/utp_09.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 % <TestDescription> | |
2 % | |
3 % Test the shape of the data in AOs. | |
4 % | |
5 % </TestDescription> | |
6 function result = utp_09(method, obj1, obj2) | |
7 | |
8 % <SyntaxDescription> | |
9 % | |
10 % Test that the <METHOD> method keeps the data shape of the input object. The | |
11 % input AO data must be an array with row data and/or column data. | |
12 % | |
13 % </SyntaxDescription> | |
14 | |
15 try | |
16 % <SyntaxCode> | |
17 | |
18 if iscolumnvector(obj1) == iscolumnvector(obj2) | |
19 warning('!!! Incorrect inputs. Give a column and a row vector.'); | |
20 stest = false; | |
21 else | |
22 out1 = feval(method, obj1); | |
23 out2 = feval(method, obj2); | |
24 % </SyntaxCode> | |
25 stest = true; | |
26 end | |
27 | |
28 catch err | |
29 disp(err.message) | |
30 stest = false; | |
31 end | |
32 | |
33 % <AlgoDescription> | |
34 % | |
35 % 1) Check that the shape of the data doesn't change. | |
36 % | |
37 % </AlgoDescription> | |
38 | |
39 atest = true; | |
40 if stest | |
41 % <AlgoCode> | |
42 % Check the shape of the output data | |
43 | |
44 atest = false; | |
45 | |
46 if iscolumnvector(out1) && iscolumnvector(obj1) | |
47 atest = true; | |
48 end | |
49 | |
50 if isrowvector(out1) && isrowvector(obj1) | |
51 atest = true; | |
52 end | |
53 | |
54 | |
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_09 | |
65 | |
66 function res = iscolumnvector(obj) | |
67 | |
68 if size(obj.data.y, 1)>=1 && size(obj.data.y,2)==1 | |
69 res = true; | |
70 else | |
71 res = false; | |
72 end | |
73 | |
74 end | |
75 | |
76 | |
77 function res = isrowvector(obj) | |
78 | |
79 if size(obj.data.y, 2)>=1 && size(obj.data.y,1)==1 | |
80 res = true; | |
81 else | |
82 res = false; | |
83 end | |
84 | |
85 end |