|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #ifndef MUSTESTHELP_H_ |
|
18 #define MUSTESTHELP_H_ |
|
19 |
|
20 |
|
21 #define MUS_EUNIT_ASSERT_LEAVE( func ) { TRAPD( leaveErr, func );\ |
|
22 if ( leaveErr == KErrNoMemory )\ |
|
23 {\ |
|
24 User::Leave( KErrNoMemory );\ |
|
25 }\ |
|
26 EUNIT_ASSERT( leaveErr != KErrNone );} |
|
27 |
|
28 #define MUS_EUNIT_ASSERT_EQUALS( func, val ) \ |
|
29 {\ |
|
30 TInt musUnitTestRetVal = func;\ |
|
31 if ( musUnitTestRetVal != KErrNoMemory ){\ |
|
32 EUNIT_ASSERT_EQUALS( musUnitTestRetVal, val );\ |
|
33 }\ |
|
34 else{\ |
|
35 User::Leave( KErrNoMemory );\ |
|
36 }\ |
|
37 } |
|
38 |
|
39 #define MUS_EUNIT_ASSERT_SPECIFIC_LEAVE( func, val ) \ |
|
40 {\ |
|
41 TRAPD( musUnitTestRetVal, func );\ |
|
42 if ( val != KErrNoMemory && musUnitTestRetVal == KErrNoMemory ){\ |
|
43 User::Leave( KErrNoMemory );\ |
|
44 }\ |
|
45 else{\ |
|
46 EUNIT_ASSERT_EQUALS( musUnitTestRetVal, val );\ |
|
47 }\ |
|
48 } |
|
49 |
|
50 #define MUS_EUNIT_ASSERT_NO_LEAVE( func ) MUS_EUNIT_ASSERT_SPECIFIC_LEAVE( func, KErrNone ) |
|
51 |
|
52 #define MUS_LEAVE_HANDLING( func, oomMappedError ) {\ |
|
53 TRAPD( musUnitTestLeaveError, func );\ |
|
54 if ( musUnitTestLeaveError == KErrNoMemory || musUnitTestLeaveError == oomMappedError )\ |
|
55 {\ |
|
56 User::Leave( KErrNoMemory );\ |
|
57 }\ |
|
58 } |
|
59 |
|
60 // MUS memory leave asserting can be used to help on cases where memory leave |
|
61 // which occured deep inside function, cannot be determined from function return |
|
62 // values (i.e. memory leave was ignored and execution did not go as expected) |
|
63 #define MUS_MEMORY_LEAVE_CHECKING_ON |
|
64 |
|
65 #ifdef MUS_MEMORY_LEAVE_CHECKING_ON |
|
66 #define MUS_CHECK_MEMORY_LEAVE( conditions ) \ |
|
67 if ( !(conditions) )\ |
|
68 {\ |
|
69 User::Leave( KErrNoMemory );\ |
|
70 } |
|
71 |
|
72 #else |
|
73 #define MUS_CHECK_MEMORY_LEAVE( conditions ) \ |
|
74 EUNIT_ASSERT( conditions ) |
|
75 #endif |
|
76 |
|
77 #ifdef MUS_MEMORY_LEAVE_CHECKING_ON |
|
78 #define MUS_CHECK_MEMORY_LEAVE_NEG( conditions ) \ |
|
79 if ( conditions )\ |
|
80 {\ |
|
81 User::Leave( KErrNoMemory );\ |
|
82 } |
|
83 |
|
84 #else |
|
85 #define MUS_CHECK_MEMORY_LEAVE_NEG( conditions ) |
|
86 #endif |
|
87 |
|
88 #endif /*MUSTESTHELP_H_*/ |