persistentstorage/store/TCONT/t_storset.cpp
changeset 55 44f437012c90
parent 51 7d4490026038
--- a/persistentstorage/store/TCONT/t_storset.cpp	Mon Sep 27 11:59:56 2010 +0100
+++ b/persistentstorage/store/TCONT/t_storset.cpp	Tue Oct 19 16:26:13 2010 +0100
@@ -19,10 +19,40 @@
 #include <e32test.h>
 #include "U32STD.H"
 
-const TInt KTestCleanupStack=0x20;
+LOCAL_D RTest TheTest(_L("t_storset"));
 
-LOCAL_D CTrapCleanup* TheTrapCleanup;
-LOCAL_D RTest test(_L("t_storset"));
+///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////
+//Test macros and functions
+void Check1(TInt aValue, TInt aLine)
+	{
+	if(!aValue)
+		{
+		TheTest.Printf(_L("*** Expression  evaluated to false. Line %d\r\n"), aLine);
+		TheTest(EFalse, aLine);
+		}
+	}
+void Check2(TInt aValue, TInt aExpected, TInt aLine)
+	{
+	if(aValue != aExpected)
+		{
+		TheTest.Printf(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
+		TheTest(EFalse, aLine);
+		}
+	}
+void Check3(TUint aValue, TUint aExpected, TInt aLine)
+	{
+	if(aValue != aExpected)
+		{
+		TheTest.Printf(_L("*** Line %d, Expected value: %u, got: %u\r\n"), aLine, aExpected, aValue);
+		TheTest(EFalse, aLine);
+		}
+	}
+#define TEST(arg) ::Check1((arg), __LINE__)
+#define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
+#define TEST3(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
+
+///////////////////////////////////////////////////////////////////////////////////////
 
 /**
 @SYMTestCaseID          SYSLIB-STORE-CT-1121
@@ -35,89 +65,93 @@
 */
 LOCAL_C void test1L()
 	{
-	test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1121 Insertion & Deletion "));
+	TheTest.Printf(_L("Basic operations\r\n"));
 	
 	const TInt KEntryCount=200;
 	TPagedSet<TInt32> set;
 	set.Connect(CMemPagePool::NewLC());
 	//IsIntact() and IsDirty() test
+	TheTest.Printf(_L("IsIntact() and IsDirty() test\r\n"));
 	TBool rc = set.IsIntact();
-	test(rc);
+	TEST(rc);
 	rc = set.IsDirty();
-	test(!rc);
+	TEST(!rc);
 	set.MarkDirty();
 	rc = set.IsDirty();
-	test(rc);
+	TEST(rc);
 	//IsBroken() test
+	TheTest.Printf(_L("IsBroken() test\r\n"));
 	rc = set.IsBroken();
-	test(!rc);
+	TEST(!rc);
 	set.MarkBroken();
 	rc = set.IsBroken();
-	test(!rc);//Empty tree - cannot be marked as broken
+	TEST(!rc);//Empty tree - cannot be marked as broken
 	TInt yy = 10;
 	set.InsertL(yy);
 	set.MarkBroken();
 	rc = set.IsBroken();
-	test(rc);
+	TEST(rc);
+	TheTest.Printf(_L("RepairL()test\r\n"));
 	set.RepairL();
 	rc = set.IsBroken();
-	test(!rc);
+	TEST(!rc);
+	TheTest.Printf(_L("ClearL() test\r\n"));
 	set.ClearL();
 	rc = set.IsBroken();
-	test(!rc);
+	TEST(!rc);
 
+	TheTest.Printf(_L("InsertL() and DeleteL() test\r\n"));
 	TInt32 it=0;
-//*	test(set.InsertL(it));
+//*	TEST(set.InsertL(it));
 	set.InsertL(it);
-	test(set.Count()==1);
-//*	test(!set.InsertL(it));
-	test(set.Count()==1);
-	test(set.ContainsL(it));
-//*	test(set.DeleteL(it));
+	TEST2(set.Count(), 1);
+//*	TEST(!set.InsertL(it));
+	TEST2(set.Count(), 1);
+	TEST(set.ContainsL(it));
+//*	TEST(set.DeleteL(it));
 	set.DeleteL(it);
-	test(set.Count()==0);
-//*	test(!set.DeleteL(it));
-//*	test(set.Count()==0);
-	test(!set.ContainsL(it));
+	TEST2(set.Count(), 0);
+//*	TEST(!set.DeleteL(it));
+//*	TEST(set.Count()==0);
+	TEST(!set.ContainsL(it));
 
-//*	test.Next(_L("Duplicates"));
+//*	TheTest.Printf(_L("Duplicates"));
 	TInt ii;
 //*	for (ii=0;ii<KEntryCount;++ii)
-//*		test(set.InsertL(it,EAllowDuplicates));
-//*	test(set.Count()==KEntryCount);
-//*	test(set.ContainsL(it));
-//*	test(!set.InsertL(it));
+//*		TEST(set.InsertL(it,EAllowDuplicates));
+//*	TEST2(set.Count(), KEntryCount);
+//*	TEST(set.ContainsL(it));
+//*	TEST(!set.InsertL(it));
 //*	for (ii=0;ii<KEntryCount;++ii)
-//*		test(set.DeleteL(it));
-//*	test(!set.ContainsL(it));
-//*	test(!set.DeleteL(it));
-//*	test(set.Count()==0);
+//*		TEST(set.DeleteL(it));
+//*	TEST(!set.ContainsL(it));
+//*	TEST(!set.DeleteL(it));
+//*	TEST2(set.Count(), 0);
 
-	test.Next(_L("No duplicates"));
+	TheTest.Printf(_L("No duplicates\r\n"));
 	for (ii=0;ii<KEntryCount;++ii)
 		{
 		it=ii;
-//*		test(set.InsertL(it));
+//*		TEST(set.InsertL(it));
 		set.InsertL(it);
 		}
 	for (ii=0;ii<KEntryCount;++ii)
 		{
 		it=ii;
-//*		test(!set.InsertL(it));
-		test(set.ContainsL(it));
+//*		TEST(!set.InsertL(it));
+		TEST(set.ContainsL(it));
 		}
-	test(set.Count()==KEntryCount);
+	TEST2(set.Count(), KEntryCount);
 
-	test.Next(_L("Empty the set"));
+	TheTest.Printf(_L("Empty the set\r\n"));
 	set.ClearL();
-	test(set.Count()==0);
+	TEST2(set.Count(), 0);
 	for (ii=0;ii<KEntryCount;++ii)
 		{
 		it=ii;
-		test(!set.ContainsL(it));
+		TEST(!set.ContainsL(it));
 		}
 
-	test.End();
 	CleanupStack::PopAndDestroy();
 	}
 /**
@@ -136,22 +170,22 @@
 //*	set.Connect(CMemPagePool::NewLC(),TBtree::EQosFastest);
 	set.Connect(CMemPagePool::NewLC());
 
-	test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1122 Add items "));
+	TheTest.Printf(_L("Add items\r\n"));
 	TUint32 jj=0;
 	TInt32 ii;
 	for (ii=KEntryCount;ii>0;--ii)
 		{
 		jj=(jj+17)%KEntryCount;
-//*		test(set.InsertL(jj));
+//*		TEST(set.InsertL(jj));
 		set.InsertL(jj);
 		}
-	test(set.Count()==KEntryCount);
+	TEST2(set.Count(), KEntryCount);
 
-	test.Next(_L("Check contents"));
+	TheTest.Printf(_L("Check contents\r\n"));
 	for (ii=0;ii<KEntryCount;++ii)
-		test(set.ContainsL(ii));
+		TEST(set.ContainsL(ii));
 
-	test.Next(_L("Iterate over items"));
+	TheTest.Printf(_L("Iterate over items\r\n"));
 	TUint8 *checkMap=(TUint8*)User::AllocLC(KEntryCount);
 	Mem::FillZ(checkMap,KEntryCount);
 	TPagedSetIter<TUint32> iter(set);
@@ -163,70 +197,68 @@
 			++checkMap[data1];
 			TUint32 data2;
 			iter.ExtractAtL(data2);
-			test(data1 == data2);
+			TEST3(data1, data2);
 			}while(iter.NextL());
 		}
 	for (ii=0;ii<KEntryCount;++ii)
-		test(checkMap[ii]==1);
+		TEST2(checkMap[ii], 1);
 	CleanupStack::PopAndDestroy();
 
-	test.Next(_L("Delete items"));
+	TheTest.Printf(_L("Delete items\r\n"));
 	jj=0;
 	for (ii=KEntryCount;ii>KEntryCount/2;--ii)
 		{
 		jj=(jj+17)%KEntryCount;
-//*		test(set.DeleteL(jj));
+//*		TEST(set.DeleteL(jj));
 		set.DeleteL(jj);
 		}
-	test(set.Count()==KEntryCount/2);
+	TEST2(set.Count(), KEntryCount/2);
 
-	test.Next(_L("Check contents"));
+	TheTest.Printf(_L("Check contents\r\n"));
 	for (;ii>0;--ii)
 		{
 		jj=(jj+17)%KEntryCount;
-		test(set.ContainsL(jj));
+		TEST(set.ContainsL(jj));
 		}
 	jj=0;
 	for (ii=KEntryCount;ii>KEntryCount/2;--ii)
 		{
 		jj=(jj+17)%KEntryCount;
-		test(!set.ContainsL(jj));
+		TEST(!set.ContainsL(jj));
 		}
 
-	test.Next(_L("Delete items"));
+	TheTest.Printf(_L("Delete items\r\n"));
 	for (;ii>1;--ii)
 		{
 		jj=(jj+17)%KEntryCount;
-//*		test(set.DeleteL(jj));
+//*		TEST(set.DeleteL(jj));
 		set.DeleteL(jj);
 		}
-	test(set.Count()==1);
+	TEST2(set.Count(), 1);
 
-	test.Next(_L("Check contents"));
+	TheTest.Printf(_L("Check contents\r\n"));
 	jj=(jj+17)%KEntryCount;
 	TPagedSetBiIter<TUint32> biter(set);
-	test(biter.FirstL());
-	test(biter.AtL()==jj);
+	TEST(biter.FirstL());
+	TEST3(biter.AtL(), jj);
 	TUint32 data; 
 	biter.ExtractAtL(data);
-	test(data == jj);
-	test(!biter.NextL());
-	test(biter.LastL());
-	test(biter.AtL()==jj);
-	test(!biter.PreviousL());
+	TEST3(data, jj);
+	TEST(!biter.NextL());
+	TEST(biter.LastL());
+	TEST3(biter.AtL(), jj);
+	TEST(!biter.PreviousL());
 	TPagedSetRIter<TUint32> riter(set);
-	test(riter.ResetL());
-	test(riter.AtL()==jj);
+	TEST(riter.ResetL());
+	TEST3(riter.AtL(), jj);
 	riter.ExtractAtL(data);
-	test(data == jj);
-	test(!riter.NextL());
+	TEST3(data, jj);
+	TEST(!riter.NextL());
 
-//*	test(set.DeleteL(jj));
+//*	TEST(set.DeleteL(jj));
 	set.DeleteL(jj);
-	test(!iter.ResetL());
-	test(set.Count()==0);
-
-	test.End();
+	TEST(!iter.ResetL());
+	TEST2(set.Count(), 0);
 
 	CleanupStack::PopAndDestroy();
 	}
@@ -240,7 +272,7 @@
 */
 LOCAL_C void test3aL(RWriteStream& aStream,MPagePool *aPool,TInt aCount)
 	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1123 "));
+	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1123"));
 	TPagedSet<TInt32> set;
 //*	set.Connect(aPool,TBtree::EQosFastest);
 	set.Connect(aPool);
@@ -263,21 +295,21 @@
 */
 LOCAL_C void test3bL(RReadStream& aStream,MPagePool *aPool,TInt aCount)
 	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1124 "));
+	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1124"));
 	TPagedSetToken token;
 	aStream>>token;
 	TPagedSet<TInt32> set(token);
 //*	set.Connect(aPool,TBtree::EQosFastest);
 	set.Connect(aPool);
 
-	test(set.Count()==aCount);
+	TEST2(set.Count(), aCount);
 	for (TInt ii=0;ii<aCount;ii++)
 		{
 		TInt32 it=ii;
-//*		test(set.DeleteL(it));
+//*		TEST(set.DeleteL(it));
 		set.DeleteL(it);
 		}
-	test(set.Count()==0);
+	TEST2(set.Count(), 0);
 	}
 
 /**
@@ -293,32 +325,102 @@
 	const TInt KEntryCount=1000;
 	MPagePool *pool=CMemPagePool::NewLC();
 	TUint8 stream[0x40];
-	test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1125 Build set and stream out "));
+	TheTest.Printf(_L("Build set and stream out\r\n"));
 	RMemWriteStream out(stream,sizeof(stream));
 	test3aL(out,pool,KEntryCount);
-	test.Next(_L("Stream in and test set "));
+	TheTest.Printf(_L("Stream in and test set\r\n"));
 	RMemReadStream in(stream,sizeof(stream));
 	test3bL(in,pool,KEntryCount);
-	test.End();
 	CleanupStack::PopAndDestroy();
 	}
 
 class CPersistentStoreHelper: public CPersistentStore
 	{
-	virtual MStreamBuf* DoReadL(TStreamId /*anId*/) const
+private:
+	virtual MStreamBuf* DoReadL(TStreamId) const
+		{
+		return NULL;
+		}
+	virtual MStreamBuf* DoCreateL(TStreamId&)
 		{
 		return NULL;
 		}
