sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Tests for CPtrC8Array and TKeyDesC8Array class(Test Improvement activity)
sl@0: // 
sl@0: //
sl@0: 
sl@0: #include <e32test.h>
sl@0: #include <badesca.h>
sl@0: 
sl@0: RTest test(_L("T_PTRCB"));
sl@0: 
sl@0: /**
sl@0: @SYMTestCaseID          SYSLIB-BAFL-UT-1706
sl@0: @SYMTestCaseDesc        Testing 8-bit descriptor arrays
sl@0: 						Tests for CPtrC8Array::MdcaCount(),CPtrC8Array::CopyL(),CPtrC8Array::operator =() functions
sl@0: @SYMTestPriority        Medium
sl@0: @SYMTestActions         Tests by adding descriptors to CDesC8Array and then copying to CPtrC8Array
sl@0: @SYMTestExpectedResults Tests must not fail
sl@0: @SYMREQ                 REQ0000
sl@0: */
sl@0: 
sl@0: void DoTestsL()
sl@0: 	{
sl@0: 	test.Next(_L("Test for ptrC8 and desC8 arrays"));
sl@0: 
sl@0: 	CPtrC8Array* ptrB = new(ELeave) CPtrC8Array(8);
sl@0: 	CDesC8Array* desB = new(ELeave) CDesC8ArrayFlat(8);
sl@0: 
sl@0: 	desB->AppendL(_L8("one"));
sl@0: 	desB->AppendL(_L8("two"));
sl@0: 	desB->AppendL(_L8("three"));
sl@0: 
sl@0: 	// calling CPtrC8Array::CopyL() with an overloaded '=' operator
sl@0: 
sl@0: 	*ptrB = *desB;
sl@0: 
sl@0: 	test(ptrB->MdcaCount()==desB->MdcaCount());
sl@0: 	test(ptrB->MdcaPoint(2)==desB->MdcaPoint(2));
sl@0: 
sl@0: 	test.Next(_L("Test for covering case ECmpCollated8 for TKeyDesC8Array class"));
sl@0: 
sl@0: 	TInt pos = desB->InsertIsqAllowDuplicatesL(_L8("hello"));
sl@0: 	test(desB->MdcaCount()==4);
sl@0: 
sl@0: 	// Invoking TKeyDesC8Array::Compare(), covers ECmpCollated8 case inside switch statement
sl@0: 
sl@0: 	desB->Sort(ECmpCollated8);
sl@0: 
sl@0: 	delete(ptrB);
sl@0: 	delete(desB);
sl@0: 	}
sl@0: 
sl@0: 
sl@0: TInt E32Main()
sl@0: 	{
sl@0:     __UHEAP_MARK;
sl@0: 
sl@0:     CTrapCleanup* cleanup=CTrapCleanup::New();
sl@0: 	if(cleanup == NULL)
sl@0: 	{
sl@0: 		return KErrNoMemory;
sl@0: 	}
sl@0: 	test.Title();
sl@0: 	test.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-UT-1706 Testing CPtrC8Array and TKeyDesC8Array class "));
sl@0: 
sl@0:     TRAPD(err,DoTestsL());
sl@0:     test(err==KErrNone);
sl@0:     test.End();
sl@0:     test.Close();
sl@0:     delete cleanup;
sl@0: 
sl@0:     __UHEAP_MARKEND;
sl@0: 
sl@0: 	return(0);
sl@0:     }