#include <iostream>
#include <tqobject.h>
#include <tqstringlist.h>
#include <tqasciidict.h>
#include <kdelibs_export.h>
Go to the source code of this file.
Classes | |
class | KUnitTest::TestResults |
class | KUnitTest::Tester |
class | KUnitTest::SlotTester |
Namespaces | |
namespace | KUnitTest |
Defines | |
#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) |
Typedefs | |
typedef TQAsciiDict< TestResults > | KUnitTest::TestResultsListType |
typedef TQAsciiDictIterator < TestResults > | KUnitTest::TestResultsListIteratorType |
Functions | |
KUNITTEST_EXPORT TQTextStream & | operator<< (TQTextStream &str, const TQRect &r) |
KUNITTEST_EXPORT TQTextStream & | operator<< (TQTextStream &str, const TQPoint &r) |
KUNITTEST_EXPORT TQTextStream & | operator<< (TQTextStream &str, const TQSize &r) |
Detailed Description
Defines macros for unit testing as well as some test classes.
Definition in file tester.h.
Define Documentation
#define CHECK | ( | x, | |
y | |||
) | check( __FILE__, __LINE__, #x, x, y, false ) |
#define CHECK_EXCEPTION | ( | exceptionCatch, | |
expression | |||
) |
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.
for source-compat with qttestlib: use COMPARE(x,y) if you plan to port to qttestlib later.
#define SKIP | ( | x | ) | skip( __FILE__, __LINE__, TQString::fromLatin1(#x)) |
#define SKIP_EXCEPTION | ( | exceptionCatch, | |
expression | |||
) |
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.
#define XFAIL | ( | x, | |
y | |||
) | check( __FILE__, __LINE__, #x, x, y, true ) |
#define XFAIL_EXCEPTION | ( | exceptionCatch, | |
expression | |||
) |
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.