GammaLib
2.0.0
|
Test suite container class. More...
#include <GTestSuites.hpp>
Public Member Functions | |
GTestSuites (void) | |
Void constructor. More... | |
GTestSuites (const GTestSuites &suites) | |
Copy constructor. More... | |
GTestSuites (const std::string &name) | |
Name constructor. More... | |
virtual | ~GTestSuites (void) |
Destructor. More... | |
GTestSuites & | operator= (const GTestSuites &suites) |
Assignment operator. More... | |
GTestSuite * | operator[] (const int &index) |
Returns pointer to test suite. More... | |
const GTestSuite * | operator[] (const int &index) const |
Returns pointer to test suite (const version) More... | |
void | clear (void) |
Clear test suites. More... | |
GTestSuites * | clone (void) const |
Clone test suites. More... | |
std::string | classname (void) const |
Return class name. More... | |
GTestSuite * | at (const int &index) |
Returns pointer to test suite. More... | |
const GTestSuite * | at (const int &index) const |
Returns pointer to test suite (const version) More... | |
int | size (void) const |
Return number of test suites in container. More... | |
bool | is_empty (void) const |
Signals if there are no test suites in the container. More... | |
GTestSuite * | set (const int &index, const GTestSuite &suite) |
Set test suite in container. More... | |
GTestSuite * | append (const GTestSuite &suite) |
Append test suite to container. More... | |
GTestSuite * | insert (const int &index, const GTestSuite &suite) |
Insert test suite into container. More... | |
void | remove (const int &index) |
Remove test suite from container. More... | |
void | reserve (const int &num) |
Reserves space for test suites in container. More... | |
void | extend (const GTestSuites &suites) |
Append test suite container. More... | |
const std::string & | name (void) const |
Return test suite container name. More... | |
void | name (const std::string &name) |
Set test suite container name. More... | |
void | cout (const bool &flag) |
Enables/disables logging into standard output stream. More... | |
int | errors (void) const |
Return the total number of errors in all test suites. More... | |
int | failures (void) const |
Return the total number of failures in all test suites. More... | |
int | tests (void) const |
Return the total number of tests they are in all test suites. More... | |
const time_t & | timestamp (void) const |
Return the timestamp. More... | |
bool | run (void) |
Run all tests. More... | |
void | save (const GFilename &filename) const |
Save test report into XML file. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print test suites information. More... | |
Public Member Functions inherited from GContainer | |
virtual | ~GContainer (void) |
Destructor. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GTestSuites &suites) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | write (GXml &xml) const |
Write Test Suites into XML document. More... | |
Protected Attributes | |
std::string | m_name |
Name of container. More... | |
std::vector< GTestSuite * > | m_testsuites |
Vector of test suites. More... | |
time_t | m_timestamp |
Timestamp. More... | |
GLog | m_log |
Log. More... | |
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.
Definition at line 53 of file GTestSuites.hpp.
GTestSuites::GTestSuites | ( | void | ) |
Void constructor.
Definition at line 59 of file GTestSuites.cpp.
References init_members().
Referenced by clone().
GTestSuites::GTestSuites | ( | const GTestSuites & | suites | ) |
Copy constructor.
[in] | suites | Test suite container. |
Definition at line 74 of file GTestSuites.cpp.
References copy_members(), and init_members().
|
explicit |
Name constructor.
[in] | name | Name of the test suites. |
Definition at line 92 of file GTestSuites.cpp.
References init_members(), m_name, and name().
|
virtual |
GTestSuite * GTestSuites::append | ( | const GTestSuite & | suite | ) |
Append test suite to container.
[in] | suite | Test suite. |
Appends test suite to the container by making a deep copy of the test suite and storing its pointer.
Definition at line 274 of file GTestSuites.cpp.
References GTestSuite::clone(), and m_testsuites.
GTestSuite * GTestSuites::at | ( | const int & | index | ) |
Returns pointer to test suite.
[in] | index | Test suite index [0,...,size()-1]. |
GException::out_of_range | Test suite index is out of range. |
Definition at line 193 of file GTestSuites.cpp.
References G_AT, m_testsuites, and size().
const GTestSuite * GTestSuites::at | ( | const int & | index | ) | const |
Returns pointer to test suite (const version)
[in] | index | Test Suite index [0,...,size()-1]. |
GException::out_of_range | Test suite index is out of range. |
Definition at line 215 of file GTestSuites.cpp.
References G_AT, m_testsuites, and size().
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 113 of file GTestSuites.hpp.
|
virtual |
Clear test suites.
Implements GBase.
Definition at line 160 of file GTestSuites.cpp.
References free_members(), and init_members().
|
virtual |
Clone test suites.
Implements GBase.
Definition at line 178 of file GTestSuites.cpp.
References GTestSuites().
Referenced by extend().
|
protected |
Copy class members.
[in] | suites | Test suites container. |
This method just clone the container not the test suite.
Definition at line 570 of file GTestSuites.cpp.
References m_log, m_name, m_testsuites, and m_timestamp.
Referenced by GTestSuites(), and operator=().
|
inline |
Enables/disables logging into standard output stream.
[in] | flag | Enable/disable logging (true/false). |
Enables or disables logging into the standard output stream.
Definition at line 227 of file GTestSuites.hpp.
References GLog::cout(), and m_log.
int GTestSuites::errors | ( | void | ) | const |
Return the total number of errors in all test suites.
Definition at line 389 of file GTestSuites.cpp.
References m_testsuites.
Referenced by print().
void GTestSuites::extend | ( | const GTestSuites & | suites | ) |
Append test suite container.
[in] | suites | Test suite container. |
Append test suite container to the container.
Definition at line 361 of file GTestSuites.cpp.
References clone(), is_empty(), m_testsuites, reserve(), and size().
int GTestSuites::failures | ( | void | ) | const |
Return the total number of failures in all test suites.
Definition at line 407 of file GTestSuites.cpp.
References m_testsuites.
Referenced by print().
|
protected |
Delete class members.
Definition at line 590 of file GTestSuites.cpp.
References GLog::close(), m_log, and m_testsuites.
Referenced by clear(), operator=(), and ~GTestSuites().
|
protected |
Initialise class members.
Definition at line 547 of file GTestSuites.cpp.
References GLog::buffer_size(), GLog::clear(), GLog::cout(), m_log, m_name, m_testsuites, and m_timestamp.
Referenced by clear(), GTestSuites(), and operator=().
GTestSuite * GTestSuites::insert | ( | const int & | index, |
const GTestSuite & | suite | ||
) |
Insert test suite into container.
[in] | index | Test suite index [0,...,size()-1]. |
[in] | suite | Test suite. |
GException::out_of_range | Test suite index is out of range. |
Inserts a test suite
into the container before the test suite with the specified index
.
Definition at line 300 of file GTestSuites.cpp.
References GTestSuite::clone(), G_INSERT, is_empty(), m_testsuites, and size().
|
inlinevirtual |
Signals if there are no test suites in the container.
Signals if the container does not contain any test suite.
Implements GContainer.
Definition at line 173 of file GTestSuites.hpp.
References m_testsuites.
|
inline |
Return test suite container name.
Definition at line 200 of file GTestSuites.hpp.
References m_name.
Referenced by GTestSuites(), name(), run(), and write().
|
inline |
Set test suite container name.
[in] | name | Test suite container name. |
Definition at line 212 of file GTestSuites.hpp.
GTestSuites & GTestSuites::operator= | ( | const GTestSuites & | suites | ) |
Assignment operator.
[in] | suites | Test suite container. |
Definition at line 130 of file GTestSuites.cpp.
References copy_members(), free_members(), and init_members().
|
inline |
Returns pointer to test suite.
[in] | index | Test suite index [0,...,size()-1]. |
Returns pointer to test suite with index
. No range checking is done for the index.
Definition at line 129 of file GTestSuites.hpp.
References m_testsuites.
|
inline |
Returns pointer to test suite (const version)
[in] | index | Test suite index [0,...,size()-1]. |
Returns pointer to test suite with index
. No range checking is done for the index.
Definition at line 145 of file GTestSuites.hpp.
References m_testsuites.
Print test suites information.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GBase.
Definition at line 503 of file GTestSuites.cpp.
References errors(), failures(), m_name, gammalib::parformat(), SILENT, size(), gammalib::str(), and tests().
|
virtual |
Remove test suite from container.
[in] | index | Test suite index [0,...,size()-1]. |
GException::out_of_range | Test suite index is out of range. |
Remove test suite of specified index
from container.
Implements GContainer.
Definition at line 337 of file GTestSuites.cpp.
References G_REMOVE, m_testsuites, and size().
|
inlinevirtual |
Reserves space for test suites in container.
[in] | num | Number of test suites. |
Reserves space for num
test suites in the container.
Implements GContainer.
Definition at line 187 of file GTestSuites.hpp.
References m_testsuites.
Referenced by extend().
bool GTestSuites::run | ( | void | ) |
Run all tests.
Runs all tests that are in the test suite container. The method returns true if all test suites succeeded. If one test suite failed, false is returned.
Definition at line 447 of file GTestSuites.cpp.
References gammalib::fill(), m_testsuites, and name().
void GTestSuites::save | ( | const GFilename & | filename | ) | const |
Save test report into XML file.
[in] | filename | Name of XML file. |
Saves the test results in a JUnit compliant format into an XML file.
Definition at line 481 of file GTestSuites.cpp.
References GXml::save(), and write().
GTestSuite * GTestSuites::set | ( | const int & | index, |
const GTestSuite & | suite | ||
) |
Set test suite in container.
[in] | index | Test suite index [0,...,size()-1]. |
[in] | suite | Test suite. |
GException::out_of_range | Test suite index is out of range. |
Set test suite in the container. A deep copy of the test suite will be made.
Definition at line 242 of file GTestSuites.cpp.
References GTestSuite::clone(), G_SET, m_testsuites, and size().
|
inlinevirtual |
Return number of test suites in container.
Returns the number of test suites in the container.
Implements GContainer.
Definition at line 159 of file GTestSuites.hpp.
References m_testsuites.
Referenced by at(), extend(), insert(), print(), remove(), and set().
int GTestSuites::tests | ( | void | ) | const |
Return the total number of tests they are in all test suites.
Definition at line 425 of file GTestSuites.cpp.
References m_testsuites.
Referenced by print().
|
inline |
Return the timestamp.
The time step is set at the moment of construction of the test suites container.
Definition at line 241 of file GTestSuites.hpp.
References m_timestamp.
|
protected |
Write Test Suites into XML document.
[in] | xml | XML document. |
Write test suites into the XML document.
Definition at line 613 of file GTestSuites.cpp.
References GXmlNode::append(), GXml::append(), GXmlElement::attribute(), GTestCase::duration(), GTestSuite::duration(), GTestCase::ERROR_TEST, GTestSuite::errors(), GTestSuite::failures(), GTestCase::has_passed(), GTestCase::kind(), m_name, m_testsuites, GTestCase::message(), GTestCase::name(), GXmlElement::name(), GTestSuite::name(), name(), GTestSuite::size(), gammalib::str(), GTestSuite::timestamp(), and GTestCase::type().
Referenced by save().
|
protected |
Log.
Definition at line 103 of file GTestSuites.hpp.
Referenced by copy_members(), cout(), free_members(), and init_members().
|
protected |
Name of container.
Definition at line 100 of file GTestSuites.hpp.
Referenced by copy_members(), GTestSuites(), init_members(), name(), print(), and write().
|
protected |
Vector of test suites.
Definition at line 101 of file GTestSuites.hpp.
Referenced by append(), at(), copy_members(), errors(), extend(), failures(), free_members(), init_members(), insert(), is_empty(), operator[](), remove(), reserve(), run(), set(), size(), tests(), and write().
|
protected |
Timestamp.
Definition at line 102 of file GTestSuites.hpp.
Referenced by copy_members(), init_members(), and timestamp().