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

Test class. More...

#include <GTestCase.hpp>

Inheritance diagram for GTestCase:
GBase

Public Types

enum  ErrorKind { FAIL_TEST, ERROR_TEST }
 

Public Member Functions

 GTestCase (void)
 Void constructor. More...
 
 GTestCase (const ErrorKind &kind, const std::string &name="")
 Type and name constructor. More...
 
 GTestCase (const GTestCase &test)
 Copy constructor. More...
 
virtual ~GTestCase (void)
 Destructor. More...
 
GTestCaseoperator= (const GTestCase &test)
 Assignment operator. More...
 
void clear (void)
 Clear test case. More...
 
GTestCaseclone (void) const
 Clone test case. More...
 
std::string classname (void) const
 Return class name. More...
 
const std::string & name (void) const
 Return test case name. More...
 
void name (const std::string &name)
 Set test case name. More...
 
const std::string & message (void) const
 Return test case message. More...
 
void message (const std::string &message)
 Set test case message. More...
 
const std::string & type (void) const
 Return test case type. More...
 
void type (const std::string &type)
 Set type of test case. More...
 
const ErrorKindkind (void) const
 Return kind of test case. More...
 
void kind (const ErrorKind &kind)
 Set kind of test case. More...
 
const bool & has_passed (void) const
 Return whether the test passed. More...
 
void has_passed (const bool &has_passed)
 Set if test passed. More...
 
const double & duration (void) const
 Return test case duration. More...
 
void duration (const double &duration)
 Set test duration. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print test case result. 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 GTestCase &test)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Protected Attributes

std::string m_name
 Test name. More...
 
std::string m_message
 Test message. More...
 
std::string m_type
 Test type. More...
 
bool m_has_passed
 Boolean to check test success. More...
 
ErrorKind m_kind
 Kind of test case (failure or error test) More...
 
double m_duration
 Test duration. More...
 

Detailed Description

Test class.

This class implements a single test case result. It contains information about the test name, an optional message that is created in case of an error or a failure, a type information (containing usually the name of the class that is failing), and some information about the test duration. Furthermore, the test case knows whether the test succeeded or failed, and whether the test was an error or a failure test.

Definition at line 47 of file GTestCase.hpp.

Member Enumeration Documentation

Enumerator
FAIL_TEST 
ERROR_TEST 

Definition at line 51 of file GTestCase.hpp.

Constructor & Destructor Documentation

GTestCase::GTestCase ( void  )

Void constructor.

Definition at line 51 of file GTestCase.cpp.

References init_members().

Referenced by clone().

GTestCase::GTestCase ( const ErrorKind kind,
const std::string &  name = "" 
)

Type and name constructor.

Parameters
[in]kindTest kind (FAIL_TEST or ERROR_TEST)
[in]nameTest case name (default: "")

Definition at line 67 of file GTestCase.cpp.

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

GTestCase::GTestCase ( const GTestCase test)

Copy constructor.

Parameters
[in]testTest case.

Definition at line 88 of file GTestCase.cpp.

References copy_members(), and init_members().

GTestCase::~GTestCase ( void  )
virtual

Destructor.

Definition at line 104 of file GTestCase.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GBase.

Definition at line 105 of file GTestCase.hpp.

void GTestCase::clear ( void  )
virtual

Clear test case.

Implements GBase.

Definition at line 156 of file GTestCase.cpp.

References free_members(), and init_members().

GTestCase * GTestCase::clone ( void  ) const
virtual

Clone test case.

Returns
Pointer to deep copy of test case.

Implements GBase.

Definition at line 174 of file GTestCase.cpp.

References GTestCase().

void GTestCase::copy_members ( const GTestCase test)
protected

Copy class members.

Parameters
[in]testTest case.

Copies all members from the test case class.

Definition at line 246 of file GTestCase.cpp.

References m_duration, m_has_passed, m_kind, m_message, m_name, and m_type.

Referenced by GTestCase(), and operator=().

const double & GTestCase::duration ( void  ) const
inline

Return test case duration.

Returns
Duration of test case.

Definition at line 250 of file GTestCase.hpp.

References m_duration.

Referenced by duration(), GTestSuite::run(), and GTestSuites::write().

void GTestCase::duration ( const double &  duration)
inline

Set test duration.

Parameters
[in]durationTest duration.

Definition at line 262 of file GTestCase.hpp.

References duration(), and m_duration.

void GTestCase::free_members ( void  )
protected

Delete class members.

Definition at line 263 of file GTestCase.cpp.

