Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / API_CppTest / SRC / core / collectoroutput.cpp
1 // ---
2 //
3 // $Id: collectoroutput.cpp,v 1.4 2008/07/15 20:33:31 hartwork Exp $
4 //
5 // CppTest - A C++ Unit Testing Framework
6 // Copyright (c) 2003 Niklas Lundell
7 //
8 // ---
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the
22 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 // Boston, MA 02111-1307, USA.
24 //
25 // ---
26
27
28 #if (defined(__WIN32__) || defined(WIN32))
29 # include "winconfig.h"
30 #else
31 # include "config.h"
32 #endif
33
34
35 #include "cpptest-collectoroutput.h"
36
37 using namespace std;
38
39 namespace Test
40 {
41 CollectorOutput::TestInfo::TestInfo(const string name)
42 : _name(name)
43 {}
44
45 CollectorOutput::SuiteInfo::SuiteInfo(const string& name, int tests)
46 : _name(name),
47 _errors(0)
48 {
49 _tests.reserve(tests);
50 }
51
52 /// Constructs a collector object.
53 ///
54 CollectorOutput::CollectorOutput()
55 : Output(),
56 _total_errors(0)
57 {}
58
59 void
60 CollectorOutput::finished(int tests, const Time& time)
61 {
62 _total_tests = tests;
63 _total_time = time;
64 }
65
66 void
67 CollectorOutput::suite_start(int tests, const string& name)
68 {
69 if (tests > 0)
70 {
71 _suites.push_back(SuiteInfo(name, tests));
72 _cur_suite = &_suites.back();
73 }
74 }
75
76 void
77 CollectorOutput::suite_end(int tests, const string&, const Time& time)
78 {
79 if (tests > 0)
80 {
81 _cur_suite->_time = time;
82 _total_errors += _cur_suite->_errors;
83 }
84 }
85
86 void
87 CollectorOutput::test_start(const string& name)
88 {
89 _cur_suite->_tests.push_back(TestInfo(name));
90 _cur_test = &_cur_suite->_tests.back();
91 }
92
93 void
94 CollectorOutput::test_end(const string&, bool ok, const Time& time)
95 {
96 if (!(_cur_test->_success = ok))
97 ++_cur_suite->_errors;
98 _cur_test->_time = time;
99
100 }
101
102 void
103 CollectorOutput::assertment(const Source& s)
104 {
105 _cur_test->_sources.push_back(s);
106
107 }
108
109 } // namespace Test
110