KUnitTest
tester.h File Reference
#include <iostream>
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QHash>
#include <QtCore/QTextStream>
#include "kunittest_export.h"
Go to the source code of this file.
Classes | |
class | KUnitTest::SlotTester |
class | KUnitTest::Tester |
class | KUnitTest::TestResults |
Namespaces | |
namespace | KUnitTest |
Defines | |
#define | CHECK(x, y) check( __FILE__, __LINE__, #x, x, y, false ) |
#define | CHECK_EXCEPTION(exceptionCatch, expression) |
#define | SKIP(x) skip( __FILE__, __LINE__, QLatin1String(#x)) |
#define | SKIP_EXCEPTION(exceptionCatch, expression) |
#define | VERIFY(cond) check( __FILE__, __LINE__, #cond, cond, true, false ) |
#define | XFAIL(x, y) check( __FILE__, __LINE__, #x, x, y, true ) |
#define | XFAIL_EXCEPTION(exceptionCatch, expression) |
Typedefs | |
typedef QHash< QByteArray, TestResults * > | KUnitTest::TestResultsList |
Functions | |
KUNITTEST_EXPORT QTextStream & | operator<< (QTextStream &str, const QSize &r) |
KUNITTEST_EXPORT QTextStream & | operator<< (QTextStream &str, const QPoint &r) |
KUNITTEST_EXPORT QTextStream & | operator<< (QTextStream &str, const QRect &r) |
Define Documentation
#define CHECK | ( | x, | |||
y | ) | check( __FILE__, __LINE__, #x, x, y, false ) |
#define CHECK_EXCEPTION | ( | exceptionCatch, | |||
expression | ) |
Value:
try \ { \ expression; \ } \ catch(exceptionCatch) \ { \ setExceptionRaised(true); \ } \ if(exceptionRaised()) \ { \ success(QString(__FILE__) + "[" + QString::number(__LINE__) + "]: passed " + #expression); \ } \ else \ { \ failure(QString(__FILE__) + "[" + QString::number(__LINE__) + QString("]: failed to throw " \ "an exception on: ") + #expression); \ } \ setExceptionRaised(false);
An macro testing that expression
throws an exception that is caught 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.
#define SKIP | ( | x | ) | skip( __FILE__, __LINE__, QLatin1String(#x)) |
#define SKIP_EXCEPTION | ( | exceptionCatch, | |||
expression | ) |
Value:
skip( __FILE__, __LINE__, QString("Exception catch: ")\ .arg(QString(#exceptionCatch)).arg(QString(" Test expression: ")).arg(QString(#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 VERIFY | ( | cond | ) | check( __FILE__, __LINE__, #cond, cond, true, false ) |
#define XFAIL | ( | x, | |||
y | ) | check( __FILE__, __LINE__, #x, x, y, true ) |
#define XFAIL_EXCEPTION | ( | exceptionCatch, | |||
expression | ) |
Value:
try \ { \ expression; \ } \ catch(exceptionCatch) \ { \ setExceptionRaised(true); \ } \ if(exceptionRaised()) \ { \ unexpectedSuccess(QString(__FILE__) + "[" + QString::number(__LINE__) + "]: unexpectedly threw an exception and passed: " + #expression); \ }\ else \ { \ expectedFailure(QString(__FILE__) + "[" + QString::number(__LINE__) + QString("]: 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.
Function Documentation
KUNITTEST_EXPORT QTextStream& operator<< | ( | QTextStream & | str, | |
const QSize & | r | |||
) |
Definition at line 112 of file tester.cpp.
KUNITTEST_EXPORT QTextStream& operator<< | ( | QTextStream & | str, | |
const QPoint & | r | |||
) |
Definition at line 107 of file tester.cpp.
KUNITTEST_EXPORT QTextStream& operator<< | ( | QTextStream & | str, | |
const QRect & | r | |||
) |
Definition at line 102 of file tester.cpp.