Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <e32test.h>
Link against: euser.lib

Class RTest

class RTest;

Description

Test console.

The class creates a console window to which test results can be logged through the various overloads of the operator().

Members

Defined in RTest:


Construction and destruction


RTest(const TDesC &,TInt,const TText *)

IMPORT_C RTest(const TDesC &aTitle, TInt aThrowaway, const TText *anOtherThrowaway);

Description

Constructor.

Parameters

const TDesC16 &aTitle

A title describing this use of RTest. This is also referred to as the console title.

TInt aThrowaway

Not used.

const TText *anOtherThrowaway

Not used.


RTest(const TDesC &,TInt)

IMPORT_C RTest(const TDesC &aTitle, TInt aThrowaway);

Description

Constructor.

Parameters

const TDesC16 &aTitle

A title describing this use of RTest. This is also referred to as the console title.

TInt aThrowaway

Not used.


RTest(const TDesC &)

IMPORT_C RTest(const TDesC &aTitle);

Description

Constructor.

Parameters

const TDesC16 &aTitle

A title describing this use of RTest. This is also referred to as the console title.

[Top]


Member functions


Close()

IMPORT_C void Close();

Description

Closes the console and frees any resources acquired.


Title()

IMPORT_C void Title();

Description

Prints out the console title and version number.

The format of the text is:

RTEST TITLE: XXX YYY
Epoc/32 YYY

where XXX is the console title, and YYY is the version number, formatted as described by TVersion::Name()const.

See also:


Start(const TDesC &)

IMPORT_C void Start(const TDesC &aHeading);

Description

Marks the start of a set of tests.

Note that sets of tests can be nested.

A call to this function must be matched by a call to RTest::End() to mark the end of this set of tests.

Parameters

const TDesC16 &aHeading

A heading describing the set of tests; this is printed at the console.

See also:


Next(const TDesC &)

IMPORT_C void Next(const TDesC &aHeading);

Description

Marks the start of the next test.

Parameters

const TDesC16 &aHeading

A heading describing the test; this is printed at the console. This function is also called by RTest::Start(const TDesC &), which passes the text that describes the set of tests.

See also:


End()

IMPORT_C void End();

Description

Ends the current set of tests.

If this set of tests is not nested within another set, then a message reporting success is written to the console.

Panic codes

USER

84 if there was no matching call to RTest::Start(), i.e. more calls to End() have been made than calls to Start().

See also:


operator()(TInt,TInt,const TText *)

IMPORT_C void operator()(TInt aResult, TInt aLineNum, const TText *aFileName);

Description

Checks the result of a condition and, if this is false, prints a failure message at the console and raises a panic.

Before checking the condition passed in, the operator increments a check number. This is a value that is set to zero at the start of a test and is incremented by this operator (and by all variants of it). It identifies the check being made within the current test. This value is printed on a failure message.

Typically, the operator is called, passing a test condition, for example:

RTest test(... heading text...,line number... file name)
TInt r;
...some operation to be tested that returns a value in r...
test(r==KErrNone);

The failure message has the format:

: FAIL : XXX failed check N in FFF at line Number: M
RTEST: Checkpoint-fail

where XXX is the console title, N is the check number, FFF is the filename, and M is the line number passed in.

Parameters

TInt aResult

The condition being tested. This is interpreted as a true or false value.

TInt aLineNum

A line number that is printed in the failure message if the condition being tested is false.

const TText *aFileName

A file name that is printed in the failure message if the condition being tested is false.

Panic codes

USER

84 if the condition being tested is false.

See also:


operator()(TInt,TInt)

IMPORT_C void operator()(TInt aResult, TInt aLineNum);

Description

Checks the result of a condition and, if this is false, prints a failure message at the console and raises a panic.

Before checking the condition passed in, the operator increments a check number. This is a value that is set to zero at the start of a test and is incremented by this operator (and by all variants of it). It identifies the check being made within the current test. This value is printed on the failure message.

Typically, the operator is called, passing a test condition, for example:

RTest test(... heading text...,line number)
TInt r;
...some operation to be tested that returns a value in r...
test(r==KErrNone);

The failure message has the format:

: FAIL : XXX failed check N at line Number: M
RTEST: Checkpoint-fail

where XXX is the console title, N is the check number, and M is the line number passed in.

Parameters

TInt aResult

The condition being tested. This is interpreted as a true or false value.

TInt aLineNum

A line number that is printed in the failure message if the condition being tested is false.

Panic codes

USER

84 if the condition being tested is false.

See also:


operator()(TInt)

IMPORT_C void operator()(TInt aResult);

Description

Checks the result of a condition and, if this is false, prints a failure message at the console and raises a panic.

Before checking the condition passed in, the operator increments a check number. This is a value that is set to zero at the start of a test and is incremented by this operator (and by all variants of it). It identifies the check being made within the current test. This value is printed on the failure message.

