comparison m-toolbox/classes/tests/@ut_result_printer/ut_result_printer.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % UT_RESULT_PRINTER displays results from an ltpda_test_runner.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: UT_RESULT_PRINTER provides methods to view the result-set
5 % contained in an ltpda_test_runner.
6 %
7 % CALL:
8 % printer = ut_result_printer(ltpda_test_runner)
9 %
10 % SUPER CLASSES: handle
11 %
12 %
13 % VERSION: $Id: ut_result_printer.m,v 1.5 2010/11/16 08:07:04 hewitson Exp $
14 %
15 %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 classdef ut_result_printer
18
19 properties
20 results = [];
21 end
22
23 properties (Dependent = true)
24 npassed;
25 nresults;
26 end
27
28 methods
29
30 function val = get.npassed(urp)
31 if isempty(urp.results)
32 val = 0;
33 else
34 val = sum([urp.results(:).passed]);
35 end
36 end
37
38 function val = get.nresults(urp)
39 val = numel(urp.results);
40 end
41
42 function urp = ut_result_printer(runner)
43 urp.results = runner.results;
44 end
45
46
47
48 end
49
50 methods (Access=private)
51
52
53 end
54
55
56
57 methods (Static)
58
59 function str = dispRuntime(res)
60 if numel(res.testMethod) > 35
61 res.testMethod = [fcn(1:31), ' ...'];
62 end
63 str = sprintf('%-36s %8.3f s\n', res.testMethod, res.runtime);
64 end
65
66 function str = dispRes(res)
67 if numel(res.testMethod) > 35
68 res.testMethod = [fcn(1:31), ' ...'];
69 end
70 str = sprintf('%-36s%s %s %s %s\n', res.testMethod, ut_result_printer.res2str(res.syntax), ut_result_printer.res2str(res.algorithm), ut_result_printer.res2str(res.skipped), res.message);
71 end
72
73 function str = res2str(a)
74 if islogical(a)
75 if (a)
76 str = ' pass ';
77 else
78 str = '--fail--';
79 end
80 elseif ischar(a)
81 str = a;
82 else
83 str = '';
84 end
85 end
86
87 end
88
89
90 end