|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32debug.h> |
|
17 #include <e32test.h> |
|
18 #include "BaAssert.h" |
|
19 #include "BaCompileAssert.h" |
|
20 |
|
21 RTest TheTest(_L(" t_baassert.cpp")); |
|
22 |
|
23 // |
|
24 // |
|
25 //Test macro and functions |
|
26 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
27 { |
|
28 if(aValue != aExpected) |
|
29 { |
|
30 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
31 TheTest(EFalse, aLine); |
|
32 } |
|
33 } |
|
34 |
|
35 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
36 |
|
37 |
|
38 /** |
|
39 @SYMTestCaseID BASESRVCS-BAFL-UT-4068 |
|
40 @SYMTestCaseDesc Tests the error code table (KErrorMapTbl) looks ups do not |
|
41 overrun and return random data in memory. |
|
42 @SYMTestPriority Medium |
|
43 @SYMTestActions Passes in an invalid error code, to check the correct error is return. |
|
44 Passes in valid error codes, at the end of the table to make sure the correct error |
|
45 code is returned. |
|
46 @SYMTestExpectedResults Correct system error codes are returned. |
|
47 @SYMDEF DEF124481 |
|
48 */ |
|
49 void DEF124481() |
|
50 { |
|
51 TBaAssert assertObj(TBaAssert::ELeave); |
|
52 |
|
53 TInt panicCode = 111; // Invalid error code. Valid range is 0-110. See KErrorMapTbl. |
|
54 // Should return 'KErrArgument' as the panicCode is outside the valid range. |
|
55 TRAPD (error, assertObj.AssertDebL(EFalse, static_cast <TBafPanic> (panicCode))); |
|
56 TEST2(error, KErrArgument); |
|
57 |
|
58 panicCode = EBafPanicRFsConnectArg; // Equates to 110, which maps to 'KErrArgument'. |
|
59 // Should return 'KErrArgument'. |
|
60 TRAP (error, assertObj.AssertDebL(EFalse, static_cast <TBafPanic> (panicCode))); |
|
61 TEST2(error, KErrArgument); |
|
62 |
|
63 panicCode = EBafPanicBufLength; // Equates to 109, which maps to 'KErrCorrupt'. |
|
64 // Should return 'KErrCorrupt'. |
|
65 TRAP (error, assertObj.AssertDebL(EFalse, static_cast <TBafPanic> (panicCode))); |
|
66 TEST2(error, KErrCorrupt); |
|
67 } |
|
68 |
|
69 |
|
70 LOCAL_D void RunTestsL() |
|
71 { |
|
72 TheTest.Start(_L("@SYMTestCaseID:ASESRVCS-BAFL-UT-4068 BAFL error code table look up tests")); |
|
73 DEF124481(); |
|
74 } |
|
75 |
|
76 |
|
77 TInt E32Main() |
|
78 { |
|
79 __UHEAP_MARK; |
|
80 CTrapCleanup *cleanup=CTrapCleanup::New(); |
|
81 TheTest.Title(); |
|
82 TRAPD(err,::RunTestsL()); |
|
83 TEST2(err, KErrNone); |
|
84 TheTest.End(); |
|
85 TheTest.Close(); |
|
86 delete(cleanup); |
|
87 __UHEAP_MARKEND; |
|
88 return(0); |
|
89 } |