Typically, the operator is called, passing a test condition, for example:

RTest test(... heading text...)
TInt r;
...some operation to be tested that returns a value in r...
test(r==KErrNone);

The failure message has the format:

: FAIL : XXX failed check N
RTEST: Checkpoint-fail

where XXX is the console title, and N is the check number.

Parameters

TInt aResult

The condition being tested. This is interpreted as a true or false value.

Panic codes

USER

84 if the condition being tested is false.

See also:


Panic(TInt,TRefByValue< const TDesC >,...)

IMPORT_C void Panic(TInt anError, TRefByValue< const TDesC > aFmt,...);

Description

Prints an error message and an error code, and raises a USER 84 panic.

Parameters

TInt anError

The error code.

TRefByValue< const TDesC16 > aFmt

A format list.

...


Panic(TRefByValue< const TDesC >,...)

IMPORT_C void Panic(TRefByValue< const TDesC > aFmt,...);

Description

Prints an error message, and raises a USER 84 panic.

Parameters

TRefByValue< const TDesC16 > aFmt

A format list.

...


Printf(TRefByValue< const TDesC >,...)

IMPORT_C void Printf(TRefByValue< const TDesC > aFmt,...);

Description

Prints text to the console.

If the logging flag is set, the string is also written to the debug output as represented by an RDebug object.

Parameters

TRefByValue< const TDesC16 > aFmt

A format list.

...

See also:


Getch()

IMPORT_C TKeyCode Getch();

Description

Gets an input key stroke.

Return value

TKeyCode

The input key code.


String(TInt,const TText8 *,const TText16 *)

static inline const TAny* String(TInt aSel, const TText8 *aBuf1, const TText16 *aBuf2);

Description

Utility function that returns a pointer to the specified TText8* argument or the TText16* argument depending on the value of the aSel argument.

Parameters

TInt aSel

An integer containing the size of a TText8 type or TText16 type.

const TText8 *aBuf1

A pointer to 8-bit text.

const TText16 *aBuf2

A pointer to 16-bit text.

Return value

const TAny *

A pointer to aBuf1, if the value of aSel is the size of a TText8 type, otherwise a pointer to aBuf2.


Console()const

inline CConsoleBase* Console() const;

Description

Gets the console.

Return value

CConsoleBase *

A pointer to the console object.


SetConsole(CConsoleBase *)

inline void SetConsole(CConsoleBase *aConsole);

Description

Sets the console.

Parameters

CConsoleBase *aConsole

A pointer to the console object to be used.


Logged()const

inline TBool Logged() const;

Description

Tests whether the logging flag is set.

If the logging flag is set, console output is also written to the debug output as represented by a RDebug object.

Return value

TBool

True, if the logging flag is set, false otherwise.


SetLogged(TBool)

inline void SetLogged(TBool aToLog);

Description

Sets the logging flag.

If the logging flag is set, console output is also written to the debug output as represented by a RDebug object.

Parameters

TBool aToLog

ETrue, if the logging flag is to be set, EFalse, otherwise.


HandleError(TInt,TInt,const TText *)

inline void HandleError(TInt aError, TInt aLine, const TText *aFileName);

Description

Prints a failure message, including an error code at the console and raises a panic.

Parameters

TInt aError

The error code to be printed in the failure massage.

TInt aLine

const TText *aFileName

A file name that is printed in the failure message.

Panic codes

USER

84 Always.


HandleNull(TInt,const TText *)

inline void HandleNull(TInt aLine, const TText *aFileName);

Description

Prints a failure message indicating null was encountered, at the console and raises a panic.

Parameters

TInt aLine

const TText *aFileName

A file name that is printed in the failure message.

Panic codes

USER

84 Always.


HandleNotEqual(TInt,TInt,TInt,const TText *)

inline void HandleNotEqual(TInt aExpected, TInt aActual, TInt aLine, const TText *aFileName);

Description

Prints a failure message indicating that two value (also printed) where not equal, at the console and raises a panic.

Parameters

TInt aExpected

The value that is to be printed as expected.

TInt aActual

The value that is to be printed as being actually received.

TInt aLine

const TText *aFileName

A file name that is printed in the failure message.

Panic codes

USER

84 Always.


HandleFailedCompare(TInt,const TText *,TInt,TInt,const TText *)

inline void HandleFailedCompare(TInt aLeft, const TText *aComp, TInt aRight, TInt aLine, const TText *aFileName);

Description

Prints a failure message indicating that a comparison between two values (also printed) resulted in EFalse, at the console and raises a panic.

Parameters

TInt aLeft

The left value of the comparison.

const TText *aComp

A string representing the comparison operator.

TInt aRight

The right value of the comparison.

TInt aLine

const TText *aFileName

A file name that is printed in the failure message.

Panic codes

USER

84 Always.