diff testing/utp_1.1/generic_utps/utp_10.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_10.m	Tue Dec 06 18:42:11 2011 +0100
@@ -0,0 +1,57 @@
+% <TestDescription>
+%
+% Check that the <METHOD> method pass back the output objects to a list of
+% output variables or to a single variable.
+%
+% </TestDescription>
+function result = utp_10(method, obj1, obj2, ple2)
+  
+  % <SyntaxDescription>
+  %
+  % Call the method with a list of output variables and with a single output
+  % variable. Additionaly check that the rebuild method works on the output.
+  %
+  % </SyntaxDescription>
+  
+  try
+    % <SyntaxCode>
+    [o1, o2] = feval(method, obj1, obj2);
+    o3  = feval(method, obj1, obj2);
+    mout1 = rebuild(o1);
+    mout2 = rebuild(o2);
+    mout3 = rebuild(o3);
+    % </SyntaxCode>
+    stest = true;
+  catch err
+    disp(err.message)
+    stest = false;
+  end
+  
+  % <AlgoDescription>
+  %
+  % 1) Check that the output contains the right number of objects
+  % 2) Check that the 'rebuild' method produces the same object as 'out'.
+  %
+  % </AlgoDescription>
+  
+  atest = true;
+  if stest
+    % <AlgoCode>
+    % Check the number of outputs
+    if numel(o1) ~=1, atest = false; end
+    if numel(o2) ~=1, atest = false; end
+    if numel(o3) ~=2, atest = false; end
+    % Check the rebuilding of the object
+    if ~eq(o1, mout1, ple2), atest = false; end
+    if ~eq(o2, mout2, ple2), atest = false; end
+    if ~eq(o3, mout3, ple2), 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_10