129 test.Next(_L("Iterate over items")); |
154 test.Next(_L("Iterate over items")); |
130 TUint8 *checkMap=(TUint8*)User::AllocLC(KEntryCount); |
155 TUint8 *checkMap=(TUint8*)User::AllocLC(KEntryCount); |
131 Mem::FillZ(checkMap,KEntryCount); |
156 Mem::FillZ(checkMap,KEntryCount); |
132 TPagedSetIter<TUint32> iter(set); |
157 TPagedSetIter<TUint32> iter(set); |
133 if (iter.ResetL()) |
158 if (iter.ResetL()) |
134 do ++checkMap[iter.AtL()]; while (iter.NextL()); |
159 { |
|
160 do |
|
161 { |
|
162 TUint32 data1 = iter.AtL(); |
|
163 ++checkMap[data1]; |
|
164 TUint32 data2; |
|
165 iter.ExtractAtL(data2); |
|
166 test(data1 == data2); |
|
167 }while(iter.NextL()); |
|
168 } |
135 for (ii=0;ii<KEntryCount;++ii) |
169 for (ii=0;ii<KEntryCount;++ii) |
136 test(checkMap[ii]==1); |
170 test(checkMap[ii]==1); |
137 CleanupStack::PopAndDestroy(); |
171 CleanupStack::PopAndDestroy(); |
138 |
172 |
139 test.Next(_L("Delete items")); |
173 test.Next(_L("Delete items")); |
171 test.Next(_L("Check contents")); |
205 test.Next(_L("Check contents")); |
172 jj=(jj+17)%KEntryCount; |
206 jj=(jj+17)%KEntryCount; |
173 TPagedSetBiIter<TUint32> biter(set); |
207 TPagedSetBiIter<TUint32> biter(set); |
174 test(biter.FirstL()); |
208 test(biter.FirstL()); |
175 test(biter.AtL()==jj); |
209 test(biter.AtL()==jj); |
|
210 TUint32 data; |
|
211 biter.ExtractAtL(data); |
|
212 test(data == jj); |
176 test(!biter.NextL()); |
213 test(!biter.NextL()); |
177 test(biter.LastL()); |
214 test(biter.LastL()); |
178 test(biter.AtL()==jj); |
215 test(biter.AtL()==jj); |
179 test(!biter.PreviousL()); |
216 test(!biter.PreviousL()); |
180 TPagedSetRIter<TUint32> riter(set); |
217 TPagedSetRIter<TUint32> riter(set); |
181 test(riter.ResetL()); |
218 test(riter.ResetL()); |
182 test(riter.AtL()==jj); |
219 test(riter.AtL()==jj); |
|
220 riter.ExtractAtL(data); |
|
221 test(data == jj); |
183 test(!riter.NextL()); |
222 test(!riter.NextL()); |
184 |
223 |
185 //* test(set.DeleteL(jj)); |
224 //* test(set.DeleteL(jj)); |
186 set.DeleteL(jj); |
225 set.DeleteL(jj); |
187 test(!iter.ResetL()); |
226 test(!iter.ResetL()); |
377 |
420 |
378 test.End(); |
421 test.End(); |
379 CleanupStack::PopAndDestroy(); |
422 CleanupStack::PopAndDestroy(); |
380 } |
423 } |
381 |
424 |
|
425 /** |
|
426 @SYMTestCaseID PDS-STORE-CT-4065 |
|
427 @SYMTestCaseDesc TStreamPos tests. |
|
428 @SYMTestActions Tests operations provided by TStreamPos class. |
|
429 @SYMTestPriority High |
|
430 @SYMTestExpectedResults Test must not fail |
|
431 */ |
|
432 void StreamPosTest() |
|
433 { |
|
434 TStreamPos pos1; |
|
435 TStreamPos pos2(5); |
|
436 pos1 = pos2; |
|
437 test(pos1 == pos2); |
|
438 |
|
439 pos1 = 5 + pos2; |
|
440 test(pos1 > pos2); |
|
441 test(pos2 < pos1); |
|
442 test(pos2 <= pos1); |
|
443 test(pos1 != pos2); |
|
444 pos1 = pos1 - 5; |
|
445 test(pos1 == pos2); |
|
446 |
|
447 pos2 += 0; |
|
448 test(pos1 == pos2); |
|
449 pos2 -= 0; |
|
450 test(pos1 == pos2); |
|
451 } |
|
452 |
|
453 struct TTestEntry |
|
454 { |
|
455 inline TTestEntry() : |
|
456 iKey(-1), |
|
457 iData(-1) |
|
458 { |
|
459 } |
|
460 inline TTestEntry(TInt aKey, TInt aData) : |
|
461 iKey(aKey), |
|
462 iData(aData) |
|
463 { |
|
464 } |
|
465 TInt iKey; |
|
466 TInt iData; |
|
467 }; |
|
468 |
|
469 /** |
|
470 @SYMTestCaseID PDS-STORE-CT-4066 |
|
471 @SYMTestCaseDesc TBtreeFix tests. |
|
472 @SYMTestActions Tests operations provided by TBtreeFix class. |
|
473 @SYMTestPriority High |
|
474 @SYMTestExpectedResults Test must not fail |
|
475 */ |
|
476 void BTreeFixTestL() |
|
477 { |
|
478 CMemPagePool* pool = CMemPagePool::NewLC(); |
|
479 |
|
480 TBtreeToken token(TBtreeToken::EEmpty); |
|
481 TBool rc = token.IsEmpty(); |
|
482 test(rc); |
|
483 rc = token.IsIntact(); |
|
484 test(rc); |
|
485 |
|
486 TBtreeFix<TTestEntry, TInt> bentry(token, EBtreeSecure); |
|
487 TBtreeKey bkey(sizeof(TInt)); |
|
488 bentry.Connect(pool, &bkey); |
|
489 |
|
490 TBtreePos bpos; |
|
491 rc = bentry.FindL(bpos, 1); |
|
492 test(!rc); |
|
493 rc = bentry.InsertL(bpos, TTestEntry(1, 101)); |
|
494 test(rc); |
|
495 rc = bentry.FindL(bpos, 1); |
|
496 test(rc); |
|
497 TTestEntry entry1 = bentry.AtL(bpos); |
|
498 test(entry1.iKey == 1 && entry1.iData == 101); |
|
499 const void* key = bkey.Key(&entry1); |
|
500 TInt keyVal = *((const TInt*)key); |
|
501 test.Printf(_L("keyVal=%d\n"), keyVal); |
|
502 |
|
503 rc = bentry.InsertL(bpos, TTestEntry(3, 103)); |
|
504 test(rc); |
|
505 rc = bentry.InsertL(bpos, TTestEntry(2, 102)); |
|
506 test(rc); |
|
507 |
|
508 rc = bentry.FindL(bpos, 2); |
|
509 test(rc); |
|
510 TTestEntry entry2; |
|
511 bentry.ExtractAtL(bpos, entry2); |
|
512 test(entry2.iKey == 2 && entry2.iData == 102); |
|
513 |
|
514 rc = bentry.FindL(bpos, 3); |
|
515 test(rc); |
|
516 TTestEntry entry3; |
|
517 bentry.ExtractAtL(bpos, entry3); |
|
518 test(entry3.iKey == 3 && entry3.iData == 103); |
|
519 |
|
520 //============================================== |
|
521 |
|
522 TBtreeMark bmark; |
|
523 if(bentry.ResetL(bmark)) |
|
524 { |
|
525 do |
|
526 { |
|
527 TTestEntry entry = bentry.AtL(bmark); |
|
528 test.Printf(_L("AtL(): entry.iKey=%d, entry.iData=%d\n"), entry.iKey, entry.iData); |
|
529 bentry.ExtractAtL(bmark, entry); |
|
530 test.Printf(_L("ExtractAtL(): entry.iKey=%d, entry.iData=%d\n"), entry.iKey, entry.iData); |
|
531 }while(bentry.NextL(bmark)); |
|
532 } |
|
533 |
|
534 rc = bentry.NextL(bmark); |
|
535 test(!rc); |
|
536 |
|
537 //============================================== |
|
538 |
|
539 rc = bentry.DeleteL(2); |
|
540 test(rc); |
|
541 rc = bentry.FindL(bpos, 2); |
|
542 test(!rc); |
|
543 rc = bentry.FindL(bpos, 3); |
|
544 test(rc); |
|
545 TRAPD(err, bentry.DeleteAtL(bpos)); |
|
546 test(err == KErrNone); |
|
547 rc = bentry.FindL(bpos, 3); |
|
548 test(!rc); |
|
549 |
|
550 bentry.MarkDirty(); |
|
551 rc = bentry.IsDirty(); |
|
552 test(rc); |
|
553 bentry.MarkCurrent(); |
|
554 rc = bentry.IsDirty(); |
|
555 test(!rc); |
|
556 |
|
557 bentry.ClearL(); |
|
558 CleanupStack::PopAndDestroy(pool); |
|
559 } |
|
560 |
382 LOCAL_C void doMainL() |
561 LOCAL_C void doMainL() |
383 { |
562 { |
384 test.Start(_L("Basic operations")); |
563 test.Start(_L("Basic operations")); |
385 test1L(); |
564 test1L(); |
386 test.Next(_L("Large set TUint32")); |
565 test.Next(_L("Large set TUint32")); |
387 test2L(); |
566 test2L(); |
388 test.Next(_L("Tokens and streaming")); |
567 test.Next(_L("Tokens and streaming")); |
389 test3L(); |
568 test3L(); |
390 test.Next(_L("Forgotten API")); |
569 test.Next(_L("Forgotten API")); |
391 test4L(); |
570 test4L(); |
|
571 test.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4065: TStreamPos test")); |
|
572 StreamPosTest(); |
|
573 test.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4066: TBtreeFix test")); |
|
574 BTreeFixTestL(); |
392 test.End(); |
575 test.End(); |
393 } |
576 } |
394 |
577 |
395 LOCAL_C void setupCleanup() |
578 LOCAL_C void setupCleanup() |
396 // |
579 // |