First public contribution.
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
22 #ifndef __TEF_LOG_EXTENSIONS__
23 #define __TEF_LOG_EXTENSIONS__
25 #include <test/tefunit.h>
28 This file contains extensions to the TEF macros used for logging, defined in
33 Wrapper to check for an error, then print it and leave with it if not KErrNone.
34 do ... while (0) ensures the macro can be treated like a single statement. A
35 macro is used to get the line number information.
36 Note that p1 will be evaluated once and only once.
38 #define PRINT_ON_ERROR2_L(test, p1, p2) \
41 TInt result = (test); \
42 if (result != KErrNone) \
44 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)); \
45 User::Leave(result); \
50 #define PRINT_ON_ERROR3_L(test, p1, p2, p3) \
53 TInt result = (test); \
54 if (result != KErrNone) \
56 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)); \
57 User::Leave(result); \
63 Modified version of ASSERT_EQUALS() that will log the expression tested, the
64 expected result and the actual one.
66 #define ASSERT_CONDITION(c) _LIT(KExpression, c);
68 #define ASSERT_EQUALS_X(aExpression, aExpected) \
71 TInt result = (TInt)(aExpression); \
72 TInt expected = (TInt)(aExpected); \
73 if (result != expected) \
75 ASSERT_CONDITION(#aExpression); \
76 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, not %d"), &KExpression(), result, expected ); \
77 User::Leave(KErrTEFUnitFail); \
82 #define ASSERT_NOT_EQUALS_X(aExpression, aUnexpected) \
85 TInt result = (TInt)(aExpression); \
86 TInt unexpected = (TInt)(aUnexpected); \
87 if (result == unexpected) \
89 ASSERT_CONDITION(#aExpression); \
90 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S == %d, unexpectedly"), &KExpression(), result ); \
91 User::Leave(KErrTEFUnitFail); \
96 #define ASSERT_TRUE_X(aExpression) \
99 TBool result = (TBool)(aExpression); \
102 ASSERT_CONDITION(#aExpression); \
103 Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, _L("%S false"), &KExpression() ); \
104 User::Leave(KErrTEFUnitFail); \
109 #endif // __TEF_LOG_EXTENSIONS__