sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* @file
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*
|
sl@0
|
18 |
*/
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
|
sl@0
|
22 |
#ifndef __TEF_LOG_EXTENSIONS__
|
sl@0
|
23 |
#define __TEF_LOG_EXTENSIONS__
|
sl@0
|
24 |
|
sl@0
|
25 |
#include <test/tefunit.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
/*
|
sl@0
|
28 |
This file contains extensions to the TEF macros used for logging, defined in
|
sl@0
|
29 |
tefunit.h.
|
sl@0
|
30 |
*/
|
sl@0
|
31 |
|
sl@0
|
32 |
/*
|
sl@0
|
33 |
Wrapper to check for an error, then print it and leave with it if not KErrNone.
|
sl@0
|
34 |
do ... while (0) ensures the macro can be treated like a single statement. A
|
sl@0
|
35 |
macro is used to get the line number information.
|
sl@0
|
36 |
Note that p1 will be evaluated once and only once.
|
sl@0
|
37 |
*/
|
sl@0
|
38 |
#define PRINT_ON_ERROR2_L(test, p1, p2) \
|
sl@0
|
39 |
do \
|
sl@0
|
40 |
{ \
|
sl@0
|
41 |
TInt result = (test); \
|
sl@0
|
42 |
if (result != KErrNone) \
|
sl@0
|
43 |
{ \
|
sl@0
|
44 |
Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)); \
|
sl@0
|
45 |
User::Leave(result); \
|
sl@0
|
46 |
} \
|
sl@0
|
47 |
} \
|
sl@0
|
48 |
while (0)
|
sl@0
|
49 |
|
sl@0
|
50 |
#define PRINT_ON_ERROR3_L(test, p1, p2, p3) \
|
sl@0
|
51 |
do \
|
sl@0
|
52 |
{ \
|
sl@0
|
53 |
TInt result = (test); \
|
sl@0
|
54 |
if (result != KErrNone) \
|
sl@0
|
55 |
{ \
|
sl@0
|
56 |
Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)); \
|
sl@0
|
57 |
User::Leave(result); \
|
sl@0
|
58 |
} \
|
sl@0
|
59 |
} \
|
sl@0
|
60 |
while (0)
|
sl@0
|
61 |
|
sl@0
|
62 |
/*
|
sl@0
|
63 |
Modified version of ASSERT_EQUALS() that will log the expression tested, the
|
sl@0
|
64 |
expected result and the actual one.
|
sl@0
|
65 |
*/
|
sl@0
|
66 |
#define ASSERT_CONDITION(c) _LIT(KExpression, c);
|
sl@0
|
67 |
|
sl@0
|
68 |
#define ASSERT_EQUALS_X(aExpression, aExpected) \
|
sl@0
|
69 |
do \
|
sl@0
|
70 |
{ \
|
sl@0
|
71 |
TInt result = (TInt)(aExpression); \
|
sl@0
|
72 |
TInt expected = (TInt)(aExpected); \
|
sl@0
|
73 |
if (result != expected) \
|
sl@0
|
74 |
{ \
|
sl@0
|
75 |
ASSERT_CONDITION(#aExpression); \
|
sl@0
|
76 |
Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, not %d"), &KExpression(), result, expected ); \
|
sl@0
|
77 |
User::Leave(KErrTEFUnitFail); \
|
sl@0
|
78 |
} \
|
sl@0
|
79 |
} \
|
sl@0
|
80 |
while (0)
|
sl@0
|
81 |
|
sl@0
|
82 |
#define ASSERT_NOT_EQUALS_X(aExpression, aUnexpected) \
|
sl@0
|
83 |
do \
|
sl@0
|
84 |
{ \
|
sl@0
|
85 |
TInt result = (TInt)(aExpression); \
|
sl@0
|
86 |
TInt unexpected = (TInt)(aUnexpected); \
|
sl@0
|
87 |
if (result == unexpected) \
|
sl@0
|
88 |
{ \
|
sl@0
|
89 |
ASSERT_CONDITION(#aExpression); \
|
sl@0
|
90 |
Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, unexpectedly"), &KExpression(), result ); \
|
sl@0
|
91 |
User::Leave(KErrTEFUnitFail); \
|
sl@0
|
92 |
} \
|
sl@0
|
93 |
} \
|
sl@0
|
94 |
while (0)
|
sl@0
|
95 |
|
sl@0
|
96 |
#define ASSERT_TRUE_X(aExpression) \
|
sl@0
|
97 |
do \
|
sl@0
|
98 |
{ \
|
sl@0
|
99 |
TBool result = (TBool)(aExpression); \
|
sl@0
|
100 |
if (!result) \
|
sl@0
|
101 |
{ \
|
sl@0
|
102 |
ASSERT_CONDITION(#aExpression); \
|
sl@0
|
103 |
Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S false"), &KExpression() ); \
|
sl@0
|
104 |
User::Leave(KErrTEFUnitFail); \
|
sl@0
|
105 |
} \
|
sl@0
|
106 |
} \
|
sl@0
|
107 |
while (0)
|
sl@0
|
108 |
|
sl@0
|
109 |
#endif // __TEF_LOG_EXTENSIONS__
|
sl@0
|
110 |
|