comparison 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
comparison
equal deleted inserted replaced
43:bc767aaa99a8 44:409a22968d5e
1 % UTP_PREPARE_RESULT prepares a result structure from the inputs
2 %
3 % M Hewitson 07-11-07
4 %
5 % $Id: utp_prepare_result.m,v 1.13 2011/04/27 09:03:02 hewitson Exp $
6 %
7 function result = utp_prepare_result(a, s, stack, call, varargin)
8
9 result.a = 0;
10 result.s = 0;
11 result.fcn = '?';
12 result.num = '?';
13 result.date = time;
14 result.runtime = toc();
15 result.msg = '?';
16 result.method = '?';
17 result.class = '?';
18 result.file = '?';
19
20 if numel(stack)>1
21
22 % look for utp_run
23 idx = -1;
24 for kk=1:numel(stack)
25 if strcmp(stack(kk).name, 'utp_run')
26 idx = kk;
27 break;
28 end
29 end
30
31 if idx>0
32 call = stack(idx-1).name;
33 end
34 end
35
36 % parse out utp number
37 parts = regexp(stack(1).name, '_', 'split');
38 parts = regexp(parts{end}, '(\w+)(\(.*\))*', 'tokens');
39 utpnum = parts{1}{1};
40
41 result.a = a;
42 result.s = s;
43 result.fcn = sprintf('%s_%s', call, utpnum);
44 result.num = utpnum;
45 result.subnum = parts{1}{2};
46 result.msg = '';
47
48 parts = regexp(call, '_', 'split');
49 result.method = parts{end};
50 result.class = parts{end-1};
51 result.utp = strrep(stack(1).name, result.subnum, '');
52 if ismember('file', fieldnames(stack(1)))
53 result.file = stack(1).file;
54 else
55 result.file = '';
56 end
57
58 if a
59 as = 'Pass';
60 else
61 as = 'Fail';
62 end
63 if s
64 ss = 'Pass';
65 else
66 ss = 'Fail';
67 end
68
69 if numel(varargin) >= 1
70 result.msg = varargin{1};
71 fprintf(' %-27s | %s | %s | %s\n', result.num, ss, as, varargin{1});
72 else
73 fprintf(' %-27s | %s | %s\n', result.num, ss, as);
74 end
75 end