GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GTestSuites Class Reference

Test suite container class. More...

#include <GTestSuites.hpp>

Inheritance diagram for GTestSuites:
GContainer GBase

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...
 
GTestSuitesoperator= (const GTestSuites &suites)
 Assignment operator. More...
 
GTestSuiteoperator[] (const int &index)
 Returns pointer to test suite. More...
 
const GTestSuiteoperator[] (const int &index) const
 Returns pointer to test suite (const version) More...
 
void clear (void)
 Clear test suites. More...
 
GTestSuitesclone (void) const
 Clone test suites. More...
 
std::string classname (void) const
 Return class name. More...
 
GTestSuiteat (const int &index)
 Returns pointer to test suite. More...
 
const GTestSuiteat (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...
 
GTestSuiteset (const int &index, const GTestSuite &suite)
 Set test suite in container. More...
 
GTestSuiteappend (const GTestSuite &suite)
 Append test suite to container. More...
 
GTestSuiteinsert (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...
 

Detailed Description

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

Definition at line 53 of file GTestSuites.hpp.

Constructor & Destructor Documentation

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.

Parameters
[in]suitesTest suite container.

Definition at line 74 of file GTestSuites.cpp.

References copy_members(), and init_members().

GTestSuites::GTestSuites ( const std::string &  name)
explicit

Name constructor.

Parameters
[in]nameName of the test suites.

Definition at line 92 of file GTestSuites.cpp.

References init_members(), m_name, and name().

GTestSuites::~GTestSuites ( void  )
virtual

Destructor.

Definition at line 108 of file GTestSuites.cpp.

References free_members().

Member Function Documentation

GTestSuite * GTestSuites::append ( const GTestSuite suite)

Append test suite to container.

Parameters
[in]suiteTest suite.
Returns
Pointer to deep copy of 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.

Parameters
[in]indexTest suite index [0,...,size()-1].
Exceptions
GException::out_of_rangeTest 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)

Parameters
[in]indexTest Suite index [0,...,size()-1].
Exceptions
GException::out_of_rangeTest suite index is out of range.

Definition at line 215 of file GTestSuites.cpp.

References G_AT, m_testsuites, and size().

std::string GTestSuites::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GTestSuites").

Implements GBase.

Definition at line 113 of file GTestSuites.hpp.

void GTestSuites::clear ( void  )
virtual

Clear test suites.

Implements GBase.

Definition at line 160 of file GTestSuites.cpp.

References free_members(), and init_members().

GTestSuites * GTestSuites::clone ( void  ) const
virtual

Clone test suites.

Returns
Pointer to deep copy of test suites.

Implements GBase.

Definition at line 178 of file GTestSuites.cpp.

References GTestSuites().

Referenced by extend().

void GTestSuites::copy_members ( const GTestSuites suites)
protected

Copy class members.

Parameters
[in]suitesTest 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=().

void GTestSuites::cout ( const bool &  flag)
inline

Enables/disables logging into standard output stream.

Parameters
[in]flagEnable/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.

Parameters
[in]suitesTest 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().

void GTestSuites::free_members ( void  )
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().

void GTestSuites::init_members ( void  )
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.

Parameters
[in]indexTest suite index [0,...,size()-1].
[in]suiteTest suite.
Returns
Pointer to deep copy of test suite.
Exceptions
GException::out_of_rangeTest 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().

bool GTestSuites::is_empty ( void  ) const
inlinevirtual

Signals if there are no test suites in the container.

Returns
True if test suite container is empty, false otherwise.

Signals if the container does not contain any test suite.

Implements GContainer.

Definition at line 173 of file GTestSuites.hpp.

References m_testsuites.

Referenced by extend(), and insert().

const std::string & GTestSuites::name ( void  ) const
inline

Return test suite container name.

Returns
Test suite container name

Definition at line 200 of file GTestSuites.hpp.

References m_name.

Referenced by GTestSuites(), name(), run(), and write().

void GTestSuites::name ( const std::string &  name)
inline

Set test suite container name.

Parameters
[in]nameTest suite container name.

Definition at line 212 of file GTestSuites.hpp.

References m_name, and name().

GTestSuites & GTestSuites::operator= ( const GTestSuites suites)

Assignment operator.

Parameters
[in]suitesTest suite container.
Returns
Test suite container.

Definition at line 130 of file GTestSuites.cpp.

References copy_members(), free_members(), and init_members().

GTestSuite * GTestSuites::operator[] ( const int &  index)
inline

Returns pointer to test suite.

Parameters
[in]indexTest suite index [0,...,size()-1].
Returns
Pointer to test suite.

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.

const GTestSuite * GTestSuites::operator[] ( const int &  index) const
inline

Returns pointer to test suite (const version)

Parameters
[in]indexTest suite index [0,...,size()-1].
Returns
Pointer to test suite.

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.

std::string GTestSuites::print ( const GChatter chatter = NORMAL) const
virtual

Print test suites information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing test suites information.

Implements GBase.

Definition at line 503 of file GTestSuites.cpp.

References errors(), failures(), m_name, gammalib::parformat(), SILENT, size(), gammalib::str(), and tests().

void GTestSuites::remove ( const int &  index)
virtual

Remove test suite from container.

Parameters
[in]indexTest suite index [0,...,size()-1].
Exceptions
GException::out_of_rangeTest 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().

void GTestSuites::reserve ( const int &  num)
inlinevirtual

Reserves space for test suites in container.

Parameters
[in]numNumber 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.

Parameters
[in]filenameName 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.

Parameters
[in]indexTest suite index [0,...,size()-1].
[in]suiteTest suite.
Returns
Pointer to deep copy of test suite.
Exceptions
GException::out_of_rangeTest 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().

int GTestSuites::size ( void  ) const
inlinevirtual

Return number of test suites in container.

Returns
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().

const time_t & GTestSuites::timestamp ( void  ) const
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.

Member Data Documentation

GLog GTestSuites::m_log
protected

Log.

Definition at line 103 of file GTestSuites.hpp.

Referenced by copy_members(), cout(), free_members(), and init_members().

std::string GTestSuites::m_name
protected

Name of container.

Definition at line 100 of file GTestSuites.hpp.

Referenced by copy_members(), GTestSuites(), init_members(), name(), print(), and write().

std::vector<GTestSuite*> GTestSuites::m_testsuites
protected
time_t GTestSuites::m_timestamp
protected

Timestamp.

Definition at line 102 of file GTestSuites.hpp.

Referenced by copy_members(), init_members(), and timestamp().


The documentation for this class was generated from the following files: