#include <iostream>
#include <tqobject.h>
#include <tqstringlist.h>
#include <tqasciidict.h>
#include <tdelibs_export.h>
Go to the source code of this file.
|
#define | CHECK(x, y) check( __FILE__, __LINE__, #x, x, y, false ) |
|
#define | COMPARE CHECK |
|
#define | VERIFY(x) CHECK( x, true ) |
|
#define | XFAIL(x, y) check( __FILE__, __LINE__, #x, x, y, true ) |
|
#define | SKIP(x) skip( __FILE__, __LINE__, TQString::fromLatin1(#x)) |
|
#define | CHECK_EXCEPTION(exceptionCatch, expression) |
|
#define | XFAIL_EXCEPTION(exceptionCatch, expression) |
|
#define | SKIP_EXCEPTION(exceptionCatch, expression) |
|
|
TDEUNITTEST_EXPORT TQTextStream & | operator<< (TQTextStream &str, const TQRect &r) |
|
TDEUNITTEST_EXPORT TQTextStream & | operator<< (TQTextStream &str, const TQPoint &r) |
|
TDEUNITTEST_EXPORT TQTextStream & | operator<< (TQTextStream &str, const TQSize &r) |
|
Defines macros for unit testing as well as some test classes.
Definition in file tester.h.
◆ CHECK
#define CHECK |
( |
|
x, |
|
|
|
y |
|
) |
| check( __FILE__, __LINE__, #x, x, y, false ) |
Use this macro to perform an equality check. For example
CHECK( numberOfErrors(), 0 );
Definition at line 339 of file tester.h.
◆ CHECK_EXCEPTION
#define CHECK_EXCEPTION |
( |
|
exceptionCatch, |
|
|
|
expression |
|
) |
| |
Value: try \
{ \
expression; \
} \
catch(exceptionCatch) \
{ \
setExceptionRaised(true); \
} \
if(exceptionRaised()) \
{ \
success(TQString(__FILE__) + "[" + TQString::number(__LINE__) + "]: passed " + #expression); \
} \
else \
{ \
failure(TQString(__FILE__) + "[" + TQString::number(__LINE__) + TQString("]: failed to throw " \
"an exception on: ") + #expression); \
} \
setExceptionRaised(false);
A macro testing that expression
throws an exception that is catched with exceptionCatch
. Use it to test that an expression, such as a function call, throws a certain exception.
- Note
- this macro assumes it's used in a function which is a sub-class of the Tester class.
Definition at line 371 of file tester.h.
◆ COMPARE
for source-compat with qttestlib: use COMPARE(x,y) if you plan to port to qttestlib later.
Definition at line 342 of file tester.h.
◆ SKIP
#define SKIP |
( |
|
x | ) |
skip( __FILE__, __LINE__, TQString::fromLatin1(#x)) |
Use this macro to indicate that a test is skipped.
SKIP(
"Test skipped because of lack of foo support.");
Definition at line 362 of file tester.h.
◆ SKIP_EXCEPTION
#define SKIP_EXCEPTION |
( |
|
exceptionCatch, |
|
|
|
expression |
|
) |
| |
Value: skip( __FILE__, __LINE__, TQString("Exception catch: ")\
.arg(TQString(#exceptionCatch)).arg(TQString(" Test expression: ")).arg(TQString(#expression)))
This macro is similar to SKIP, but is for exceptions instead. Skip testing expression
and the exceptionCatch
which is supposed to catch the exception, and register the test as being skipped.
Definition at line 419 of file tester.h.
◆ VERIFY
#define VERIFY |
( |
|
x | ) |
CHECK( x, true ) |
for source-compat with qttestlib: use VERIFY(x) if you plan to port to qttestlib later.
Definition at line 345 of file tester.h.
◆ XFAIL
#define XFAIL |
( |
|
x, |
|
|
|
y |
|
) |
| check( __FILE__, __LINE__, #x, x, y, true ) |
Use this macro to perform a check you expect to fail. For example
XFAIL( numberOfErrors(), 1 );
If the test fails, it will be counted as such, however it will also be registered separately.
Definition at line 355 of file tester.h.
◆ XFAIL_EXCEPTION
#define XFAIL_EXCEPTION |
( |
|
exceptionCatch, |
|
|
|
expression |
|
) |
| |
Value: try \
{ \
expression; \
} \
catch(exceptionCatch) \
{ \
setExceptionRaised(true); \
} \
if(exceptionRaised()) \
{ \
unexpectedSuccess(TQString(__FILE__) + "[" + TQString::number(__LINE__) + "]: unexpectedly threw an exception and passed: " + #expression); \
}\
else \
{ \
expectedFailure(TQString(__FILE__) + "[" + TQString::number(__LINE__) + TQString("]: failed to throw an exception on: ") + #expression); \
} \
setExceptionRaised(false);
This macro is similar to XFAIL, but is for exceptions instead. Flags expression
as being expected to fail to throw an exception that exceptionCatch
is supposed to catch.
Definition at line 395 of file tester.h.