diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testing/utp_1.1/generic_utps/utp_67.m	Tue Dec 06 18:42:11 2011 +0100
@@ -0,0 +1,56 @@
+% <TestDescription>
+%
+% Tests that the constructor properly applies history to the
+% pole/zero model + plist object constructor.
+%
+% </TestDescription>
+function result = utp_67(cl, ple1)
+  
+  % <SyntaxDescription>
+  %
+  % Tests that the constructor properly applies history to the
+  % pole/zero model + plist object constructor.
+  %
+  % </SyntaxDescription>
+  
+  try
+    % <SyntaxCode>
+    ps  = [pz(1) pz(200)];
+    zs  = pz(50);
+    pzm = pzmodel(1, ps, zs, unit('Hz'), unit('V'));
+    out = feval(cl, pzm, plist('fs', 10, 'nsecs', 10));
+    
+    rout = rebuild(out);
+    % </SyntaxCode>
+    stest = true;
+  catch err
+    disp(err.message)
+    stest = false;
+  end
+  
+  % <AlgoDescription>
+  %
+  % 1) Check that the last entry in the history of 'out' corresponds to
+  %    class name.
+  % 2) Check that the 'rebuild' method produces the same object as 'out'.
+  %
+  % </AlgoDescription>
+  
+  atest = true;
+  if stest
+    % <AlgoCode>
+    % Check the last step in the history of 'out'
+    if ~strcmp(out.hist.methodInfo.mname, cl), atest = false; end
+    % Check values
+    % Rebuild object and check the result
+    if ~eq(rout, out, ple1), atest = false; end
+    % </AlgoCode>
+  else
+    atest = false;
+  end
+  
+  % Return a result structure
+  dd = dbstack;
+  mfilename = dd(2).file(1:end-2);  
+  result = utp_prepare_result(atest, stest, dbstack, mfilename);
+end % END UTP_67
\ No newline at end of file