1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
1489 test(r==KErrNone); |
1489 test(r==KErrNone); |
1490 } |
1490 } |
1491 map.ResetAndDestroy(); |
1491 map.ResetAndDestroy(); |
1492 } |
1492 } |
1493 |
1493 |
|
1494 void TestInsertL() |
|
1495 { |
|
1496 TInt i; |
|
1497 TInt count=50; |
|
1498 const TInt KMaxBufferSize=256; |
|
1499 // Array used to hold test data to store in the hash objects |
|
1500 RPointerArray<TDesC16> iPointerArray; |
|
1501 |
|
1502 for (i=0; i<count; ++i) |
|
1503 { |
|
1504 HBufC* hbuf = HBufC::NewLC(KMaxBufferSize); |
|
1505 TPtr buf = hbuf->Des(); |
|
1506 TTestName number(NumberInWords(i)); |
|
1507 buf.Copy(number); |
|
1508 // Append "one" "two" "three" ..... |
|
1509 iPointerArray.AppendL(hbuf); |
|
1510 CleanupStack::Pop(hbuf); |
|
1511 } |
|
1512 |
|
1513 // Creates an object ptrHashMap using the template class RPtrHashMap |
|
1514 RPtrHashMap<TDesC16, TDesC16> ptrHashMap; |
|
1515 // Push object on to the cleanup stack |
|
1516 CleanupClosePushL(ptrHashMap); |
|
1517 // Expand the array with the number of key-value pairs for which space should be allocated |
|
1518 ptrHashMap.ReserveL(count); |
|
1519 |
|
1520 // Insert a key-value pairs into the array |
|
1521 for (i=0; i<count; ++i) |
|
1522 { |
|
1523 // "zero"-"forty nine" |
|
1524 // "one"-"forty eight" ..... |
|
1525 ptrHashMap.InsertL(iPointerArray[i], iPointerArray[count-1-i]); |
|
1526 } |
|
1527 |
|
1528 // Close and Cleanup |
|
1529 CleanupStack::PopAndDestroy(&ptrHashMap); |
|
1530 iPointerArray.ResetAndDestroy(); |
|
1531 } |
|
1532 |
|
1533 |
1494 void TestOOM() |
1534 void TestOOM() |
1495 { |
1535 { |
1496 // Max out memory and check it still works |
1536 // Max out memory and check it still works |
1497 test.Next(_L("Test OOM")); |
1537 test.Next(_L("Test OOM")); |
1498 |
1538 |