comparison testing/utp_1.1/generic_utps/utp_63.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 % Tests that the constructor properly applies history to the pzmodel constructor.
4 %
5 % </TestDescription>
6 function result = utp_63(cl, ple1)
7
8 % <SyntaxDescription>
9 %
10 % Tests that the constructor properly applies history to the pzmodel constructor.
11 %
12 % </SyntaxDescription>
13
14 try
15 % <SyntaxCode>
16 ps = [pz(1) pz(200)];
17 zs = pz(50);
18 pzm = pzmodel(1, ps, zs, unit('Hz^2'), unit('V^2'));
19 out = feval(cl, pzm);
20 mout = rebuild(out);
21 % </SyntaxCode>
22 stest = true;
23 catch err
24 disp(err.message)
25 stest = false;
26 end
27
28 % <AlgoDescription>
29 %
30 % 1) Check that the last entry in the history of 'out'
31 % corresponds to the class name.
32 % 2) Check that the 'rebuild' method produces the same object as 'out'.
33 %
34 % </AlgoDescription>
35
36 atest = true;
37 if stest
38 % <AlgoCode>
39 % Check that the output is the correct class of object
40 if ~isa(out,cl), atest = false; end
41 % Check the last step in the history of 'out'
42 if ~strcmp(out.hist.methodInfo.mname, cl), atest = false; end
43 if ~strcmp(out.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end
44 % Check the rebuilt object
45 if ~eq(mout, out, ple1), atest = false; end
46 % </AlgoCode>
47 else
48 atest = false;
49 end
50
51 % Return a result structure
52 dd = dbstack;
53 mfilename = dd(2).file(1:end-2);
54 result = utp_prepare_result(atest, stest, dbstack, mfilename);
55 end % END UTP_63