Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
jm::Test Class Referenceabstract

This base class represents a test object. It is used to implement unit tests for any code. Typically a set of tests is collected in one derived test class. More...

Inheritance diagram for jm::Test:
jm::Object

Public Member Functions

 Test ()=default
 Constructor.
 
 ~Test ()=default
 Destructor.
 
const Stringname () const
 Returns the name of the test.
 
void setName (const String &name)
 Set the name of the text.
 
virtual void doTest ()=0
 This is the main test method, which must be implemented by every derived test class.
 
void testUnexpectedException (const String &failmessage) const
 This method shall be called in the catch clause of an jm::Exception.
 
- Public Member Functions inherited from jm::Object
 Object () noexcept
 Constructor.
 
virtual ~Object () noexcept
 Destructor.
 
void release () noexcept
 Decreases the reference counter and releases the object immediately when the reference counter becomes 0.
 
Objectretain () noexcept
 Increases the reference counter of this object by 1.
 
Objectautorelease () noexcept
 Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object.
 
int32 referenceCount () const noexcept
 Returns the value of the reference counter.
 
virtual bool equals (const Object *other) const
 Comparison of objects.
 
virtual String displayName () const
 Returns the display name of the object intended to present to a user.
 
virtual void printDiffInfo (DiffOperation operation, Object *other) const
 Output method for outputting the diff results for the diff algorithm.
 
void setHighBit (bool status) noexcept
 
bool highBit () const noexcept
 

Protected Member Functions

void setErrorCode (const String &error)
 Set the error message of this test.
 
const StringerrorCode () const
 Returns the (last) error message.
 
void testFail (const String &message) const
 Call this method, if you made a test by yourself and this test failed.
 
void testEquals (const double actual, const double expected, const String &failmessage) const
 This method tests, if double actual is equal to expected under consideration of RESABS.
 
void testEquals (int64 actual, int64 expected, const String &failmessage) const
 This method tests, if Integer actual is equal to expected.
 
void testEquals (int64 actual, int32 expected, const String &failmessage) const
 This method tests, if Integer actual is equal to expected.
 
void testEquals (uint64 actual, uint64 expected, const String &failmessage) const
 This method tests, if uint64 actual is equal to expected.
 
void testEquals (void *actual, void *expected, const String &failmessage) const
 This method tests, if void* actual is equal to expected.
 
void testEquals (uint64 actual, int32 expected, const String &failmessage) const
 This method tests, if uint64 actual is equal to expected.
 
void testEquals (uint64 actual, uint32 expected, const String &failmessage) const
 This method tests, if uint64 actual is equal to expected.
 
void testEquals (int32 actual, int32 expected, const String &failmessage) const
 This method tests, if int32 actual is equal to expected.
 
void testEquals (uint32 actual, uint32 expected, const String &failmessage) const
 This method tests, if uint32 actual is equal to expected.
 
void testEquals (uint32 actual, int32 expected, const String &failmessage) const
 This method tests, if uint32 actual is equal to expected.
 
void testEquals (int32 actual, uint32 expected, const String &failmessage) const
 This method tests, if int32 actual is equal to expected.
 
void testEquals (const String &actual, const String &expected, const String &failmessage) const
 This method tests, if String actual is equal to expected.
 
void testEqualsIgnoreCase (const String &actual, const String &expected, const String &failmessage) const
 This method tests, if String actual is equal to expected ignoring cases.
 
void testNull (const void *actual, const String &failmessage) const
 This method tests, if actual is NULL.
 
void testNotNull (const void *actual, const String &failmessage) const
 This method tests, if actual is not NULL.
 
void testTrue (bool actual, const String &failmessage) const
 This method tests, if actual is true.
 
void testFalse (bool actual, const String &failmessage) const
 This method tests, if actual is false.
 

Detailed Description

This base class represents a test object. It is used to implement unit tests for any code. Typically a set of tests is collected in one derived test class.

Constructor & Destructor Documentation

◆ Test()

jm::Test::Test ( )
default

