annotate testing/utp_1.1/generic_utps/utp_67.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
1 % <TestDescription>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
2 %
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
3 % Tests that the constructor properly applies history to the
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
4 % pole/zero model + plist object constructor.
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
5 %
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
6 % </TestDescription>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
7 function result = utp_67(cl, ple1)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
8
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
9 % <SyntaxDescription>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
10 %
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
11 % Tests that the constructor properly applies history to the
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
12 % pole/zero model + plist object constructor.
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
13 %
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
14 % </SyntaxDescription>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
15
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
16 try
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
17 % <SyntaxCode>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
18 ps = [pz(1) pz(200)];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
19 zs = pz(50);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
20 pzm = pzmodel(1, ps, zs, unit('Hz'), unit('V'));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
21 out = feval(cl, pzm, plist('fs', 10, 'nsecs', 10));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
22
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
23 rout = rebuild(out);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
24 % </SyntaxCode>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
25 stest = true;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
26 catch err
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
27 disp(err.message)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
28 stest = false;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
29 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
30
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
31 % <AlgoDescription>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
32 %
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
33 % 1) Check that the last entry in the history of 'out' corresponds to
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
34 % class name.
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
35 % 2) Check that the 'rebuild' method produces the same object as 'out'.
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
36 %
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
37 % </AlgoDescription>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
38
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
39 atest = true;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
40 if stest
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
41 % <AlgoCode>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
42 % Check the last step in the history of 'out'
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
43 if ~strcmp(out.hist.methodInfo.mname, cl), atest = false; end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
44 % Check values
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
45 % Rebuild object and check the result
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
46 if ~eq(rout, out, ple1), atest = false; end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
47 % </AlgoCode>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
48 else
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
49 atest = false;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
50 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
51
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
52 % Return a result structure
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
53 dd = dbstack;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
54 mfilename = dd(2).file(1:end-2);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
55 result = utp_prepare_result(atest, stest, dbstack, mfilename);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
56 end % END UTP_67