-	virtual MStreamBuf* DoCreateL(TStreamId& /*anId*/)
+	};
+
+void DoBiITerMultiSetTestL(TPagedSetBiIter<TInt32>& aIter, TInt aCount)
+	{
+	TInt count = 0;
+	TBool rc = aIter.FirstL();
+	TEST(rc);
+	++count;
+	while(aIter.NextL())
 		{
-		return NULL;
+		++count;
+		}
+	TEST2(count, aCount);
+	
+	count = 0;
+	rc = aIter.LastL();
+	TEST(rc);
+	++count;
+	while(aIter.PreviousL())
+		{
+		++count;
+		}
+	TEST2(count, aCount);
+	}
+
+void DoRIterMultiSetTestL(TPagedSetRIter<TInt32> aIter, TInt aCount)
+	{
+	TInt count = 0;
+	TBool rc = aIter.ResetL();
+	TEST(rc);
+	++count;
+	while(aIter.NextL())
+		{
+		++count;
 		}
-	void Help()
+	TEST2(count, aCount);
+	}
+
+void DoRIterAnyMultiSetTestL(TPagedSetRIter<TAny> aIter, TInt aCount)
+	{
+	TInt count = 0;
+	TBool rc = aIter.ResetL();
+	TEST(rc);
+	++count;
+	while(aIter.NextL())
 		{
-		//just do nothing
-		return;
+		++count;
+		}
+	TEST2(count, aCount);
+	}
+
+void DoIterMultiSetTestL(TPagedSetIter<TInt32> aIter, TInt aCount)
+	{
+	TInt count = 0;
+	TBool rc = aIter.ResetL();
+	TEST(rc);
+	++count;
+	while(aIter.NextL())
+		{
+		++count;
 		}
-	};
+	TEST2(count, aCount);
+	}
+
+void DoIterAnyMultiSetTestL(TPagedSetIter<TAny> aIter, TInt aCount)
+	{
+	TInt count = 0;
+	TBool rc = aIter.ResetL();
+	TEST(rc);
+	++count;
+	while(aIter.NextL())
+		{
+		++count;
+		}
+	TEST2(count, aCount);
+	}
 
 /**
 @SYMTestCaseID          PDS-STORE-CT-4015
@@ -335,57 +437,87 @@
 	{
 	const TInt KEntryCount=200;
 
-	test.Start(_L(" @SYMTestCaseID:PDS-STORE-CT-4015 Test untested APIs "));
+	TheTest.Printf(_L("Test untested APIs\r\n"));
 
 	TInt32 it=0;
 	TPagedMultiset<TInt32> set;
 	set.Connect(CMemPagePool::NewLC());
-	test.Next(_L("Duplicates"));
+	TheTest.Printf(_L("Duplicates\r\n"));
 	TInt ii, err;
 	for (ii=0;ii<KEntryCount;++ii)
 		{
 		TRAP(err, set.InsertL(it));
-		test(err==KErrNone);
+		TEST2(err, KErrNone);
 		}
-	test(set.Count()==KEntryCount);
+	TEST2(set.Count(), KEntryCount);
 	TBool rc = set.IsEmpty();
-	test(!rc);
+	TEST(!rc);
+
+	TPagedSetBiIter<TInt32> biIter(set);
+	DoBiITerMultiSetTestL(biIter, set.Count());
+
+	TPagedSetRIter<TInt32> rIter(set);
+	DoRIterMultiSetTestL(rIter, set.Count());
+	TPagedSetRIter<TAny> rIter2(set);
+	DoRIterAnyMultiSetTestL(rIter2, set.Count());
+
+	TPagedSetIter<TInt32> iter(set);
+	DoIterMultiSetTestL(iter, set.Count());
+	TPagedSetIter<TAny> iter2(set);
+	DoIterAnyMultiSetTestL(iter2, set.Count());
+	
+	TPagedSetToken token = set.Token();
+	TPagedMultiset<TInt32> multiSet2(token);
+	TEST2(multiSet2.Count(), set.Count());
+	TPagedMultiset<TAny> multiSet3(token, sizeof(TInt32));
+	TEST2(multiSet3.Count(), set.Count());
+	TPagedMultiset<TAny> multiSet4(sizeof(TInt32));
+	TEST2(multiSet4.Count(), 0);
+	TPagedSet<TAny> set5(token, sizeof(TInt32));
+	TEST2(set5.Count(), set.Count());
+	TPagedSet<TAny> set6(sizeof(TInt32));
+	TEST2(set6.Count(), 0);
+	
 	set.MarkDirty();
 	set.MarkCurrent();
 	TRAP(err, set.ContainsL(it));
-	test(err==KErrNone);
+	TEST2(err, KErrNone);
 	TRAP(err, set.InsertL(it));
-	test(err==KErrNone);
+	TEST2(err, KErrNone);
 		
 	for (ii=0;ii<KEntryCount;++ii)
 		{
 		TRAP(err, set.DeleteL(it));
-		test(err==KErrNone);
+		TEST2(err, KErrNone);
 		}
 		
 	TRAP(err, set.ContainsL(it));
-	test(err==KErrNone);
+	TEST2(err, KErrNone);
 	TRAP(err, set.DeleteL(it));
-	test(err==KErrNone);
-	test(set.Count()==0);
+	TEST2(err, KErrNone);
+	TEST2(set.Count(), 0);
 	
-	test.Next(_L("Calling MPagePool::Delete"));
+	TheTest.Printf(_L("Calling MPagePool::Delete\r\n"));
 	CMemPagePool* mpp = CMemPagePool::NewLC();
 	const TPageAbandonFunction& nopFunc = mpp->AcquireL();
-	test(&nopFunc != NULL);
+	TEST(&nopFunc != NULL);
 	TAny* any = mpp->AllocL();
 	TPageRef pref;
 	pref = mpp->AssignL(any, EPageReclaimable);
 	mpp->MPagePool::Delete(pref);
 	CleanupStack::PopAndDestroy();
 	
-	test.Next(_L("CPersistentStore DoSetRootL"));
+	TheTest.Printf(_L("CPersistentStore::DoSetRootL\r\n"));
 	CPersistentStoreHelper* ps = new (ELeave) CPersistentStoreHelper();
 	CleanupStack::PushL(ps);
 	ps->SetRootL(KNullStreamId);
-	CleanupStack::PopAndDestroy();
+	TRAP(err, ps->ExtendL());
+	TEST2(err, KErrNotSupported);
+	TRAP(err, ps->DeleteL(TStreamId(1u)));
+	TEST2(err, KErrNotSupported);
+	CleanupStack::PopAndDestroy(ps);
 	
-	test.Next(_L("HDirectStoreBuf::DoSeekL calls"));
+	TheTest.Printf(_L("HDirectStoreBuf::DoSeekL calls\r\n"));
 	HBufC8* buf = HBufC8::NewLC(1024);
 	RDesWriteStream wts;
 	
@@ -404,21 +536,20 @@
 	RStoreReadStream rstream;
 	rstream.OpenL(*estor, id);
 	TStreamPos pos = rstream.Source()->SeekL(MStreamBuf::ERead, 5);
-	test(pos.Offset() == 5);
+	TEST2(pos.Offset(), 5);
 	rts.Close();
 	rstream.Close();
 	CleanupStack::PopAndDestroy(2);
 	
-	test.Next(_L("Calling TEmpty Constructor"));
-	TPagedSetToken set2(TBtreeToken::EEmpty);
-	test( set2.Count() == 0);
+	TheTest.Printf(_L("Calling TEmpty Constructor\r\n"));
+	TPagedSetToken set3(TBtreeToken::EEmpty);
+	TEST2( set3.Count(), 0);
 	
-	test.Next(_L("Set function"));
-	set.Set(set2);
+	TheTest.Printf(_L("Set function\r\n"));
+	set.Set(set3);
 	const TPagedSetToken& pst = set.Token();
-	test(pst.Count() == set2.Count());
+	TEST2(pst.Count(), set3.Count());
 	
-	test.End();
 	CleanupStack::PopAndDestroy();
 	}
 
@@ -434,20 +565,20 @@
 	TStreamPos pos1;
 	TStreamPos pos2(5);
 	pos1 = pos2;
-	test(pos1 == pos2);
+	TEST(pos1 == pos2);
 	
 	pos1 = 5 + pos2;
-	test(pos1 > pos2);
-	test(pos2 < pos1);
-	test(pos2 <= pos1);
-	test(pos1 != pos2);
+	TEST(pos1 > pos2);
+	TEST(pos2 < pos1);
+	TEST(pos2 <= pos1);
+	TEST(pos1 != pos2);
 	pos1 = pos1 - 5;
-	test(pos1 == pos2);
+	TEST(pos1 == pos2);
 	
 	pos2 += 0;
-	test(pos1 == pos2);
+	TEST(pos1 == pos2);
 	pos2 -= 0;
-	test(pos1 == pos2);
+	TEST(pos1 == pos2);
 	}
 
 struct TTestEntry
@@ -479,9 +610,9 @@
 		
 	TBtreeToken token(TBtreeToken::EEmpty);
 	TBool rc = token.IsEmpty();
-	test(rc);
+	TEST(rc);
 	rc = token.IsIntact();
-	test(rc);
+	TEST(rc);
 	
 	TBtreeFix<TTestEntry, TInt> bentry(token, EBtreeSecure);
 	TBtreeKey bkey(sizeof(TInt));
@@ -489,33 +620,33 @@
 	
 	TBtreePos bpos;
 	rc = bentry.FindL(bpos, 1);
-	test(!rc);
+	TEST(!rc);
 	rc = bentry.InsertL(bpos, TTestEntry(1, 101));
-	test(rc);
+	TEST(rc);
 	rc = bentry.FindL(bpos, 1);
-	test(rc);
+	TEST(rc);
 	TTestEntry entry1 = bentry.AtL(bpos);
-	test(entry1.iKey == 1 && entry1.iData == 101);
+	TEST(entry1.iKey == 1 && entry1.iData == 101);
 	const void* key = bkey.Key(&entry1);
 	TInt keyVal = *((const TInt*)key);
-	test.Printf(_L("keyVal=%d\n"), keyVal);
+	TheTest.Printf(_L("keyVal=%d\r\n"), keyVal);
 	
 	rc = bentry.InsertL(bpos, TTestEntry(3, 103));
-	test(rc);
+	TEST(rc);
 	rc = bentry.InsertL(bpos, TTestEntry(2, 102));
-	test(rc);
+	TEST(rc);
 	
 	rc = bentry.FindL(bpos, 2);
-	test(rc);
+	TEST(rc);
 	TTestEntry entry2;
 	bentry.ExtractAtL(bpos, entry2);
-	test(entry2.iKey == 2 && entry2.iData == 102);
+	TEST(entry2.iKey == 2 && entry2.iData == 102);
 
 	rc = bentry.FindL(bpos, 3);
-	test(rc);
+	TEST(rc);
 	TTestEntry entry3;
 	bentry.ExtractAtL(bpos, entry3);
-	test(entry3.iKey == 3 && entry3.iData == 103);
+	TEST(entry3.iKey == 3 && entry3.iData == 103);
 
 	//==============================================
 	
@@ -525,85 +656,76 @@
 		do
 			{
 			TTestEntry entry = bentry.AtL(bmark);
-			test.Printf(_L("AtL(): entry.iKey=%d, entry.iData=%d\n"), entry.iKey, entry.iData);
+			TheTest.Printf(_L("AtL(): entry.iKey=%d, entry.iData=%d\r\n"), entry.iKey, entry.iData);
 			bentry.ExtractAtL(bmark, entry);
-			test.Printf(_L("ExtractAtL(): entry.iKey=%d, entry.iData=%d\n"), entry.iKey, entry.iData);
+			TheTest.Printf(_L("ExtractAtL(): entry.iKey=%d, entry.iData=%d\r\n"), entry.iKey, entry.iData);
 			}while(bentry.NextL(bmark));
 		}
 
 	rc = bentry.NextL(bmark);
-	test(!rc);
+	TEST(!rc);
 
 	//==============================================
 
 	rc = bentry.DeleteL(2);
-	test(rc);
+	TEST(rc);
 	rc = bentry.FindL(bpos, 2);
-	test(!rc);
+	TEST(!rc);
 	rc = bentry.FindL(bpos, 3);
-	test(rc);
+	TEST(rc);
 	TRAPD(err, bentry.DeleteAtL(bpos));
-	test(err == KErrNone);
+	TEST(err == KErrNone);
 	rc = bentry.FindL(bpos, 3);
-	test(!rc);
+	TEST(!rc);
 	
 	bentry.MarkDirty();
 	rc = bentry.IsDirty();
-	test(rc);
+	TEST(rc);
 	bentry.MarkCurrent();
 	rc = bentry.IsDirty();
-	test(!rc);
+	TEST(!rc);
 	
 	bentry.ClearL();
 	CleanupStack::PopAndDestroy(pool);
 	}
 
-LOCAL_C void doMainL()
+LOCAL_C void DoTestsL()
 	{
-	test.Start(_L("Basic operations"));
+	TheTest.Start(_L("@SYMTestCaseID:SYSLIB-STORE-CT-1121 Basic operations"));
 	test1L();
-	test.Next(_L("Large set TUint32"));
+	TheTest.Next(_L("@SYMTestCaseID:SYSLIB-STORE-CT-1122 Large set TUint32"));
 	test2L();
-	test.Next(_L("Tokens and streaming"));
+	TheTest.Next(_L("@SYMTestCaseID:SYSLIB-STORE-CT-1125 Tokens and streaming"));
 	test3L();
-	test.Next(_L("Forgotten API"));
+	TheTest.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4015 Forgotten API"));
 	test4L();
-	test.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4065: TStreamPos test"));
+	TheTest.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4065: TStreamPos test"));
 	StreamPosTest();
-	test.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4066: TBtreeFix test"));
+	TheTest.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4066: TBtreeFix test"));
 	BTreeFixTestL();
-	test.End();
 	}
 
-LOCAL_C void setupCleanup()
-//
-// Initialise the cleanup stack.
-//
-    {
-	TheTrapCleanup=CTrapCleanup::New();
-	test(TheTrapCleanup!=NULL);
-	TRAPD(r,\
-		{\
-		for (TInt i=KTestCleanupStack;i>0;i--)\
-			CleanupStack::PushL((TAny*)1);\
-		test(r==KErrNone);\
-		CleanupStack::Pop(KTestCleanupStack);\
-		});
-	test(r==KErrNone);
+TInt E32Main()
+	{
+    TheTest.Title();
+    
+    CTrapCleanup* tc = CTrapCleanup::New();
+    TheTest(tc != NULL);
+    
+    __UHEAP_MARK;
+    
+    TRAPD(err, DoTestsL());
+    TEST2(err, KErrNone);
+
+    __UHEAP_MARKEND;
+
+    User::Heap().Check();
+    
+    TheTest.End();
+    TheTest.Close();
+    
+    delete tc;
+
+    return KErrNone;
 	}
 
-GLDEF_C TInt E32Main()
-	{
-	test.Title();
-	setupCleanup();
-	__UHEAP_MARK;
-//
-	TRAPD(r,doMainL());
-	test(r==KErrNone);
-//
-	__UHEAP_MARKEND;
-	delete TheTrapCleanup;
-	test.Close();
-	return 0;
-	}
-