class RTest |
Test console.
The class creates a console window to which test results can be logged through the various overloads of the operator().
Public Member Functions | |
---|---|
RTest (const TDesC &, TInt , const TText *) | |
RTest (const TDesC &, TInt ) | |
RTest (const TDesC &) | |
IMPORT_C void | Close () |
IMPORT_C TInt | CloseHandleAndWaitForDestruction ( RHandleBase &) |
CConsoleBase * | Console () |
IMPORT_C void | End () |
IMPORT_C TKeyCode | Getch () |
void | HandleError ( TInt , TInt , const TText *) |
void | HandleFailedCompare ( TInt , const TText *, TInt , TInt , const TText *) |
void | HandleNotEqual ( TInt , TInt , TInt , const TText *) |
void | HandleNull ( TInt , const TText *) |
void | HandleValue ( TInt , TInt , const TText *) |
TBool | Logged () |
IMPORT_C void | Next (const TDesC &) |
IMPORT_C void | Panic ( TInt , TRefByValue < const TDesC >, ...) |
IMPORT_C void | Panic ( TRefByValue < const TDesC >, ...) |
IMPORT_C void | Printf ( TRefByValue < const TDesC >, ...) |
void | SetConsole ( CConsoleBase *) |
void | SetLogged ( TBool ) |
IMPORT_C void | Start (const TDesC &) |
const TAny * | String ( TInt , const TText8 *, const TText16 *) |
IMPORT_C void | Title () |
IMPORT_C void | operator() ( TInt , TInt , const TText *) |
IMPORT_C void | operator() ( TInt , TInt ) |
IMPORT_C void | operator() ( TInt ) |
Protected Member Functions | |
---|---|
void | CheckConsoleCreated () |
void | DisplayLevel () |
void | Pop () |
void | Push () |
Private Attributes | |
---|---|
TText | iBuf |
TInt | iCheck |
CConsoleBase * | iConsole |
TInt | iLevel |
TBool | iLogging |
TInt | iStack |
TInt | iTest |
TBuf < 0x40 > | iTitle |
IMPORT_C | RTest | ( | const TDesC & | aTitle, |
TInt | aThrowaway, | |||
const TText * | anOtherThrowaway | |||
) |
Constructor.
IMPORT_C | RTest | ( | const TDesC & | aTitle | ) |
Constructor.
const TDesC & aTitle | A title describing this use of RTest. This is also referred to as the console title. |
IMPORT_C TInt | CloseHandleAndWaitForDestruction | ( | RHandleBase & | aH | ) | [static] |
RHandleBase & aH |
IMPORT_C void | End | ( | ) |
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.
void | HandleError | ( | TInt | aError, |
TInt | aLine, | |||
const TText * | aFileName | |||
) | [inline] |
Prints a failure message, including an error code at the console and raises a panic.
void | HandleFailedCompare | ( | TInt | aLeft, |
const TText * | aComp, | |||
TInt | aRight, | |||
TInt | aLine, | |||
const TText * | aFileName | |||
) | [inline] |
Prints a failure message indicating that a comparison between two values (also printed) resulted in EFalse, at the console and raises a panic.
void | HandleNotEqual | ( | TInt | aExpected, |
TInt | aActual, | |||
TInt | aLine, | |||
const TText * | aFileName | |||
) | [inline] |
Prints a failure message indicating that two value (also printed) where not equal, at the console and raises a panic.
void | HandleNull | ( | TInt | aLine, |
const TText * | aFileName | |||
) | [inline] |
Prints a failure message indicating null was encountered, at the console and raises a panic.
void | HandleValue | ( | TInt | aValue, |
TInt | aLine, | |||
const TText * | aFileName | |||
) | [inline] |
Prints a failure message indicating that aValue was not an expected value, at the console and raises a panic.
TBool | Logged | ( | ) | const [inline] |
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.
IMPORT_C void | Next | ( | const TDesC & | aHeading | ) |
Marks the start of the next test.
const TDesC & aHeading | A heading describing the test; this is printed at the console. This function is also called by Start(), which passes the text that describes the set of tests. |
IMPORT_C void | Panic | ( | TInt | anError, |
TRefByValue < const TDesC > | aFmt, | |||
... | ||||
) |
Prints an error message and an error code, and raises a USER 84 panic.
TInt anError | The error code. |
TRefByValue < const TDesC > aFmt | A format list. |
... |
IMPORT_C void | Panic | ( | TRefByValue < const TDesC > | aFmt, |
... | ||||
) |
Prints an error message, and raises a USER 84 panic.
TRefByValue < const TDesC > aFmt | A format list. |
... |
IMPORT_C void | Printf | ( | TRefByValue < const TDesC > | aFmt, |
... | ||||
) |
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.
RTest::SetLogged() Rtest::Logged() RDebug
TRefByValue < const TDesC > aFmt | A format list. |
... |
void | SetConsole | ( | CConsoleBase * | aConsole | ) | [inline] |
Sets the console.
CConsoleBase * aConsole | A pointer to the console object to be used. |
void | SetLogged | ( | TBool | aToLog | ) | [inline] |
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.
TBool aToLog | ETrue, if the logging flag is to be set, EFalse, otherwise. |
IMPORT_C void | Start | ( | const TDesC & | aHeading | ) |
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.
const TDesC & aHeading | A heading describing the set of tests; this is printed at the console. |
const TAny * | String | ( | TInt | aSel, |
const TText8 * | aBuf1, | |||
const TText16 * | aBuf2 | |||
) | [static, inline] |
Utility function that returns a pointer to the specified TText8* argument or the TText16* argument depending on the value of the aSel argument.
IMPORT_C void | Title | ( | ) |
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() .
IMPORT_C void | operator() | ( | TInt | aResult, |
TInt | aLineNum, | |||
const TText * | aFileName | |||
) |
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.
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. |
IMPORT_C void | operator() | ( | TInt | aResult, |
TInt | aLineNum | |||
) |
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.
IMPORT_C void | operator() | ( | TInt | aResult | ) |
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.
TInt aResult | The condition being tested. This is interpreted as a true or false value. |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.