1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/apputils/tsrc/T_PTRCA.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,131 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Started by DWW, April 1996
1.18 +// Tests TPtrC arrays
1.19 +//
1.20 +//
1.21 +
1.22 +#include <e32test.h>
1.23 +#include <badesca.h>
1.24 +
1.25 +LOCAL_D RTest test(_L("T_PTRCA"));
1.26 +
1.27 +/**
1.28 +@SYMTestCaseID SYSLIB-BAFL-CT-0425
1.29 +@SYMTestCaseDesc Testing descriptor arrays
1.30 + Tests for CPtrCArray::MdcaPoint(),CPtrCArray::MdcaCount() functions
1.31 +@SYMTestPriority Medium
1.32 +@SYMTestActions Tests by adding descriptors to the arrays and then comparing both CPtrCArray & CDesCArray arrays
1.33 +@SYMTestExpectedResults Tests must not fail
1.34 +@SYMREQ REQ0000
1.35 +*/
1.36 +LOCAL_C void testPtrCDesC()
1.37 + {
1.38 + test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0425 PtrC and DesC "));
1.39 + CPtrCArray* ptrA=new(ELeave) CPtrCArray(8);
1.40 + CDesCArray* desA=new(ELeave) CDesCArrayFlat(8);
1.41 + desA->AppendL(_L("one"));
1.42 + ptrA->AppendL(desA->MdcaPoint(0));
1.43 + test(ptrA->MdcaPoint(0)==desA->MdcaPoint(0));
1.44 + TBuf<32> buffer=_L("two");
1.45 + ptrA->InsertL(0,buffer);
1.46 + test(ptrA->MdcaPoint(0)!=desA->MdcaPoint(0));
1.47 + buffer=_L("onetwothree");
1.48 + test(ptrA->MdcaPoint(0)==desA->MdcaPoint(0)); // TPtrC length is unchanged
1.49 + //
1.50 + desA->AppendL(_L("two"));
1.51 + desA->AppendL(_L("three"));
1.52 + test(ptrA->MdcaPoint(1)!=desA->MdcaPoint(1));
1.53 + *ptrA=*desA;
1.54 + test(ptrA->MdcaCount()==desA->MdcaCount());
1.55 + test(ptrA->MdcaPoint(1)==desA->MdcaPoint(1));
1.56 + buffer=ptrA->MdcaPoint(0);
1.57 + test(buffer==_L("one"));
1.58 + //
1.59 + ptrA->Reset();
1.60 + desA->Reset();
1.61 + buffer=_L("new test");
1.62 + desA->AppendL(buffer);
1.63 + ptrA->AppendL(buffer);
1.64 + test(ptrA->MdcaPoint(0)==buffer);
1.65 + test(desA->MdcaPoint(0)==buffer);
1.66 + buffer=_L("hello");
1.67 + desA->AppendL(buffer);
1.68 + ptrA->AppendL(buffer);
1.69 + test(ptrA->MdcaPoint(0)==_L("helloest"));
1.70 + test(ptrA->MdcaPoint(1)==buffer);
1.71 + test(desA->MdcaPoint(1)==buffer);
1.72 + //
1.73 + delete(ptrA);
1.74 + delete(desA);
1.75 + }
1.76 +
1.77 +/**
1.78 +@SYMTestCaseID SYSLIB-BAFL-CT-0426
1.79 +@SYMTestCaseDesc CPtrCArray class functionality test
1.80 +@SYMTestPriority Medium
1.81 +@SYMTestActions Tests for CPtrCArray::InsertIsqL(),CPtrCArray::InsertIsqAllowDuplicatesL() functions
1.82 +@SYMTestExpectedResults Tests must not fail
1.83 +@SYMREQ REQ0000
1.84 +*/
1.85 +LOCAL_C void testFindIsq()
1.86 + {
1.87 + test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0426 Findin in sequence "));
1.88 + CPtrCArray* ptrA=new(ELeave) CPtrCArray(8);
1.89 + //
1.90 + TPtrC hello(_S("Hello"));
1.91 + TPtrC bye(_S("Bye"));
1.92 + TPtrC world(_S("World"));
1.93 + TPtrC middle(_S("middle"));
1.94 + TPtrC extra(_S("extra"));
1.95 + TInt pos;
1.96 + ptrA->AppendL(hello);
1.97 + ptrA->AppendL(bye);
1.98 + ptrA->AppendL(world);
1.99 + ptrA->AppendL(middle);
1.100 + //
1.101 + TKeyArrayFix key(0,ECmpFolded);
1.102 + //
1.103 + ptrA->Find(world,key,pos);
1.104 + test(pos==2);
1.105 + ptrA->Sort(key);
1.106 + ptrA->Find(world,key,pos);
1.107 + test(pos==3);
1.108 + //
1.109 + pos=ptrA->InsertIsqL(extra,key);
1.110 + test(pos==1);
1.111 + TRAP(pos,ptrA->InsertIsqL(extra,key));
1.112 + test(pos==KErrAlreadyExists);
1.113 + pos=ptrA->InsertIsqAllowDuplicatesL(extra,key);
1.114 + test(pos==2);
1.115 + //
1.116 + delete(ptrA);
1.117 + }
1.118 +
1.119 +GLDEF_C TInt E32Main()
1.120 + {
1.121 + CTrapCleanup *cleanup=CTrapCleanup::New();
1.122 + test.Title();
1.123 + test.Start(_L("Testing descriptor arrays "));
1.124 + __UHEAP_MARK;
1.125 + TRAPD(err,testPtrCDesC());
1.126 + test(err==KErrNone);
1.127 + TRAP(err,testFindIsq());
1.128 + test(err==KErrNone);
1.129 + __UHEAP_MARKEND;
1.130 + test.End();
1.131 + test.Close();
1.132 + delete cleanup;
1.133 + return(0);
1.134 + }