diff testing/utp_1.1/generic_utps/utp_60.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_60.m	Tue Dec 06 18:42:11 2011 +0100
@@ -0,0 +1,67 @@
+
+% <TestDescription>
+%
+% Tests that the constructor method doesn't apply history to the read
+% MAT-file constructor.
+%
+% </TestDescription>
+function result = utp_60(cl, obj1, ple1)
+  
+  % <SyntaxDescription>
+  %
+  % Tests that the constructor method doesn't apply history to the read
+  % MAT-file constructor.
+  %
+  % </SyntaxDescription>
+  
+  msg = '';
+  try
+    % <SyntaxCode>
+    filename = 'obj.mat';
+    ss = feval(cl, obj1);
+    save(ss, filename);
+    
+    out  = feval(cl, filename);
+    mout = rebuild(out);
+    % </SyntaxCode>
+    stest = true;
+  catch err
+    msg = err.message;
+    disp(err.message)
+    stest = false;
+  end
+  
+  % <AlgoDescription>
+  %
+  % 1) Check that the history is the same as the history of the saved
+  %    object. Because save and load shouldn't add a history step.
+  % 2) Check that the 'rebuild' method produces the same object as 'out'.
+  %
+  % </AlgoDescription>
+  
+  atest = true;
+  if stest
+    % <AlgoCode>
+    % Check that the saved and loaded objects are the same
+    if ~eq(out, ss)
+      msg = ['The saved and loaded objects are not equal: ' lastwarn];
+      atest = false;
+    end
+    % Check the rebuilt object
+    if ~eq(mout, out, ple1)
+      msg = ['The original and rebuilt objects are not equal: ' lastwarn];
+      atest = false;
+    end
+    % </AlgoCode>
+    delete(filename);
+  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, msg);
+end % END UTP_08
+
+