#include <test.h>
Definition at line 61 of file test.h.
Public Member Functions | |
unsigned int | failed () const |
const std::string & | name () const |
virtual void | run ()=0 |
unsigned int | succeeded () const |
Test (const std::string &name) | |
virtual | ~Test () |
Protected Member Functions | |
template<typename T, typename S> | |
void | _assertEqual (const T &x1, const S &x2, const char *expr1, const char *expr2, const char *file, unsigned int line) |
void | _assertEqualWithEpsilons (long double x1, long double x2, int prec, const char *expr1, const char *expr2, const char *exprPrec, const char *file, unsigned int line) |
void | _assertEqualWithEpsilons (double x1, double x2, int prec, const char *expr1, const char *expr2, const char *exprPrec, const char *file, unsigned int line) |
void | _assertEqualWithEpsilons (float x1, float x2, int prec, const char *expr1, const char *expr2, const char *exprPrec, const char *file, unsigned int line) |
void | _assertFalse (bool x, const char *expression, const char *file, unsigned int line) |
template<typename T, typename S> | |
void | _assertNotEqual (const T &x1, const S &x2, const char *expr1, const char *expr2, const char *file, unsigned int line) |
void | _assertNotNull (const void *x, const char *expression, const char *file, unsigned int line) |
void | _assertNull (const void *x, const char *expression, const char *file, unsigned int line) |
void | _assertTrue (bool x, const char *expression, const char *file, unsigned int line) |
std::ostream & | fail (const char *file, unsigned int line) |
void | success () |
KDAB::UnitTest::Test::Test | ( | const std::string & | name | ) |
void KDAB::UnitTest::Test::_assertEqual | ( | const T & | x1, | |
const S & | x2, | |||
const char * | expr1, | |||
const char * | expr2, | |||
const char * | file, | |||
unsigned int | line | |||
) | [protected] |
void KDAB::UnitTest::Test::_assertEqualWithEpsilons | ( | long double | x1, | |
long double | x2, | |||
int | prec, | |||
const char * | expr1, | |||
const char * | expr2, | |||
const char * | exprPrec, | |||
const char * | file, | |||
unsigned int | line | |||
) | [protected] |
Definition at line 61 of file test.cpp.
References fail(), and success().
00061 { 00062 if ( qAbs( x1/x2 - 1.0l ) <= prec * std::numeric_limits<long double>::epsilon() ) success(); 00063 else fail( file, line ) << x1 << " (" << expr1 << ") deviates from expected " 00064 << x2 << " (" << expr2 << ") by more than " 00065 << prec << " (" << exprP << ") epsilons." << std::endl; 00066 }
void KDAB::UnitTest::Test::_assertEqualWithEpsilons | ( | double | x1, | |
double | x2, | |||
int | prec, | |||
const char * | expr1, | |||
const char * | expr2, | |||
const char * | exprPrec, | |||
const char * | file, | |||
unsigned int | line | |||
) | [protected] |
Definition at line 54 of file test.cpp.
References fail(), and success().
00054 { 00055 if ( qAbs( x1/x2 - 1.0 ) <= prec * std::numeric_limits<double>::epsilon() ) success(); 00056 else fail( file, line ) << x1 << " (" << expr1 << ") deviates from expected " 00057 << x2 << " (" << expr2 << ") by more than " 00058 << prec << " (" << exprP << ") epsilons." << std::endl; 00059 }
void KDAB::UnitTest::Test::_assertEqualWithEpsilons | ( | float | x1, | |
float | x2, | |||
int | prec, | |||
const char * | expr1, | |||
const char * | expr2, | |||
const char * | exprPrec, | |||
const char * | file, | |||
unsigned int | line | |||
) | [protected] |
Definition at line 47 of file test.cpp.
References fail(), and success().
00047 { 00048 if ( qAbs( x1/x2 - 1.0f ) <= prec * std::numeric_limits<float>::epsilon() ) success(); 00049 else fail( file, line ) << x1 << " (" << expr1 << ") deviates from expected " 00050 << x2 << " (" << expr2 << ") by more than " 00051 << prec << " (" << exprP << ") epsilons." << std::endl; 00052 }
void KDAB::UnitTest::Test::_assertFalse | ( | bool | x, | |
const char * | expression, | |||
const char * | file, | |||
unsigned int | line | |||
) | [protected] |
void KDAB::UnitTest::Test::_assertNotEqual | ( | const T & | x1, | |
const S & | x2, | |||
const char * | expr1, | |||
const char * | expr2, | |||
const char * | file, | |||
unsigned int | line | |||
) | [protected] |
Definition at line 96 of file test.h.
References fail(), and success().
00096 { 00097 if ( x1 != x2 ) this->success(); 00098 else { 00099 this->fail( file, line ) << '"' << expr1 << "\" yielded " << x1 << "; expected something not equal to: " << x2 << "(\"" << expr2 << "\")" << std::endl; 00100 } 00101 }
void KDAB::UnitTest::Test::_assertNotNull | ( | const void * | x, | |
const char * | expression, | |||
const char * | file, | |||
unsigned int | line | |||
) | [protected] |
void KDAB::UnitTest::Test::_assertNull | ( | const void * | x, | |
const char * | expression, | |||
const char * | file, | |||
unsigned int | line | |||
) | [protected] |
void KDAB::UnitTest::Test::_assertTrue | ( | bool | x, | |
const char * | expression, | |||
const char * | file, | |||
unsigned int | line | |||
) | [protected] |
std::ostream & KDAB::UnitTest::Test::fail | ( | const char * | file, | |
unsigned int | line | |||
) | [protected] |
Definition at line 68 of file test.cpp.
Referenced by _assertEqual(), _assertEqualWithEpsilons(), _assertFalse(), _assertNotEqual(), _assertNotNull(), _assertNull(), and _assertTrue().
unsigned int KDAB::UnitTest::Test::failed | ( | ) | const |
const std::string& KDAB::UnitTest::Test::name | ( | ) | const |
virtual void KDAB::UnitTest::Test::run | ( | ) | [pure virtual] |
unsigned int KDAB::UnitTest::Test::succeeded | ( | ) | const |
void KDAB::UnitTest::Test::success | ( | ) | [protected] |
Definition at line 105 of file test.h.
Referenced by _assertEqual(), _assertEqualWithEpsilons(), _assertFalse(), _assertNotEqual(), _assertNotNull(), _assertNull(), and _assertTrue().