• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KUnitTest

tester.h File Reference

#include <iostream>
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QHash>
#include <QtCore/QTextStream>
#include "kunittest_export.h"

Include dependency graph for tester.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


Namespaces

namespace  KUnitTest

Classes

class  KUnitTest::SlotTester
class  KUnitTest::Tester
class  KUnitTest::TestResults

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 )

Use this macro to perform an equality check. For example

 CHECK( numberOfErrors(), 0 ); 

Definition at line 335 of file tester.h.

#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.

Definition at line 368 of file tester.h.

#define SKIP ( x   )     skip( __FILE__, __LINE__, QLatin1String(#x))

Use this macro to indicate that a test is skipped.

 SKIP("Test skipped because of lack of foo support."); 

Definition at line 359 of file tester.h.

#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.

Definition at line 416 of file tester.h.

#define VERIFY ( cond   )     check( __FILE__, __LINE__, #cond, cond, true, false )

Use this macro to check that a boolean condition is true. For example

 VERIFY( numberOfRows() > 0 ); 

Definition at line 342 of file tester.h.

#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 352 of file tester.h.

#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.

Definition at line 392 of file tester.h.


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.

KUnitTest

Skip menu "KUnitTest"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal