GammaLib
2.1.0.dev
|
Test class. More...
#include <GTestCase.hpp>
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... | |
GTestCase & | operator= (const GTestCase &test) |
Assignment operator. More... | |
void | clear (void) |
Clear test case. More... | |
GTestCase * | clone (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 ErrorKind & | kind (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... | |
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.
enum GTestCase::ErrorKind |
Enumerator | |
---|---|
FAIL_TEST | |
ERROR_TEST |
Definition at line 51 of file GTestCase.hpp.
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.
[in] | kind | Test kind (FAIL_TEST or ERROR_TEST) |
[in] | name | Test 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.
[in] | test | Test case. |
Definition at line 88 of file GTestCase.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 105 of file GTestCase.hpp.
|
virtual |
Clear test case.
Implements GBase.
Definition at line 156 of file GTestCase.cpp.
References free_members(), and init_members().
|
virtual |
Clone test case.
Implements GBase.
Definition at line 174 of file GTestCase.cpp.
References GTestCase().
|
protected |
Copy class members.
[in] | test | Test 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=().
|
inline |
Return test case duration.
Definition at line 250 of file GTestCase.hpp.
References m_duration.
Referenced by duration(), GTestSuite::run(), and GTestSuites::write().
|
inline |
Set test duration.
[in] | duration | Test duration. |
Definition at line 262 of file GTestCase.hpp.
References duration(), and m_duration.
|
protected |
Delete class members.
Definition at line 263 of file GTestCase.cpp.
Referenced by clear(), operator=(), and ~GTestCase().
|
inline |
Return whether the test passed.
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().
|
inline |
Set if test passed.
[in] | has_passed | Test passed (true or false) |
Definition at line 237 of file GTestCase.hpp.
References has_passed(), and m_has_passed.
|
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=().
|
inline |
Return kind of test case.
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().
|
inline |
Set kind of test case.
[in] | kind | Kind 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.
|
inline |
Return 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().
|
inline |
Set test case message.
[in] | message | Test case message. |
Definition at line 154 of file GTestCase.hpp.
|
inline |
Return test case name.
Definition at line 117 of file GTestCase.hpp.
References m_name.
Referenced by GTestCase(), name(), and GTestSuites::write().
|
inline |
Set test case name.
[in] | name | Test case name. |
Definition at line 129 of file GTestCase.hpp.
Assignment operator.
[in] | test | Test case. |
Definition at line 126 of file GTestCase.cpp.
References copy_members(), free_members(), and init_members().
Print test case result.
[in] | chatter | Chattiness (defaults to NORMAL). |
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().
|
inline |
Return test case type.
Definition at line 167 of file GTestCase.hpp.
References m_type.
Referenced by GTestSuite::run(), type(), and GTestSuites::write().
|
inline |
Set type of test case.
[in] | type | Type of test case. |
Definition at line 179 of file GTestCase.hpp.
|
protected |
Test duration.
Definition at line 95 of file GTestCase.hpp.
Referenced by copy_members(), duration(), and init_members().
|
protected |
Boolean to check test success.
Definition at line 93 of file GTestCase.hpp.
Referenced by copy_members(), has_passed(), init_members(), and print().
|
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().
|
protected |
Test message.
Definition at line 91 of file GTestCase.hpp.
Referenced by copy_members(), init_members(), and message().
|
protected |
Test name.
Definition at line 90 of file GTestCase.hpp.
Referenced by copy_members(), GTestCase(), init_members(), and name().
|
protected |
Test type.
Definition at line 92 of file GTestCase.hpp.
Referenced by copy_members(), init_members(), and type().