GTestSuites.hpp
8.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/***************************************************************************
* GTestSuites.hpp - Test suite container class *
* ----------------------------------------------------------------------- *
* copyright (C) 2012-2014 by Jean-Baptiste Cayrou *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
***************************************************************************/
/**
* @file GTestSuites.hpp
* @brief Test suite container class interface definition
* @author Jean-Baptiste Cayrou
*/
#ifndef GTESTSUITES_HPP
#define GTESTSUITES_HPP
/* __ Includes ___________________________________________________________ */
#include <string>
#include <vector>
#include "GContainer.hpp"
#include "GLog.hpp"
#include "GXml.hpp"
#include "GTestSuite.hpp"
/***********************************************************************//**
* @class GTestSuites
*
* @brief Test suite container class
*
* This is a container class for test suites. All test suites will be
* executed by invoking the run() method, and test results are saved in
* JUnit format to an XML file using the save() method.
*
* @todo Provide detailed description
***************************************************************************/
class GTestSuites : public GContainer {
public:
// Constructors and destructors
GTestSuites(void);
GTestSuites(const GTestSuites& suites);
GTestSuites(const std::string& name);
virtual ~GTestSuites(void);
// Operators
GTestSuites& operator=(const GTestSuites& suites);
GTestSuite* operator[](const int& index);
const GTestSuite* operator[](const int& index) const;
// Methods
void clear(void);
GTestSuites* clone(void) const;
std::string classname(void) const;
GTestSuite* at(const int& index);
const GTestSuite* at(const int& index) const;
int size(void) const;
bool is_empty(void) const;
GTestSuite* set(const int& index, const GTestSuite& suite);
GTestSuite* append(const GTestSuite& suite);
GTestSuite* insert(const int& index, const GTestSuite& suite);
void remove(const int& index);
void reserve(const int& num);
void extend(const GTestSuites& suites);
const std::string& name(void) const;
void name(const std::string& name);
void cout(const bool& flag);
int errors(void) const;
int failures(void) const;
int tests(void) const;
const time_t& timestamp(void) const;
bool run(void);
void save(const std::string& filename) const;
std::string print(const GChatter& chatter = NORMAL) const;
protected:
// Protected methods
void init_members(void);
void copy_members(const GTestSuites& suites);
void free_members(void);
void write(GXml& xml) const;
// Protected members
std::string m_name; //!< Name of container
std::vector<GTestSuite*> m_testsuites; //!< Vector of test suites
time_t m_timestamp; //!< Timestamp
GLog m_log; //!< Log
};
/***********************************************************************//**
* @brief Return class name
*
* @return String containing the class name ("GTestSuites").
***************************************************************************/
inline
std::string GTestSuites::classname(void) const
{
return ("GTestSuites");
}
/***********************************************************************//**
* @brief Returns pointer to test suite
*
* @param[in] index Test suite index [0,...,size()-1].
* @return Pointer to test suite.
*
* Returns pointer to test suite with @p index. No range checking is done
* for the index.
***************************************************************************/
inline
GTestSuite* GTestSuites::operator[](const int& index)
{
return (m_testsuites[index]);
}
/***********************************************************************//**
* @brief Returns pointer to test suite (const version)
*
* @param[in] index Test suite index [0,...,size()-1].
* @return Pointer to test suite.
*
* Returns pointer to test suite with @p index. No range checking is done
* for the index.
***************************************************************************/
inline
const GTestSuite* GTestSuites::operator[](const int& index) const
{
return (m_testsuites[index]);
}
/***********************************************************************//**
* @brief Return number of test suites in container
*
* @return Number of test suites in container.
*
* Returns the number of test suites in the container.
***************************************************************************/
inline
int GTestSuites::size(void) const
{
return m_testsuites.size();
}
/***********************************************************************//**
* @brief Signals if there are no test suites in the container
*
* @return True if test suite container is empty, false otherwise.
*
* Signals if the container does not contain any test suite.
***************************************************************************/
inline
bool GTestSuites::is_empty(void) const
{
return (m_testsuites.empty());
}
/***********************************************************************//**
* @brief Reserves space for test suites in container
*
* @param[in] num Number of test suites.
*
* Reserves space for @p num test suites in the container.
***************************************************************************/
inline
void GTestSuites::reserve(const int& num)
{
m_testsuites.reserve(num);
return;
}
/***********************************************************************//**
* @brief Return test suite container name
*
* @return Test suite container name
***************************************************************************/
inline
const std::string& GTestSuites::name(void) const
{
return m_name;
}
/***********************************************************************//**
* @brief Set test suite container name
*
* @param[in] name Test suite container name.
***************************************************************************/
inline
void GTestSuites::name(const std::string& name)
{
m_name = name;
return;
}
/***********************************************************************//**
* @brief Enables/disables logging into standard output stream
*
* @param[in] flag Enable/disable logging (true/false).
*
* Enables or disables logging into the standard output stream.
***************************************************************************/
inline
void GTestSuites::cout(const bool& flag)
{
m_log.cout(flag);
return;
}
/***********************************************************************//**
* @brief Return the timestamp
*
* The time step is set at the moment of construction of the test suites
* container.
***************************************************************************/
inline
const time_t& GTestSuites::timestamp(void) const
{
return m_timestamp;
}
#endif /* GTESTSUITES_HPP */