diff testing/utp_1.1/utp_fcns/utp_prepare_result.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/utp_fcns/utp_prepare_result.m	Tue Dec 06 18:42:11 2011 +0100
@@ -0,0 +1,75 @@
+% UTP_PREPARE_RESULT prepares a result structure from the inputs
+%
+% M Hewitson 07-11-07
+%
+% $Id: utp_prepare_result.m,v 1.13 2011/04/27 09:03:02 hewitson Exp $
+%
+function result = utp_prepare_result(a, s, stack, call, varargin)
+
+  result.a       = 0;
+  result.s       = 0;
+  result.fcn     = '?';
+  result.num     = '?';
+  result.date    = time;
+  result.runtime = toc();
+  result.msg     = '?';
+  result.method  = '?';
+  result.class   = '?';
+  result.file    = '?';
+  
+  if numel(stack)>1
+    
+    % look for utp_run
+    idx = -1;
+    for kk=1:numel(stack)
+      if strcmp(stack(kk).name, 'utp_run')
+        idx = kk;
+        break;
+      end
+    end
+    
+    if idx>0
+      call = stack(idx-1).name;
+    end
+  end
+  
+  % parse out utp number
+  parts = regexp(stack(1).name, '_', 'split');
+  parts = regexp(parts{end}, '(\w+)(\(.*\))*', 'tokens');
+  utpnum = parts{1}{1};
+  
+  result.a       = a;
+  result.s       = s;
+  result.fcn     = sprintf('%s_%s', call, utpnum);
+  result.num     = utpnum;
+  result.subnum  = parts{1}{2};
+  result.msg     = '';
+  
+  parts = regexp(call, '_', 'split');
+  result.method  = parts{end};
+  result.class   = parts{end-1};
+  result.utp     = strrep(stack(1).name, result.subnum, '');
+  if ismember('file', fieldnames(stack(1)))
+    result.file    = stack(1).file;
+  else
+    result.file = '';
+  end
+  
+  if a
+    as = 'Pass';
+  else
+    as = 'Fail';
+  end
+  if s
+    ss = 'Pass';
+  else
+    ss = 'Fail';
+  end
+
+  if numel(varargin) >= 1
+    result.msg = varargin{1};
+    fprintf('  %-27s  |  %s  |  %s  | %s\n', result.num, ss, as, varargin{1});
+  else
+    fprintf('  %-27s  |  %s  |  %s\n', result.num, ss, as);
+  end
+end