Referenced by clear(), operator=(), and ~GTestCase().

const bool & GTestCase::has_passed ( void  ) const
inline

Return whether the test passed.

Returns
True if test has passed, false otherwise.

This method returns true if the test has passed, false otherwise.

Definition at line 225 of file GTestCase.hpp.

References m_has_passed.

Referenced by has_passed(), GTestSuite::run(), GTestSuite::test_assert(), GTestSuite::test_value(), and GTestSuites::write().

void GTestCase::has_passed ( const bool &  has_passed)
inline

Set if test passed.

Parameters
[in]has_passedTest passed (true or false)

Definition at line 237 of file GTestCase.hpp.

References has_passed(), and m_has_passed.

void GTestCase::init_members ( void  )
protected

Initialise class members.

Definition at line 224 of file GTestCase.cpp.

References ERROR_TEST, m_duration, m_has_passed, m_kind, m_message, m_name, and m_type.

Referenced by clear(), GTestCase(), and operator=().

const GTestCase::ErrorKind & GTestCase::kind ( void  ) const
inline

Return kind of test case.

Returns
Test case kind (FAIL_TEST or ERROR_TEST).

Returns whether this test case is for failure testing (FAIL_TEST) or error testing (ERROR_TEST).

Definition at line 195 of file GTestCase.hpp.

References m_kind.

Referenced by GTestCase(), kind(), and GTestSuites::write().

void GTestCase::kind ( const ErrorKind kind)
inline

Set kind of test case.

Parameters
[in]kindKind of test case (FAIL_TEST or ERROR_TEST)

Specifies whether this test case is for failure testing (FAIL_TEST) or error testing (ERROR_TEST).

Definition at line 210 of file GTestCase.hpp.

References kind(), and m_kind.

const std::string & GTestCase::message ( void  ) const
inline

Return test case message.

Returns
Test case message.

Definition at line 142 of file GTestCase.hpp.

References m_message.

Referenced by message(), GTestSuite::run(), GTestSuite::test_assert(), GTestSuite::test_value(), and GTestSuites::write().

void GTestCase::message ( const std::string &  message)
inline

Set test case message.

Parameters
[in]messageTest case message.

Definition at line 154 of file GTestCase.hpp.

References m_message, and message().

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

Return test case name.

Returns
Test case name.

Definition at line 117 of file GTestCase.hpp.

References m_name.

Referenced by GTestCase(), name(), and GTestSuites::write().

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

Set test case name.

Parameters
[in]nameTest case name.

Definition at line 129 of file GTestCase.hpp.

References m_name, and name().

GTestCase & GTestCase::operator= ( const GTestCase test)

Assignment operator.

Parameters
[in]testTest case.
Returns
Test case.

Definition at line 126 of file GTestCase.cpp.

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

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

Print test case result.

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

Returns either ".", "F" or "E", dependent on the test result.

Implements GBase.

Definition at line 189 of file GTestCase.cpp.

References ERROR_TEST, m_has_passed, m_kind, and SILENT.

Referenced by GTestSuite::run(), GTestSuite::test_assert(), and GTestSuite::test_value().

const std::string & GTestCase::type ( void  ) const
inline

Return test case type.

Returns
Type of test case.

Definition at line 167 of file GTestCase.hpp.

References m_type.

Referenced by GTestSuite::run(), type(), and GTestSuites::write().

void GTestCase::type ( const std::string &  type)
inline

Set type of test case.

Parameters
[in]typeType of test case.

Definition at line 179 of file GTestCase.hpp.

References m_type, and type().

Member Data Documentation

double GTestCase::m_duration
protected

Test duration.

Definition at line 95 of file GTestCase.hpp.

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

bool GTestCase::m_has_passed
protected

Boolean to check test success.

Definition at line 93 of file GTestCase.hpp.

Referenced by copy_members(), has_passed(), init_members(), and print().

ErrorKind GTestCase::m_kind
protected

Kind of test case (failure or error test)

Definition at line 94 of file GTestCase.hpp.

Referenced by copy_members(), GTestCase(), init_members(), kind(), and print().

std::string GTestCase::m_message
protected

Test message.

Definition at line 91 of file GTestCase.hpp.

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

std::string GTestCase::m_name
protected

Test name.

Definition at line 90 of file GTestCase.hpp.

Referenced by copy_members(), GTestCase(), init_members(), and name().

std::string GTestCase::m_type
protected

Test type.

Definition at line 92 of file GTestCase.hpp.

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


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