persistentstorage/dbms/tdbms/t_dbthrd.cpp
branchRCL_3
changeset 6 5ffdb8f2067f
parent 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
2:6862383cf555 6:5ffdb8f2067f
   168 	}
   168 	}
   169 
   169 
   170 void CThread::Reset()
   170 void CThread::Reset()
   171 	{
   171 	{
   172 	iLog.Write(_L8("\nReset"));
   172 	iLog.Write(_L8("\nReset"));
   173 	test(iOpen);
   173 	TEST(iOpen);
   174 	iAccs.Reset();
   174 	iAccs.Reset();
   175 	iTrans.Reset();
   175 	iTrans.Reset();
   176 	}
   176 	}
   177 
   177 
   178 void CThread::RecoverL()
   178 void CThread::RecoverL()
   254 
   254 
   255 void CThread::AccountL(TInt anAccount)
   255 void CThread::AccountL(TInt anAccount)
   256 	{
   256 	{
   257 	Sql.Format(_L("id=%d"),anAccount);
   257 	Sql.Format(_L("id=%d"),anAccount);
   258 	iAccs.FirstL();
   258 	iAccs.FirstL();
   259 	test(iAccs.FindL(iAccs.EForwards,Sql)>=0);
   259 	TEST(iAccs.FindL(iAccs.EForwards,Sql)>=0);
   260 	}
   260 	}
   261 
   261 
   262 //
   262 //
   263 // generate and add a single transaction
   263 // generate and add a single transaction
   264 //
   264 //
   272 	else
   272 	else
   273 		from=Random(KAccountIDs);
   273 		from=Random(KAccountIDs);
   274 	TInt to=(Random(KAccountIDs-1)+from+1)%KAccountIDs;
   274 	TInt to=(Random(KAccountIDs-1)+from+1)%KAccountIDs;
   275 	AccountL(from);
   275 	AccountL(from);
   276 	iAccs.GetL();
   276 	iAccs.GetL();
   277 	test(iAccs.ColInt(1)==from);
   277 	TEST(iAccs.ColInt(1)==from);
   278 	TInt avail=iAccs.ColInt(2)+KOverdraftLimit;
   278 	TInt avail=iAccs.ColInt(2)+KOverdraftLimit;
   279 	TInt amount;
   279 	TInt amount;
   280 	if (to==ECash)
   280 	if (to==ECash)
   281 		{
   281 		{
   282 		if (avail<10)
   282 		if (avail<10)
   368 	}
   368 	}
   369 
   369 
   370 void CThread::VerifyL()
   370 void CThread::VerifyL()
   371 	{
   371 	{
   372 	TInt balance[KAccountIDs];
   372 	TInt balance[KAccountIDs];
   373 	test(iAccs.CountL()==KAccountIDs);
   373 	TEST(iAccs.CountL()==KAccountIDs);
   374 	for (iAccs.BeginningL();iAccs.NextL();)
   374 	for (iAccs.BeginningL();iAccs.NextL();)
   375 		{
   375 		{
   376 		iAccs.GetL();
   376 		iAccs.GetL();
   377 		TInt id=iAccs.ColInt(1);
   377 		TInt id=iAccs.ColInt(1);
   378 		balance[id]=iAccs.ColInt(3);
   378 		balance[id]=iAccs.ColInt(3);
   386 		TInt to=iTrans.ColInt(3);
   386 		TInt to=iTrans.ColInt(3);
   387 		TInt amount=iTrans.ColInt(4);
   387 		TInt amount=iTrans.ColInt(4);
   388 		balance[from]-=amount;
   388 		balance[from]-=amount;
   389 		balance[to]+=amount;
   389 		balance[to]+=amount;
   390 		}
   390 		}
   391 	test(transact==iTrans.CountL());
   391 	TEST(transact==iTrans.CountL());
   392 	for (iAccs.BeginningL();iAccs.NextL();)
   392 	for (iAccs.BeginningL();iAccs.NextL();)
   393 		{
   393 		{
   394 		iAccs.GetL();
   394 		iAccs.GetL();
   395 		TInt id=iAccs.ColInt(1);
   395 		TInt id=iAccs.ColInt(1);
   396 		if (balance[id]!=iAccs.ColInt(2))
   396 		if (balance[id]!=iAccs.ColInt(2))