Example #1
0
LOCAL_C void test1(CArrayFix<TText>& aFix)
//
	{
	test.Next(_L("AppendL and InsertL single chars"));
	aFix.AppendL(_S("abcd"),4);
	test(aFix[0]=='a');
	test(aFix[1]=='b');
	test(aFix[3]=='d');
	test(aFix.Count()==4);
	aFix.InsertL(2,_S("ef"),2);
	test(aFix[1]=='b');
	test(aFix[2]=='e');
	test(aFix[4]=='c');
	test(aFix.Count()==6);	
	aFix.AppendL(TText('z'));
	test(aFix[6]=='z');
	aFix.InsertL(0,TText('y'));
	test(aFix[0]=='y');
	test(aFix[1]=='a');
	test(aFix.Count()==8);
	test.Next(_L("Delete single chars"));
	aFix.Delete(3);
	test(aFix[2]=='b');
	test(aFix[3]=='f');
	test(aFix[4]=='c');
	aFix.Delete(1,2);
	test(aFix[0]=='y');
	test(aFix[1]=='f');
	test(aFix[2]=='c');
	test(aFix.Count()==5);
	aFix.Compress();
	}
Example #2
0
LOCAL_C void testFix(CArrayFix<TBuf<0x10> >& aFix)
//
// Test all methods
//
	{
	test.Next(_L("Test all methods"));
	test(aFix.Count()==0);
	test(aFix.Length()==sizeof(TBuf<0x10>));
	aFix.Compress();
	test(TRUE);
	aFix.Reset();
	test(TRUE);
	TKeyArrayFix kk(0,ECmpNormal,0x10);
	test(TRUE);
	aFix.Sort(kk);
	test(TRUE);
	TBuf<0x10> aa(_L("aaaaa"));
	aFix.InsertL(0,aa);
	test(TRUE);
	aFix[0].Fill(' ');
	test(TRUE);
	TBuf<0x10> z(aFix[0]);
    z.Length();
	test(TRUE);
	aFix[0].Fill('a');
	test(TRUE);
	TInt pp;
	test(aFix.Find(aa,kk,pp)==0);
	test(pp==0);
	aFix.Delete(0);
	TBuf<0x10> bb(_L("bbbbb"));
	aFix.AppendL(bb);
	test(aFix.Count()==1);
	test(aFix.InsertIsqAllowDuplicatesL(aa,kk)==0);
	test(aFix.InsertIsqAllowDuplicatesL(bb,kk)==2);
	test(aFix.FindIsq(aa,kk,pp)==0);
	test(pp==0);
	aFix.Reset();
	for(TInt index=0;index<KTestGranularity*7/2;index++)
		aFix.AppendL(aa);
	const TBuf<0x10> *end=NULL;
	const TBuf<0x10> *ptr=NULL;
	for(TInt index2=0;index2<KTestGranularity*7/2;index2++)
		{
		if (end==ptr)
			{
			end=aFix.End(index2);
			ptr=&aFix[index2];
			TInt seglen=end-ptr;
			test(seglen==KTestGranularity || seglen==(aFix.Count()-index2));
			}
		test(&aFix[index2]==ptr++);
		}
	const TBuf<0x10> *bak=NULL;
	ptr=NULL;
	for(TInt index3=KTestGranularity*7/2;index3>0;index3--)
		{
		if (bak==ptr)
			{
			bak=aFix.Back(index3);
			ptr=&aFix[index3-1]+1;
			TInt seglen=ptr-bak;
			test(seglen==KTestGranularity || seglen==index3 || seglen==index3%KTestGranularity);
			}
		test(&aFix[index3-1]==--ptr);
		}
	
	//Test ExpandL
	//Expand array in slot 1
	TBuf16<0x10> exp;
	exp=_L("abc AbC");
	aFix.InsertL(0,exp);
	aFix.InsertL(1,exp);
	aFix.InsertL(2,exp);
	exp=aFix.ExpandL(1);
	test(aFix[0]==_L("abc AbC"));
	test(aFix[1]==_L(""));
	test(aFix[2]==_L("abc AbC"));
	test(aFix[3]==_L("abc AbC"));
	
	//Test ResizeL and InsertReplL
	//Resize the array to containing 20 records,
	//copying a record into any new slots.
	TBuf<0x10> res(_L("bbbbb"));
	aFix.Reset();
	aFix.ResizeL(20,res);
	for(TInt i=0;i<20;i++)
	    {
        test(aFix[1]==_L("bbbbb"));
	    }
	}