Constructor.

◆ ~Test()

jm::Test::~Test ( )
default

Destructor.

Member Function Documentation

◆ doTest()

virtual void jm::Test::doTest ( )
pure virtual

This is the main test method, which must be implemented by every derived test class.

◆ errorCode()

const String & jm::Test::errorCode ( ) const
protected

Returns the (last) error message.

◆ name()

const String & jm::Test::name ( ) const

Returns the name of the test.

◆ setErrorCode()

void jm::Test::setErrorCode ( const String error)
protected

Set the error message of this test.

Parameters
errorThe error message.

◆ setName()

void jm::Test::setName ( const String name)

Set the name of the text.

Parameters
nameThe name.

◆ testEquals() [1/12]

void jm::Test::testEquals ( const double  actual,
const double  expected,
const String failmessage 
) const
protected

This method tests, if double actual is equal to expected under consideration of RESABS.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [2/12]

void jm::Test::testEquals ( const String actual,
const String expected,
const String failmessage 
) const
protected

This method tests, if String actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [3/12]

void jm::Test::testEquals ( int32  actual,
int32  expected,
const String failmessage 
) const
protected

This method tests, if int32 actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [4/12]

void jm::Test::testEquals ( int32  actual,
uint32  expected,
const String failmessage 
) const
protected

This method tests, if int32 actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [5/12]

void jm::Test::testEquals ( int64  actual,
int32  expected,
const String failmessage 
) const
protected

This method tests, if Integer actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [6/12]

void jm::Test::testEquals ( int64  actual,
int64  expected,
const String failmessage 
) const
protected

This method tests, if Integer actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [7/12]

void jm::Test::testEquals ( uint32  actual,
int32  expected,
const String failmessage 
) const
protected

This method tests, if uint32 actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [8/12]

void jm::Test::testEquals ( uint32  actual,
uint32  expected,
const String failmessage 
) const
protected

This method tests, if uint32 actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [9/12]

void jm::Test::testEquals ( uint64  actual,
int32  expected,
const String failmessage 
) const
protected

This method tests, if uint64 actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [10/12]

void jm::Test::testEquals ( uint64  actual,
uint32  expected,
const String failmessage 
) const
protected

This method tests, if uint64 actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [11/12]

void jm::Test::testEquals ( uint64  actual,
uint64  expected,
const String failmessage 
) const
protected

This method tests, if uint64 actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEquals() [12/12]

void jm::Test::testEquals ( void *  actual,
void *  expected,
const String failmessage 
) const
protected

This method tests, if void* actual is equal to expected.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testEqualsIgnoreCase()

void jm::Test::testEqualsIgnoreCase ( const String actual,
const String expected,
const String failmessage 
) const
protected

This method tests, if String actual is equal to expected ignoring cases.

Parameters
actualThe test value
expectedThe expected value
failmessageThe log message in case of failed test.

◆ testFail()

void jm::Test::testFail ( const String message) const
protected

Call this method, if you made a test by yourself and this test failed.

◆ testFalse()

void jm::Test::testFalse ( bool  actual,
const String failmessage 
) const
protected

This method tests, if actual is false.

Parameters
actualThe test value
failmessageThe log message in case of failed test.

◆ testNotNull()

void jm::Test::testNotNull ( const void *  actual,
const String failmessage 
) const
protected

This method tests, if actual is not NULL.

Parameters
actualThe test value
failmessageThe log message in case of failed test.

◆ testNull()

void jm::Test::testNull ( const void *  actual,
const String failmessage 
) const
protected

This method tests, if actual is NULL.

Parameters
actualThe test value
failmessageThe log message in case of failed test.

◆ testTrue()

void jm::Test::testTrue ( bool  actual,
const String failmessage 
) const
protected

This method tests, if actual is true.

Parameters
actualThe test value
failmessageThe log message in case of failed test.

◆ testUnexpectedException()

void jm::Test::testUnexpectedException ( const String failmessage) const

This method shall be called in the catch clause of an jm::Exception.