Update contrib.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\buffer\t_que.cpp
16 // Test double linked list functionality.
18 // TDblQueLinkBase, TDeltaQueLink, TDblQueLink, TPriQueLink,
19 // TDblQueIterBase, TDblQueIter
21 // - Create many TDblQueLinkBase links, insert links at specified locations
22 // and check previous and next links are as expected.
23 // - Create many TDeltaQueLink links, insert these links at specified locations
24 // and check previous and next links are as expected.
25 // - Create many TDblQueLink links, insert, remove these links at specified
26 // locations and check previous and next links are as expected.
27 // - Create many TPriQueLink links, insert, remove these links at specified
28 // locations and check previous and next links are as expected.
29 // - Create TDblQueBase based object without offset, with specified offset
30 // and check it is constructed as expected.
31 // - Create TDblQueBase based object, insert and remove TPriQueLink list
32 // element, set priorities of TPriQueLink list elements, call IsEmpty
34 // - Create TDblQueBase based object without, with offset and check
35 // it is constructed as expected
36 // - Create TDblQueBase based object, insert TDblQueLink links at
37 // specified locations and check that they are added as expected.
38 // - Initialise TPriQueLink link with different priorities, insert
39 // the elements in priority order and check that they are added
41 // - Create TDblQueBase based object, check the double linked list for empty
42 // before inserting, after inserting, before/after Deque, before/after Enque,
43 // after Reset. Verify that results are as expected.
44 // - Create TDeltaQueBase object without offset, with specified offset
45 // and check it is constructed as expected. Insert TDeltaQueLink list
46 // elements at specified distance from the zero point, remove the elements
47 // at specified distance, decrement the delta value.
48 // - Create TDeltaQueBase based object, insert TDblQueLink link at specified
49 // locations and check the previous, next link are as expected.
50 // - Check the linked list for empty before inserting, after inserting,
51 // before/after Deque, before/after Enque, after Reset. Verify that results
53 // - Create TDeltaQueBase based object, insert links using DoAddDelta method,
54 // check that links are as expected. Delete links using DoRemove and
55 // DoRemoveFirst methods and check that links are as expected.
56 // - Create TDeltaQueBase based object, insert links using DoAddDelta method,
57 // check the return value of CountDown is as expected. Delete links using
58 // DoRemoveFirst method and check the return value of CountDown is as expected.
59 // - Create TDblQue based object, insert links at front and last, call IsHead,
60 // IsFirst, IsLast, First and Last methods.
61 // - Create TDblQue object, check list for empty before inserting, after
62 // inserting, before/after Deque, before/after Enque, after Reset.
63 // Verify that results are as expected.
64 // - Create TDblQue based object with offset constructor, insert links at
65 // specified locations and check it is added as specified.
66 // - Create TDblQue based object, insert links using AddFirst and AddLast and
67 // check the links are as expected.
68 // - Create TDblQue based object, insert links using AddFirst and AddLast and
69 // check the result of the IsHead, IsFirst and IsLast methods are as expected.
70 // - Create TDblQue based object, insert links using AddFirst and AddLast, check
71 // the results are as expected.
72 // - Create TPriQueLink list without offset, with different offset, check the
73 // construction is as expected.
74 // - Create TPriQueLink list and insert many links at different specified location
75 // and check it is added as specified.
76 // - Create TPriQueLink link with different priorities, insert the elements in
77 // priority order and check that they are added as expected.
78 // - Create TPriQueLink list, check the double linked list for empty before
79 // inserting, after inserting, before/after Deque, before/after Enque, after Reset.
80 // Verify that results are as expected.
81 // - Create TPriQueLink list with different offset, get the list offset and check it
83 // - Create TPriQueLink list, insert many links with different priorities check it is
85 // - Create TDeltaQueLink list, add ,remove links and check the links and check
87 // - Create TDeltaQueLink list and insert many links at different specified location
88 // and check it is added as specified.
89 // - Create TDeltaQueLink list, check the double linked list for empty before, after
90 // inserting, before Deque, after Enque, Reset method call is as expected.
91 // - Create TDeltaQueLink list, insert links using DoAddDelta method,check that
92 // links are as expected. Delete links using DoRemove and DoRemoveFirst methods
93 // and check that links are as expected.
94 // - Create TDeltaQueLink based object, insert links using DoAddDelta method,
95 // check the return value of CountDown is as expected. Delete links using
96 // DoRemoveFirst method and check the return value of CountDown is as expected.
97 // - Create TDeltaQueLink list with different offset, get and check the offset is
99 // - Create TDeltaQueLink list, add, remove links at different specified location
100 // and check it is added and removed successfully.
101 // - Initialaize TDblQueIterBase based iterator, get the current item in the queue,
102 // move the current position forward, backward, set the iterator to point to the
103 // first element, last item and check it is as expected.
104 // - Create TDblQueIterBase object with offset constructor, insert links at
105 // specified locations and check it is added as specified.
106 // - Create TDblQueIterBase object, iterate the list using operators, DoPostInc,
107 // DoPostDec, DoCurrent and check it is as expected.
108 // - Create TDblQue based link with specified offset, initialize TDblQueIter
109 // based iterator, iterate the link and check the offset is as expected.
110 // - Create TDblQueIter object with offset constructor, insert links at
111 // specified locations and check it is added as specified.
112 // - Create TDblQueIter object, iterate the list using operators, DoPostInc,
113 // DoPostDec, DoCurrent and check it is as expected.
114 // - Create TDblQueIter based object, insert links using AddFirst and SetToLast,
115 // using IsHead, check the results are as expected.
116 // Platforms/Drives/Compatibility:
118 // Assumptions/Requirement/Pre-requisites:
119 // Failures and causes:
120 // Base Port information:
126 LOCAL_D RTest test(_L("T_QUE"));
129 #pragma warning(disable : 4710) //fuction not expanded
133 #define MAX_OFFSET 10
138 TInt iSpace[MAX_OFFSET]; // Reserve some space
141 class CItem : public CBase
145 //int iSpac[MAX_OFFSET]; // Reserve some space
152 void TestQueLinkBase(); // Calls Test: 1.
153 void TestQueLink(); // Calls Test: 1,2.
154 void Test1(); // Test Enque
155 void Test2(); // Test Deque
157 void CreateObjects(TInt aBaseLink);
158 void DestroyObjects();
165 void TestTQueLink<T>::CallTest1()
167 test.Start(_L("Test Enque"));
172 void TestTQueLink<T>::CreateObjects(TInt aBaseLink)
178 if (aBaseLink>=0&&aBaseLink<SIZE)
179 (iLink[aBaseLink])->iNext=(iLink[aBaseLink])->iPrev=iLink[aBaseLink];
183 void TestTQueLink<T>::DestroyObjects()
192 void TestTQueLink<T>::TestQueLinkBase()
195 test.Next(_L("Finished"));
200 void TestTQueLink<T>::TestQueLink()
203 test.Next(_L("Text Deque"));
205 test.Next(_L("Finished"));
210 void TestTQueLink<T>::Test1()
213 test.Start(_L("Check Next and Prev pointers set corectly."));
214 iLink[2]->Enque(iLink[1]);
215 test(iLink[1]->iPrev==iLink[2]);
216 test(iLink[1]->iNext==iLink[2]);
217 test(iLink[2]->iPrev==iLink[1]);
218 test(iLink[2]->iNext==iLink[1]);
219 iLink[3]->Enque(iLink[2]);
220 test(iLink[1]->iPrev==iLink[3]);
221 test(iLink[1]->iNext==iLink[2]);
222 test(iLink[2]->iPrev==iLink[1]);
223 test(iLink[2]->iNext==iLink[3]);
224 test(iLink[3]->iPrev==iLink[2]);
225 test(iLink[3]->iNext==iLink[1]);
226 iLink[4]->Enque(iLink[3]);
227 test(iLink[1]->iPrev==iLink[4]);
228 test(iLink[1]->iNext==iLink[2]);
229 test(iLink[2]->iPrev==iLink[1]);
230 test(iLink[2]->iNext==iLink[3]);
231 test(iLink[3]->iPrev==iLink[2]);
232 test(iLink[3]->iNext==iLink[4]);
233 test(iLink[4]->iPrev==iLink[3]);
234 test(iLink[4]->iNext==iLink[1]);
235 iLink[5]->Enque(iLink[2]);
236 test(iLink[1]->iPrev==iLink[4]);
237 test(iLink[1]->iNext==iLink[2]);
238 test(iLink[2]->iPrev==iLink[1]);
239 test(iLink[2]->iNext==iLink[5]);
240 test(iLink[5]->iPrev==iLink[2]);
241 test(iLink[5]->iNext==iLink[3]);
242 test(iLink[3]->iPrev==iLink[5]);
243 test(iLink[3]->iNext==iLink[4]);
244 test(iLink[4]->iPrev==iLink[3]);
245 test(iLink[4]->iNext==iLink[1]);
246 test.Next(_L("Finished"));
252 void TestTQueLink<T>::Test2()
255 test.Start(_L("Check Next and Prev pointers set corectly"));
256 iLink[2]->Enque(iLink[1]);
257 iLink[3]->Enque(iLink[2]);
258 iLink[4]->Enque(iLink[3]);
259 iLink[5]->Enque(iLink[4]);
261 iLink[5]->Enque(iLink[2]);
262 test(iLink[1]->iPrev==iLink[4]);
263 test(iLink[1]->iNext==iLink[2]);
264 test(iLink[2]->iPrev==iLink[1]);
265 test(iLink[2]->iNext==iLink[5]);
266 test(iLink[5]->iPrev==iLink[2]);
267 test(iLink[5]->iNext==iLink[3]);
268 test(iLink[3]->iPrev==iLink[5]);
269 test(iLink[3]->iNext==iLink[4]);
270 test(iLink[4]->iPrev==iLink[3]);
271 test(iLink[4]->iNext==iLink[1]);
273 test(iLink[1]->iPrev==iLink[4]);
274 test(iLink[1]->iNext==iLink[2]);
275 test(iLink[2]->iPrev==iLink[1]);
276 test(iLink[2]->iNext==iLink[5]);
277 test(iLink[5]->iPrev==iLink[2]);
278 test(iLink[5]->iNext==iLink[4]);
279 test(iLink[4]->iPrev==iLink[5]);
280 test(iLink[4]->iNext==iLink[1]);
282 test(iLink[2]->iPrev==iLink[4]);
283 test(iLink[2]->iNext==iLink[5]);
284 test(iLink[5]->iPrev==iLink[2]);
285 test(iLink[5]->iNext==iLink[4]);
286 test(iLink[4]->iPrev==iLink[5]);
287 test(iLink[4]->iNext==iLink[2]);
289 test(iLink[2]->iPrev==iLink[5]);
290 test(iLink[2]->iNext==iLink[5]);
291 test(iLink[5]->iPrev==iLink[2]);
292 test(iLink[5]->iNext==iLink[2]);
293 test.Next(_L("Finished"));
298 class VDblQueBase : public TDblQueBase
302 VDblQueBase(TInt anOffset);
303 inline void sDoAddFirst(TAny* aPtr) {DoAddFirst(aPtr);}
304 inline void sDoAddLast(TAny* aPtr) {DoAddLast(aPtr);}
305 inline void sDoAddPriority(TAny* aPtr) {DoAddPriority(aPtr);}
306 inline void sTestEmpty() const {__DbgTestEmpty();}
313 class VDeltaQueBase : public TDeltaQueBase
317 VDeltaQueBase(TInt anOffset);
318 inline void sDoAddDelta(TAny* aPtr,TInt aDelta) {DoAddDelta(aPtr,aDelta);} //From TDeltaQueBase
319 inline void sDoRemove(TAny* aPtr) {this->DoRemove(aPtr);}
320 inline TAny* sDoRemoveFirst() {return this->DoRemoveFirst();}
322 inline void sDoAddFirst(TAny* aPtr) {DoAddFirst(aPtr);} //From TDblQueBase
323 inline void sDoAddLast(TAny* aPtr) {DoAddLast(aPtr);}
324 inline void sDoAddPriority(TAny* aPtr) {DoAddPriority(aPtr);}
332 class VDblQue : public TDblQue<T>
336 VDblQue(TInt anOffset);
337 /*inline void sDoAddDelta(TAny* aPtr,TInt aDelta) {DoAddDelta(aPtr,aDelta);} //From TDeltaQueBase
338 inline void sDoRemove(TAny* aPtr) {this->DoRemove(aPtr);}
339 inline TAny* sDoRemoveFirst() {return this->DoRemoveFirst();}
340 TInt** sFirstDelta;*/
341 inline void sDoAddFirst(TAny* aPtr) {this->DoAddFirst(aPtr);} //From TDblQueBase
342 inline void sDoAddLast(TAny* aPtr) {this->DoAddLast(aPtr);}
343 inline void sDoAddPriority(TAny* aPtr) {this->DoAddPriority(aPtr);}
351 class VPriQue : public TPriQue<T>
355 VPriQue(TInt anOffset);
356 /*inline void sDoAddDelta(TAny* aPtr,TInt aDelta) {DoAddDelta(aPtr,aDelta);} //From TDeltaQueBase
357 inline void sDoRemove(TAny* aPtr) {this->DoRemove(aPtr);}
358 inline TAny* sDoRemoveFirst() {return this->DoRemoveFirst();}
359 TInt** sFirstDelta;*/
360 inline void sDoAddFirst(TAny* aPtr) {this->DoAddFirst(aPtr);} //From TDblQueBase
361 inline void sDoAddLast(TAny* aPtr) {this->DoAddLast(aPtr);}
362 inline void sDoAddPriority(TAny* aPtr) {this->DoAddPriority(aPtr);}
370 class VDeltaQue : public TDeltaQue<T>
374 VDeltaQue(TInt anOffset);
375 inline void sDoAddDelta(TAny* aPtr,TInt aDelta) {this->DoAddDelta(aPtr,aDelta);} //From TDeltaQueBase
376 inline void sDoRemove(TAny* aPtr) {this->DoRemove(aPtr);}
377 inline TAny* sDoRemoveFirst() {return this->DoRemoveFirst();}
379 inline void sDoAddFirst(TAny* aPtr) {this->DoAddFirst(aPtr);} //From TDblQueBase
380 inline void sDoAddLast(TAny* aPtr) {this->DoAddLast(aPtr);}
381 inline void sDoAddPriority(TAny* aPtr) {this->DoAddPriority(aPtr);}
388 VDblQueBase::VDblQueBase()
393 VDblQueBase::VDblQueBase(TInt anOffset)
394 :TDblQueBase(anOffset)
399 void VDblQueBase::SetMembers()
405 VDeltaQueBase::VDeltaQueBase()
410 VDeltaQueBase::VDeltaQueBase(TInt anOffset)
411 :TDeltaQueBase(anOffset)
416 void VDeltaQueBase::SetMembers()
418 sFirstDelta=&iFirstDelta;
424 VDblQue<T>::VDblQue()
430 VDblQue<T>::VDblQue(TInt anOffset)
431 :TDblQue<T>(anOffset)
437 void VDblQue<T>::SetMembers()
439 //sFirstDelta=&iFirstDelta;
441 sOffset=&this->iOffset;
445 VPriQue<T>::VPriQue()
451 VPriQue<T>::VPriQue(TInt anOffset)
452 :TPriQue<T>(anOffset)
458 void VPriQue<T>::SetMembers()
460 //sFirstDelta=&iFirstDelta;
462 sOffset=&this->iOffset;
466 VDeltaQue<T>::VDeltaQue()
472 VDeltaQue<T>::VDeltaQue(TInt anOffset)
473 :TDeltaQue<T>(anOffset)
479 void VDeltaQue<T>::SetMembers()
481 sFirstDelta=&this->iFirstDelta;
483 sOffset=&this->iOffset;
489 friend class TestTQueLink<TDblQueLinkBase>;
492 void TestDeltaBase();
496 void Test1(); // All functions //TDblQueBase functions
497 void Test2(); // Constructors
498 void Test3(TBool aTestPri); // DoAdd's
499 void Test4(); // Public functions
500 void Test5(); // All functions //TDblDeltaQueBase
501 void Test6(); // Constructors
502 void Test7(); // Do's
503 void Test8(); // CountDown
504 void Test9(); // All functions //TDblQueBase
505 void Test10(); // Constructors
506 void Test11(); // Add's
507 void Test12(); // Is's
508 void Test13(); // Get's
509 void Test14(); // All functions //TPriQue
510 void Test15(); // Constructors
511 void Test16(); // Add
512 void Test17(); // All functions //TDeltaQue
513 void Test18(); // Constructors
514 void Test19(); // Add/Remove
516 void CallTest3_4(TBool aTestPri);
521 void TestTQue<T>::CallTest3_4(TBool aTestPri)
523 test.Next(_L("Test DoAdd's"));
525 test.Next(_L("Test public functions"));
530 void TestTQue<T>::CallTest7_8()
532 test.Next(_L("Test Do's"));
534 test.Next(_L("CountDown"));
539 void TestTQue<T>::TestQueBase()
541 test.Start(_L("Test all member functions (simply)"));
543 test.Next(_L("Test Constructors"));
546 test.Next(_L("Finished"));
551 void TestTQue<T>::TestDeltaBase()
553 test.Start(_L("Test all member functions (simply)"));
556 test.Next(_L("Test Constructors"));
559 test.Next(_L("Finished"));
564 void TestTQue<T>::TestDblQue()
566 test.Start(_L("Test all member functions (simply)"));
569 test.Next(_L("Test Constructor"));
571 test.Next(_L("Test Add's"));
573 test.Next(_L("Test Is's"));
575 test.Next(_L("Get's"));
577 test.Next(_L("Finished"));
582 void TestTQue<T>::TestPriQue()
584 test.Start(_L("Test all member functions (simply)"));
587 test.Next(_L("Test Constructor"));
589 test.Next(_L("Test Add"));
591 test.Next(_L("Finished"));
596 void TestTQue<T>::TestDeltaQue()
598 test.Start(_L("Test all member functions (simply)"));
602 test.Next(_L("Test Constructor"));
604 test.Next(_L("Test Add/Removes"));
606 test.Next(_L("Finished"));
611 void TestTQue<T>::Test1()
614 TPriQueLink link1,link2;
617 test.Start(_L("Constructors"));
618 que=new VDblQueBase(offset);
622 test.Next(_L("DoAdd's"));
623 que->sDoAddFirst(&link1);
625 que->sDoAddLast(&link1);
628 que->sDoAddPriority(&link2);
629 test.Next(_L("Public"));
631 que->SetOffset(offset);
633 test.Next(_L("Finished"));
639 void TestTQue<T>::Test2()
644 test.Start(_L("Default constructor"));
645 que=new VDblQueBase();
646 test(*(que->sOffset)==0);
647 test(que->sHead->iNext==que->sHead);
648 test(que->sHead->iPrev==que->sHead);
650 test.Next(_L("Offset constructor"));
651 for (offset=0;offset<40;offset+=4)
653 que=new VDblQueBase(offset);
654 test(*(que->sOffset)==offset);
655 test(que->sHead->iNext==que->sHead);
656 test(que->sHead->iPrev==que->sHead);
659 test.Next(_L("Finished"));
664 void TestTQue<T>::Test3(TBool aTestPri)
667 TDblQueLink link1,link2,link3,link4;
669 test.Start(_L("AddFirst"));
671 que->sDoAddFirst(&link1);
672 test(que->sHead->iNext==&link1);
673 test(que->sHead->iPrev==&link1);
674 test(link1.iNext==que->sHead);
675 test(link1.iPrev==que->sHead);
676 que->sDoAddFirst(&link2);
677 test(que->sHead->iNext==&link2);
678 test(que->sHead->iPrev==&link1);
679 test(link1.iNext==que->sHead);
680 test(link1.iPrev==&link2);
681 test(link2.iNext==&link1);
682 test(link2.iPrev==que->sHead);
683 que->sDoAddFirst(&link3);
684 test(que->sHead->iNext==&link3);
685 test(que->sHead->iPrev==&link1);
686 test(link1.iNext==que->sHead);
687 test(link1.iPrev==&link2);
688 test(link2.iNext==&link1);
689 test(link2.iPrev==&link3);
690 test(link3.iNext==&link2);
691 test(link3.iPrev==que->sHead);
692 que->sDoAddFirst(&link4);
693 test(que->sHead->iNext==&link4);
694 test(que->sHead->iPrev==&link1);
695 test(link1.iNext==que->sHead);
696 test(link1.iPrev==&link2);
697 test(link2.iNext==&link1);
698 test(link2.iPrev==&link3);
699 test(link3.iNext==&link2);
700 test(link3.iPrev==&link4);
701 test(link4.iNext==&link3);
702 test(link4.iPrev==que->sHead);
708 test.Next(_L("AddLast"));
710 que->sDoAddLast(&link1);
711 test(que->sHead->iNext==&link1);
712 test(que->sHead->iPrev==&link1);
713 test(link1.iNext==que->sHead);
714 test(link1.iPrev==que->sHead);
715 que->sDoAddLast(&link2);
716 test(que->sHead->iNext==&link1);
717 test(que->sHead->iPrev==&link2);
718 test(link1.iNext==&link2);
719 test(link1.iPrev==que->sHead);
720 test(link2.iNext==que->sHead);
721 test(link2.iPrev==&link1);
722 que->sDoAddLast(&link3);
723 test(que->sHead->iNext==&link1);
724 test(que->sHead->iPrev==&link3);
725 test(link1.iNext==&link2);
726 test(link1.iPrev==que->sHead);
727 test(link2.iNext==&link3);
728 test(link2.iPrev==&link1);
729 test(link3.iNext==que->sHead);
730 test(link3.iPrev==&link2);
731 que->sDoAddLast(&link4);
732 test(que->sHead->iNext==&link1);
733 test(que->sHead->iPrev==&link4);
734 test(link1.iNext==&link2);
735 test(link1.iPrev==que->sHead);
736 test(link2.iNext==&link3);
737 test(link2.iPrev==&link1);
738 test(link3.iNext==&link4);
739 test(link3.iPrev==&link2);
740 test(link4.iNext==que->sHead);
741 test(link4.iPrev==&link3);
747 test.Next(_L("Combined AddFirst and AddLast"));
749 que->sDoAddFirst(&link1);
750 que->sDoAddLast(&link2);
751 test(que->sHead->iNext==&link1);
752 test(que->sHead->iPrev==&link2);
753 test(link1.iNext==&link2);
754 test(link1.iPrev==que->sHead);
755 test(link2.iNext==que->sHead);
756 test(link2.iPrev==&link1);
757 que->sDoAddFirst(&link3);
758 test(que->sHead->iNext==&link3);
759 test(que->sHead->iPrev==&link2);
760 test(link1.iNext==&link2);
761 test(link1.iPrev==&link3);
762 test(link2.iNext==que->sHead);
763 test(link2.iPrev==&link1);
764 test(link3.iNext==&link1);
765 test(link3.iPrev==que->sHead);
766 que->sDoAddLast(&link4);
767 test(que->sHead->iNext==&link3);
768 test(que->sHead->iPrev==&link4);
769 test(link1.iNext==&link2);
770 test(link1.iPrev==&link3);
771 test(link2.iNext==&link4);
772 test(link2.iPrev==&link1);
773 test(link3.iNext==&link1);
774 test(link3.iPrev==que->sHead);
775 test(link4.iNext==que->sHead);
776 test(link4.iPrev==&link2);
784 TPriQueLink link5,link6,link7,link8,link9,link10;
786 test.Next(_L("AddPriority"));
791 que->sDoAddPriority(&link5);
792 que->sDoAddPriority(&link6);
793 que->sDoAddPriority(&link7);
794 test(que->sHead->iNext==&link7);
795 test(que->sHead->iPrev==&link5);
796 test(link5.iNext==que->sHead);
797 test(link5.iPrev==&link6);
798 test(link6.iNext==&link5);
799 test(link6.iPrev==&link7);
800 test(link7.iNext==&link6);
801 test(link7.iPrev==que->sHead);
803 que->sDoAddPriority(&link8);
804 test(que->sHead->iNext==&link7);
805 test(que->sHead->iPrev==&link5);
806 test(link5.iNext==que->sHead);
807 test(link5.iPrev==&link6);
808 test(link6.iNext==&link5);
809 test(link6.iPrev==&link8);
810 test(link7.iNext==&link8);
811 test(link7.iPrev==que->sHead);
812 test(link8.iPrev==&link7);
813 test(link8.iNext==&link6);
815 que->sDoAddPriority(&link9);
816 test(que->sHead->iNext==&link7);
817 test(que->sHead->iPrev==&link5);
818 test(link5.iNext==que->sHead);
819 test(link5.iPrev==&link9);
820 test(link6.iNext==&link9);
821 test(link6.iPrev==&link8);
822 test(link7.iNext==&link8);
823 test(link7.iPrev==que->sHead);
824 test(link8.iPrev==&link7);
825 test(link8.iNext==&link6);
826 test(link9.iPrev==&link6);
827 test(link9.iNext==&link5);
829 que->sDoAddPriority(&link10);
830 test(que->sHead->iNext==&link7);
831 test(que->sHead->iPrev==&link10);
832 test(link5.iNext==&link10);
833 test(link5.iPrev==&link9);
834 test(link6.iNext==&link9);
835 test(link6.iPrev==&link8);
836 test(link7.iNext==&link8);
837 test(link7.iPrev==que->sHead);
838 test(link8.iPrev==&link7);
839 test(link8.iNext==&link6);
840 test(link9.iPrev==&link6);
841 test(link9.iNext==&link5);
842 test(link10.iNext==que->sHead);
843 test(link10.iPrev==&link5);
850 test.Next(_L("Finished"));
855 void TestTQue<T>::Test4()
860 test.Start(_L("IsEmpty"));
862 test(que->IsEmpty()==TRUE);
863 TDblQueLink link1,link2;
864 que->sDoAddFirst(&link1);
865 test(que->IsEmpty()==FALSE);
867 test(que->IsEmpty()==TRUE);
868 que->sDoAddLast(&link2);
869 test(que->IsEmpty()==FALSE);
871 test(que->IsEmpty()==FALSE);
873 test(que->IsEmpty()==FALSE);
875 test(que->IsEmpty()==TRUE);
876 test.Next(_L("Reset"));
877 que->sDoAddFirst(&link1);
878 test(que->IsEmpty()==FALSE);
880 test(que->IsEmpty()==TRUE);
881 test.Next(_L("SetOffset"));
882 for (offset=0;offset<40;offset+=4)
884 que->SetOffset(offset);
885 test(*(que->sOffset)==offset);
887 test.Next(_L("Finished"));
893 void TestTQue<T>::Test5()
896 TDeltaQueLink link1,link2,link3;
899 test.Start(_L("Constructors"));
900 que=new VDeltaQueBase(offset);
902 que=new VDeltaQueBase;
903 test.Next(_L("Do's"));
904 que->sDoAddDelta(&link1,3);
905 que->sDoAddDelta(&link2,2);
906 que->sDoAddDelta(&link3,0);
907 que->sDoRemoveFirst();
908 que->sDoRemove(&link2);
909 test.Next(_L("CountDown"));
911 test.Next(_L("Finished"));
917 void TestTQue<T>::Test6()
922 test.Start(_L("Default constructor"));
923 que=new VDeltaQueBase();
924 test(*(que->sFirstDelta)==NULL);
926 test.Next(_L("Offset constructor"));
927 for (offset=0;offset<40;offset+=4)
929 que=new VDeltaQueBase(offset);
930 test(*(que->sOffset)==offset);
931 test(*(que->sFirstDelta)==NULL);
934 test.Next(_L("Finished"));
939 void TestTQue<T>::Test7()
942 TDeltaQueLink link1,link2,link3,link4,link5,link6;
944 test.Start(_L("DoAddDelta"));
946 que->sDoAddDelta(&link2,3);
947 test(*(que->sFirstDelta)==&link2.iDelta);
948 test(link2.iDelta==3);
949 que->sDoAddDelta(&link5,15);
950 test(*(que->sFirstDelta)==&link2.iDelta);
951 test(link2.iDelta==3);
952 test(link5.iDelta==12);
953 que->sDoAddDelta(&link3,6);
954 test(*(que->sFirstDelta)==&link2.iDelta);
955 test(link2.iDelta==3);
956 test(link3.iDelta==3);
957 test(link5.iDelta==9);
958 que->sDoAddDelta(&link4,10);
959 test(*(que->sFirstDelta)==&link2.iDelta);
960 test(link2.iDelta==3);
961 test(link3.iDelta==3);
962 test(link4.iDelta==4);
963 test(link5.iDelta==5);
964 que->sDoAddDelta(&link1,1);
965 test(*(que->sFirstDelta)==&link1.iDelta);
966 test(link1.iDelta==1);
967 test(link2.iDelta==2);
968 test(link3.iDelta==3);
969 test(link4.iDelta==4);
970 test(link5.iDelta==5);
971 que->sDoAddDelta(&link6,21);
972 test(*(que->sFirstDelta)==&link1.iDelta);
973 test(link1.iDelta==1);
974 test(link2.iDelta==2);
975 test(link3.iDelta==3);
976 test(link4.iDelta==4);
977 test(link5.iDelta==5);
978 test(link6.iDelta==6);
979 test.Next(_L("DoRemove"));
980 que->sDoRemove(&link6);
981 test(*(que->sFirstDelta)==&link1.iDelta);
982 test(link1.iDelta==1);
983 test(link2.iDelta==2);
984 test(link3.iDelta==3);
985 test(link4.iDelta==4);
986 test(link5.iDelta==5);
987 que->sDoRemove(&link1);
988 test(*(que->sFirstDelta)==&link2.iDelta);
989 test(link2.iDelta==3);
990 test(link3.iDelta==3);
991 test(link4.iDelta==4);
992 test(link5.iDelta==5);
993 que->sDoRemove(&link4);
994 test(*(que->sFirstDelta)==&link2.iDelta);
995 test(link2.iDelta==3);
996 test(link3.iDelta==3);
997 test(link5.iDelta==9);
998 que->sDoRemove(&link3);
999 test(*(que->sFirstDelta)==&link2.iDelta);
1000 test(link2.iDelta==3);
1001 test(link5.iDelta==12);
1002 que->sDoRemove(&link5);
1003 test(*(que->sFirstDelta)==&link2.iDelta);
1004 test(link2.iDelta==3);
1005 test.Next(_L("DoRemoveFirst"));
1006 test(NULL==que->sDoRemoveFirst());
1007 test(*(que->sFirstDelta)==&link2.iDelta);
1008 test(link2.iDelta==3);
1010 test(NULL==que->sDoRemoveFirst());
1011 test(*(que->sFirstDelta)==&link2.iDelta);
1012 test(link2.iDelta==1);
1014 test(&link2==que->sDoRemoveFirst());
1016 test.Next(_L("Finished"));
1021 void TestTQue<T>::Test8()
1024 TDeltaQueLink link1,link2,link3;
1027 que->sDoAddDelta(&link1,1);
1028 que->sDoAddDelta(&link2,3);
1029 que->sDoAddDelta(&link3,6);
1030 test(que->CountDown()==TRUE);
1031 que->sDoRemoveFirst();
1032 test(que->CountDown()==FALSE);
1033 test(que->CountDown()==TRUE);
1034 que->sDoRemoveFirst();
1035 test(que->CountDown()==FALSE);
1036 test(que->CountDown()==FALSE);
1037 test(que->CountDown()==TRUE);
1038 que->sDoRemoveFirst();
1043 void TestTQue<T>::Test9()
1046 TDblQueLink link1,link2;
1049 test.Start(_L("Constructors"));
1050 que=new VDblQue<TDblQueLink>(offset);
1052 que=new VDblQue<TDblQueLink>;
1053 test.Next(_L("Add's"));
1054 que->AddFirst(link1);
1055 que->AddLast(link2);
1056 test.Next(_L("Is's"));
1057 que->IsHead(que->sHead);
1058 que->IsFirst(&link1);
1059 que->IsLast(&link2);
1060 test.Next(_L("Get's"));
1063 test.Next(_L("Finished"));
1069 void TestTQue<T>::Test10()
1074 test.Start(_L("Offset constructor"));
1075 for (offset=0;offset<40;offset+=4)
1077 que=new VDblQue<TDblQueLink>(offset);
1078 test(*(que->sOffset)==offset);
1081 test.Next(_L("Finished"));
1086 void TestTQue<T>::Test11()
1089 TDblQueLink link1,link2,link3,link4;
1091 test.Start(_L("AddFirst"));
1093 que->AddFirst(link1);
1094 test(que->sHead->iNext==&link1);
1095 test(que->sHead->iPrev==&link1);
1096 test(link1.iNext==que->sHead);
1097 test(link1.iPrev==que->sHead);
1098 que->AddFirst(link2);
1099 test(que->sHead->iNext==&link2);
1100 test(que->sHead->iPrev==&link1);
1101 test(link1.iNext==que->sHead);
1102 test(link1.iPrev==&link2);
1103 test(link2.iNext==&link1);
1104 test(link2.iPrev==que->sHead);
1105 que->AddFirst(link3);
1106 test(que->sHead->iNext==&link3);
1107 test(que->sHead->iPrev==&link1);
1108 test(link1.iNext==que->sHead);
1109 test(link1.iPrev==&link2);
1110 test(link2.iNext==&link1);
1111 test(link2.iPrev==&link3);
1112 test(link3.iNext==&link2);
1113 test(link3.iPrev==que->sHead);
1114 que->AddFirst(link4);
1115 test(que->sHead->iNext==&link4);
1116 test(que->sHead->iPrev==&link1);
1117 test(link1.iNext==que->sHead);
1118 test(link1.iPrev==&link2);
1119 test(link2.iNext==&link1);
1120 test(link2.iPrev==&link3);
1121 test(link3.iNext==&link2);
1122 test(link3.iPrev==&link4);
1123 test(link4.iNext==&link3);
1124 test(link4.iPrev==que->sHead);
1130 test.Next(_L("AddLast"));
1132 que->AddLast(link1);
1133 test(que->sHead->iNext==&link1);
1134 test(que->sHead->iPrev==&link1);
1135 test(link1.iNext==que->sHead);
1136 test(link1.iPrev==que->sHead);
1137 que->AddLast(link2);
1138 test(que->sHead->iNext==&link1);
1139 test(que->sHead->iPrev==&link2);
1140 test(link1.iNext==&link2);
1141 test(link1.iPrev==que->sHead);
1142 test(link2.iNext==que->sHead);
1143 test(link2.iPrev==&link1);
1144 que->AddLast(link3);
1145 test(que->sHead->iNext==&link1);
1146 test(que->sHead->iPrev==&link3);
1147 test(link1.iNext==&link2);
1148 test(link1.iPrev==que->sHead);
1149 test(link2.iNext==&link3);
1150 test(link2.iPrev==&link1);
1151 test(link3.iNext==que->sHead);
1152 test(link3.iPrev==&link2);
1153 que->AddLast(link4);
1154 test(que->sHead->iNext==&link1);
1155 test(que->sHead->iPrev==&link4);
1156 test(link1.iNext==&link2);
1157 test(link1.iPrev==que->sHead);
1158 test(link2.iNext==&link3);
1159 test(link2.iPrev==&link1);
1160 test(link3.iNext==&link4);
1161 test(link3.iPrev==&link2);
1162 test(link4.iNext==que->sHead);
1163 test(link4.iPrev==&link3);
1169 test.Next(_L("Combined AddFirst and AddLast"));
1171 que->AddFirst(link1);
1172 que->AddLast(link2);
1173 test(que->sHead->iNext==&link1);
1174 test(que->sHead->iPrev==&link2);
1175 test(link1.iNext==&link2);
1176 test(link1.iPrev==que->sHead);
1177 test(link2.iNext==que->sHead);
1178 test(link2.iPrev==&link1);
1179 que->AddFirst(link3);
1180 test(que->sHead->iNext==&link3);
1181 test(que->sHead->iPrev==&link2);
1182 test(link1.iNext==&link2);
1183 test(link1.iPrev==&link3);
1184 test(link2.iNext==que->sHead);
1185 test(link2.iPrev==&link1);
1186 test(link3.iNext==&link1);
1187 test(link3.iPrev==que->sHead);
1188 que->AddLast(link4);
1189 test(que->sHead->iNext==&link3);
1190 test(que->sHead->iPrev==&link4);
1191 test(link1.iNext==&link2);
1192 test(link1.iPrev==&link3);
1193 test(link2.iNext==&link4);
1194 test(link2.iPrev==&link1);
1195 test(link3.iNext==&link1);
1196 test(link3.iPrev==que->sHead);
1197 test(link4.iNext==que->sHead);
1198 test(link4.iPrev==&link2);
1204 test.Next(_L("Finished"));
1209 void TestTQue<T>::Test12()
1212 TDblQueLink link1,link2,link3,link4,*head;
1215 que->AddFirst(link1);
1216 que->AddLast(link2);
1217 que->AddLast(link3);
1218 que->AddLast(link4);
1220 test.Start(_L("IsHead"));
1221 test(que->IsHead(head)==TRUE);
1222 test(que->IsHead(&link1)==FALSE);
1223 test(que->IsHead(&link2)==FALSE);
1224 test(que->IsHead(&link3)==FALSE);
1225 test(que->IsHead(&link4)==FALSE);
1226 test.Next(_L("IsFirst"));
1227 test(que->IsFirst(head)==FALSE);
1228 test(que->IsFirst(&link1)==TRUE);
1229 test(que->IsFirst(&link2)==FALSE);
1230 test(que->IsFirst(&link3)==FALSE);
1231 test(que->IsFirst(&link4)==FALSE);
1232 test.Next(_L("IsLast"));
1233 test(que->IsLast(head)==FALSE);
1234 test(que->IsLast(&link1)==FALSE);
1235 test(que->IsLast(&link2)==FALSE);
1236 test(que->IsLast(&link3)==FALSE);
1237 test(que->IsLast(&link4)==TRUE);
1239 test.Next(_L("Finished"));
1244 void TestTQue<T>::Test13()
1247 TDblQueLink link1,link2,link3,link4;
1249 test.Start(_L("First"));
1251 que->AddFirst(link1);
1252 test(que->First()==&link1);
1253 que->AddFirst(link2);
1254 test(que->First()==&link2);
1255 que->AddFirst(link3);
1256 test(que->First()==&link3);
1257 que->AddFirst(link4);
1258 test(que->First()==&link4);
1264 test.Next(_L("Last"));
1266 que->AddLast(link1);
1267 test(que->Last()==&link1);
1268 que->AddLast(link2);
1269 test(que->Last()==&link2);
1270 que->AddLast(link3);
1271 test(que->Last()==&link3);
1272 que->AddLast(link4);
1273 test(que->Last()==&link4);
1279 test.Next(_L("Finished"));
1284 void TestTQue<T>::Test14()
1290 test.Start(_L("Constructors"));
1291 que=new VPriQue<TPriQueLink>(offset);
1293 que=new VPriQue<TPriQueLink>;
1294 test.Next(_L("Add"));
1296 test.Next(_L("Finished"));
1302 void TestTQue<T>::Test15()
1307 test.Start(_L("Offset constructor"));
1308 for (offset=0;offset<40;offset+=4)
1310 que=new VPriQue<TPriQueLink>(offset);
1311 test(*(que->sOffset)==offset);
1314 test.Next(_L("Finished"));
1319 void TestTQue<T>::Test16()
1322 TPriQueLink link1,link2,link3,link4,link5,link6;
1328 que->sDoAddPriority(&link1);
1329 que->sDoAddPriority(&link2);
1330 que->sDoAddPriority(&link3);
1331 test(que->sHead->iNext==&link2);
1332 test(que->sHead->iPrev==&link3);
1333 test(link1.iNext==&link3);
1334 test(link1.iPrev==&link2);
1335 test(link2.iNext==&link1);
1336 test(link2.iPrev==que->sHead);
1337 test(link3.iNext==que->sHead);
1338 test(link3.iPrev==&link1);
1340 que->sDoAddPriority(&link4);
1341 test(que->sHead->iNext==&link2);
1342 test(que->sHead->iPrev==&link3);
1343 test(link1.iNext==&link4);
1344 test(link1.iPrev==&link2);
1345 test(link2.iNext==&link1);
1346 test(link2.iPrev==que->sHead);
1347 test(link3.iNext==que->sHead);
1348 test(link3.iPrev==&link4);
1349 test(link4.iNext==&link3);
1350 test(link4.iPrev==&link1);
1352 que->sDoAddPriority(&link5);
1353 test(que->sHead->iNext==&link2);
1354 test(que->sHead->iPrev==&link3);
1355 test(link1.iNext==&link4);
1356 test(link1.iPrev==&link5);
1357 test(link2.iNext==&link5);
1358 test(link2.iPrev==que->sHead);
1359 test(link3.iNext==que->sHead);
1360 test(link3.iPrev==&link4);
1361 test(link4.iNext==&link3);
1362 test(link4.iPrev==&link1);
1363 test(link5.iNext==&link1);
1364 test(link5.iPrev==&link2);
1366 que->sDoAddPriority(&link6);
1367 test(que->sHead->iNext==&link2);
1368 test(que->sHead->iPrev==&link6);
1369 test(link1.iNext==&link4);
1370 test(link1.iPrev==&link5);
1371 test(link2.iNext==&link5);
1372 test(link2.iPrev==que->sHead);
1373 test(link3.iNext==&link6);
1374 test(link3.iPrev==&link4);
1375 test(link4.iNext==&link3);
1376 test(link4.iPrev==&link1);
1377 test(link5.iNext==&link1);
1378 test(link5.iPrev==&link2);
1379 test(link6.iNext==que->sHead);
1380 test(link6.iPrev==&link3);
1385 void TestTQue<T>::Test17()
1388 TDeltaQueLink link1,link2;
1391 test.Start(_L("Constructors"));
1392 que=new VDeltaQue<TDeltaQueLink>(offset);
1394 que=new VDeltaQue<TDeltaQueLink>;
1395 test.Next(_L("Add/Remove"));
1400 test.Next(_L("Finished"));
1405 void TestTQue<T>::Test18()
1410 test.Start(_L("Offset constructor"));
1411 for (offset=0;offset<40;offset+=4)
1413 que=new VDeltaQue<TDeltaQueLink>(offset);
1414 test(*(que->sOffset)==offset);
1417 test.Next(_L("Finished"));
1422 void TestTQue<T>::Test19()
1425 TDeltaQueLink link1,link2,link3,link4,link5,link6;
1427 test.Start(_L("Add"));
1430 test(*(que->sFirstDelta)==&link2.iDelta);
1431 test(link2.iDelta==3);
1433 test(*(que->sFirstDelta)==&link2.iDelta);
1434 test(link2.iDelta==3);
1435 test(link5.iDelta==12);
1437 test(*(que->sFirstDelta)==&link2.iDelta);
1438 test(link2.iDelta==3);
1439 test(link3.iDelta==3);
1440 test(link5.iDelta==9);
1442 test(*(que->sFirstDelta)==&link2.iDelta);
1443 test(link2.iDelta==3);
1444 test(link3.iDelta==3);
1445 test(link4.iDelta==4);
1446 test(link5.iDelta==5);
1448 test(*(que->sFirstDelta)==&link1.iDelta);
1449 test(link1.iDelta==1);
1450 test(link2.iDelta==2);
1451 test(link3.iDelta==3);
1452 test(link4.iDelta==4);
1453 test(link5.iDelta==5);
1455 test(*(que->sFirstDelta)==&link1.iDelta);
1456 test(link1.iDelta==1);
1457 test(link2.iDelta==2);
1458 test(link3.iDelta==3);
1459 test(link4.iDelta==4);
1460 test(link5.iDelta==5);
1461 test(link6.iDelta==6);
1462 test.Next(_L("Remove"));
1464 test(*(que->sFirstDelta)==&link1.iDelta);
1465 test(link1.iDelta==1);
1466 test(link2.iDelta==2);
1467 test(link3.iDelta==3);
1468 test(link4.iDelta==4);
1469 test(link5.iDelta==5);
1471 test(*(que->sFirstDelta)==&link2.iDelta);
1472 test(link2.iDelta==3);
1473 test(link3.iDelta==3);
1474 test(link4.iDelta==4);
1475 test(link5.iDelta==5);
1477 test(*(que->sFirstDelta)==&link2.iDelta);
1478 test(link2.iDelta==3);
1479 test(link3.iDelta==3);
1480 test(link5.iDelta==9);
1482 test(*(que->sFirstDelta)==&link2.iDelta);
1483 test(link2.iDelta==3);
1484 test(link5.iDelta==12);
1486 test(*(que->sFirstDelta)==&link2.iDelta);
1487 test(link2.iDelta==3);
1488 test.Next(_L("RemoveFirst"));
1489 test(NULL==que->RemoveFirst());
1490 test(*(que->sFirstDelta)==&link2.iDelta);
1491 test(link2.iDelta==3);
1493 test(NULL==que->RemoveFirst());
1494 test(*(que->sFirstDelta)==&link2.iDelta);
1495 test(link2.iDelta==1);
1497 test(&link2==que->RemoveFirst());
1498 test.Next(_L("Finished"));
1503 class VDblQueIterBase : public TDblQueIterBase
1506 VDblQueIterBase(TDblQueBase& aQue);
1507 inline TAny* sDoPostInc() {return DoPostInc();}
1508 inline TAny* sDoPostDec() {return DoPostDec();}
1509 inline TAny* sDoCurrent() {return DoCurrent();}
1511 TDblQueLinkBase** sHead;
1512 TDblQueLinkBase** sNext;
1518 class VDblQueIter : public TDblQueIter<T>
1521 VDblQueIter(TDblQueBase& aQue);
1522 inline TAny* sDoPostInc() {return this->DoPostInc();}
1523 inline TAny* sDoPostDec() {return this->DoPostDec();}
1524 inline TAny* sDoCurrent() {return this->DoCurrent();}
1526 TDblQueLinkBase** sHead;
1527 TDblQueLinkBase** sNext;
1532 VDblQueIterBase::VDblQueIterBase(TDblQueBase& aQue)
1533 :TDblQueIterBase(aQue)
1538 void VDblQueIterBase::SetMember()
1546 VDblQueIter<T>::VDblQueIter(TDblQueBase& aQue)
1547 :TDblQueIter<T>(aQue)
1553 void VDblQueIter<T>::SetMember()
1555 sOffset=&this->iOffset;
1564 void TestIterBase();
1566 void Test1(); //All functions //TDblQueIterBase
1567 void Test2(); //Constructors
1568 void Test3(); //Do's
1570 void Test5(); //All functions //TDblQueIter
1572 //void Test6(); //Constructors //Redundant
1573 void Test7(); //Iterators
1579 void TestTQueIter<T>::CallTest2_4()
1581 test.Next(_L("Constructors"));
1583 test.Next(_L("Do's"));
1585 test.Next(_L("Sets"));
1590 void TestTQueIter<T>::TestIterBase()
1592 test.Start(_L("All Methods"));
1595 test.Next(_L("Finished"));
1600 void TestTQueIter<T>::TestQueIter()
1602 test.Start(_L("All Methods"));
1605 test.Next(_L("One item in queue"));
1607 test.Next(_L("Iterators"));
1609 test.Next(_L("Finished"));
1614 void TestTQueIter<T>::Test1()
1620 que.AddFirst(item2);
1621 que.AddFirst(item1);
1622 test.Start(_L("Constructor"));
1623 iter=new VDblQueIterBase(que);
1624 test.Next(_L("Do's"));
1628 test.Next(_L("Sets"));
1632 test.Next(_L("Finished"));
1637 void TestTQueIter<T>::Test2()
1644 for(offset=0;offset<40;offset+=4)
1646 que=new TDblQue<Item>(offset);
1647 new(PtrAdd(&item.iLink,offset)) TDblQueLink(); // create the link at this offset
1649 test(que->IsHead((Item*) PtrSub(*(iter->sHead),offset))); //Need to pass a pointer to a item
1650 test(que->IsHead((Item*) PtrSub(*(iter->sNext),offset)));
1651 test(*(iter->sOffset)==offset);
1654 que=new TDblQue<Item>(offset);
1655 new(PtrAdd(&item.iLink,offset)) TDblQueLink(); // create the link at this offset
1656 que->AddFirst(item);
1658 test(que->IsHead((Item*) PtrSub(*(iter->sHead),offset)));
1659 test(*(iter->sNext)==PtrAdd(&item.iLink,offset)); //Need a pointer to a link
1660 test(*(iter->sOffset)==offset);
1661 PtrAdd(&item.iLink,offset)->Deque();
1668 void TestTQueIter<T>::Test3()
1670 Item item1,item2,item3,item4;
1674 que.AddFirst(item4);
1675 que.AddFirst(item3);
1676 que.AddFirst(item2);
1677 que.AddFirst(item1);
1678 test.Start(_L("DoPostInc"));
1680 test(&item1==iter->sDoPostInc());
1681 test(&item2.iLink==*(iter->sNext));
1682 test(&item2==iter->sDoPostInc());
1683 test(&item3.iLink==*(iter->sNext));
1684 test(&item3==iter->sDoPostInc());
1685 test(&item4.iLink==*(iter->sNext));
1686 test(&item4==iter->sDoPostInc());
1687 test(que.IsHead((Item*) *(iter->sNext)));
1688 test(iter->sDoPostInc()==NULL);
1690 test.Next(_L("DoPostDec"));
1695 test(&item4.iLink==*(iter->sNext));
1696 test(&item4==iter->sDoPostDec());
1697 test(&item3.iLink==*(iter->sNext));
1698 test(&item3==iter->sDoPostDec());
1699 test(&item2.iLink==*(iter->sNext));
1700 test(&item2==iter->sDoPostDec());
1701 test(&item1.iLink==*(iter->sNext));
1702 test(&item1==iter->sDoPostDec());
1703 test(que.IsHead((Item*) *(iter->sNext)));
1704 test(iter->sDoPostDec()==NULL);
1706 test.Next(_L("DoCurrent"));
1708 test(&item1==iter->sDoCurrent());
1710 test(&item2==iter->sDoCurrent());
1712 test(&item3==iter->sDoCurrent());
1714 test(&item4==iter->sDoCurrent());
1716 test(iter->sDoCurrent()==NULL);
1718 test.Next(_L("Finished"));
1723 void TestTQueIter<T>::Test4()
1725 Item item1,item2,item3,item4;
1730 que.AddFirst(item4);
1731 que.AddFirst(item3);
1732 que.AddFirst(item2);
1733 que.AddFirst(item1);
1734 test.Start(_L("SetToFirst"));
1741 test(*(iter->sNext)==&item1.iLink);
1744 test.Next(_L("SetToLast"));
1752 test(*(iter->sNext)==&item4.iLink);
1755 test.Next(_L("Finished"));
1760 void TestTQueIter<T>::Test5()
1767 que.AddFirst(item2);
1768 que.AddFirst(item1);
1769 test.Start(_L("Constructor"));
1771 test.Next(_L("Iterators"));
1773 test(((*iter)++)==&item1);
1774 test(((*iter)--)==&item2);
1775 test(((*iter)++)==&item1);
1776 test(((*iter)++)==&item2);
1777 test(((*iter)++)==NULL);
1778 test(((*iter)++)==NULL);
1779 test(((*iter)--)==NULL);
1780 test(((*iter)--)==NULL);
1782 test(((*iter)--)==&item2);
1783 test(((*iter)++)==&item1);
1784 test(((*iter)--)==&item2);
1785 test(((*iter)--)==&item1);
1786 test(((*iter)++)==NULL);
1787 test(((*iter)++)==NULL);
1788 test(((*iter)--)==NULL);
1789 test(((*iter)--)==NULL);
1791 test.Next(_L("Finished"));
1796 void TestTQueIter<T>::Test1Item()
1802 test.Start(_L("Constructor"));
1806 test.Next(_L("Iterators"));
1807 test(((*iter)++)==&item);
1808 test(((*iter)++)==NULL);
1809 test(((*iter)++)==NULL);
1810 test(((*iter)++)==NULL);
1811 test(((*iter)--)==NULL);
1812 test(((*iter)--)==NULL);
1814 test(((*iter)--)==&item);
1815 test(((*iter)++)==NULL);
1816 test(((*iter)--)==NULL);
1817 test(((*iter)--)==NULL);
1818 test(((*iter)--)==NULL);
1819 test(((*iter)++)==NULL);
1820 test(((*iter)++)==NULL);
1822 test.Next(_L("Finished"));
1826 /*template<class T> //Redundant
1827 void TestTQueIter<T>::Test6()
1834 for(offset=0;offset<40;offset+=4)
1836 que=new TDblQue<Item>(offset);
1838 test(que->IsHead((Item*) *(iter->sHead)));
1839 test(que->IsHead((Item*) *(iter->sNext)));
1840 test(*(iter->sOffset)==offset);
1843 que=new TDblQue<Item>(offset);
1844 que->AddFirst(item);
1846 test(que->IsHead((Item*) *(iter->sHead)));
1847 test(*(iter->sNext)==&item.iLink);
1848 test(*(iter->sOffset)==offset);
1855 void TestTQueIter<T>::Test7()
1857 Item item1,item2,item3,item4;
1861 que.AddFirst(item4);
1862 que.AddFirst(item3);
1863 que.AddFirst(item2);
1864 que.AddFirst(item1);
1865 test.Start(_L("PostFix ++"));
1867 test(&item1==(*iter)++);
1868 test(&item2.iLink==*(iter->sNext));
1869 test(&item2==(*iter)++);
1870 test(&item3.iLink==*(iter->sNext));
1871 test(&item3==(*iter)++);
1872 test(&item4.iLink==*(iter->sNext));
1873 test(&item4==(*iter)++);
1874 test(que.IsHead((Item*) *(iter->sNext)));
1875 test((*iter)++==NULL);
1877 test.Next(_L("PostFix --"));
1880 test(&item4.iLink==*(iter->sNext));
1881 test(&item4==(*iter)--);
1882 test(&item3.iLink==*(iter->sNext));
1883 test(&item3==(*iter)--);
1884 test(&item2.iLink==*(iter->sNext));
1885 test(&item2==(*iter)--);
1886 test(&item1.iLink==*(iter->sNext));
1887 test(&item1==(*iter)--);
1888 test(que.IsHead((Item*) *(iter->sNext)));
1889 test((*iter)--==NULL);
1891 test.Next(_L("Conversion Operator"));
1893 test(&item1==*iter);
1895 test(&item2==*iter);
1897 test(&item3==*iter);
1899 test(&item4==*iter);
1903 test.Next(_L("Finished"));
1907 GLDEF_C TInt E32Main()
1910 TestTQueLink<TDblQueLinkBase>* testDblQueLinkBase;
1911 TestTQueLink<TDeltaQueLink>* testDeltaQueLink;
1912 TestTQueLink<TDblQueLink>* testDblQueLink;
1913 TestTQueLink<TPriQueLink>* testPriQueLink;
1914 TestTQue<VDblQueBase>* testDblQueBase;
1915 TestTQue<VDeltaQueBase>* testDeltaQueBase;
1916 TestTQue<VDblQue<TDblQueLink> >* testDblQue;
1917 TestTQue<VPriQue<TPriQueLink> >* testPriQue;
1918 TestTQue<VDeltaQue<TDeltaQueLink> >* testDeltaQue;
1919 TestTQueIter<VDblQueIterBase>* testDblQueIterBase;
1920 TestTQueIter<VDblQueIter<Item> >* testDblQueIter;
1922 // Test the queue classes.
1924 test.Start(_L("class TDblQueLinkBase"));
1925 testDblQueLinkBase=new TestTQueLink<TDblQueLinkBase>;
1926 testDblQueLinkBase->TestQueLinkBase();
1927 delete testDblQueLinkBase;
1929 test.Next(_L("class TDeltaQueLink"));
1930 testDeltaQueLink=new TestTQueLink<TDeltaQueLink>;
1931 testDeltaQueLink->TestQueLinkBase();
1932 delete testDeltaQueLink;
1934 test.Next(_L("class TDblQueLink"));
1935 testDblQueLink=new TestTQueLink<TDblQueLink>;
1936 testDblQueLink->TestQueLink();
1937 delete testDblQueLink;
1939 test.Next(_L("class TPriQueLink"));
1940 testPriQueLink=new TestTQueLink<TPriQueLink>;
1941 testPriQueLink->TestQueLink();
1942 delete testPriQueLink;
1944 test.Next(_L("class TDblQueBase"));
1945 testDblQueBase=new TestTQue<VDblQueBase>;
1946 testDblQueBase->TestQueBase();
1947 delete testDblQueBase;
1949 test.Next(_L("class TDeltaQueBase"));
1950 testDeltaQueBase=new TestTQue<VDeltaQueBase>;
1951 testDeltaQueBase->TestDeltaBase();
1952 delete testDeltaQueBase;
1954 test.Next(_L("class TDlbQue"));
1955 testDblQue=new TestTQue<VDblQue<TDblQueLink> >;
1956 testDblQue->TestDblQue();
1959 test.Next(_L("class TPriQue"));
1960 testPriQue=new TestTQue<VPriQue<TPriQueLink> >;
1961 testPriQue->TestPriQue();
1964 test.Next(_L("class TDeltaQue"));
1965 testDeltaQue=new TestTQue<VDeltaQue<TDeltaQueLink> >;
1966 testDeltaQue->TestDeltaQue();
1967 delete testDeltaQue;
1969 test.Next(_L("class TDblQueIterBase"));
1970 testDblQueIterBase=new TestTQueIter<VDblQueIterBase>;
1971 testDblQueIterBase->TestIterBase();
1972 delete testDblQueIterBase;
1974 test.Next(_L("class TDblQueIter"));
1975 testDblQueIter=new TestTQueIter<VDblQueIter<Item> >;
1976 testDblQueIter->TestQueIter();
1977 delete testDblQueIter;
1979 test.Next(_L("Finished"));
1984 #pragma warning(default : 4710) //fuction not expanded