• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeunittest
 

tdeunittest

  • tdeunittest
Classes | Namespaces | Macros | Typedefs | Functions
tester.h File Reference
#include <iostream>
#include <tqobject.h>
#include <tqstringlist.h>
#include <tqasciidict.h>
#include <tdelibs_export.h>

Go to the source code of this file.

Classes

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

Namespaces

namespace  KUnitTest
 

Macros

#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

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)
 

Detailed Description

Defines macros for unit testing as well as some test classes.

Definition in file tester.h.

Macro Definition Documentation

◆ 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 );
CHECK
#define CHECK(x, y)
Definition: tester.h:339

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

#define COMPARE   CHECK

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.");
SKIP
#define SKIP(x)
Definition: tester.h:362

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 );
XFAIL
#define XFAIL(x, y)
Definition: tester.h:355

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.

Function Documentation

◆ operator<<() [1/3]

TDEUNITTEST_EXPORT TQTextStream & operator<< ( TQTextStream &  str,
const TQPoint &  r 
)

Definition at line 88 of file tester.cpp.

◆ operator<<() [2/3]

TDEUNITTEST_EXPORT TQTextStream & operator<< ( TQTextStream &  str,
const TQRect &  r 
)

Definition at line 83 of file tester.cpp.

◆ operator<<() [3/3]

TDEUNITTEST_EXPORT TQTextStream & operator<< ( TQTextStream &  str,
const TQSize &  r 
)

Definition at line 93 of file tester.cpp.

tdeunittest

Skip menu "tdeunittest"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

tdeunittest

Skip menu "tdeunittest"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeunittest by doxygen 1.9.4
This website is maintained by Timothy Pearson.