|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test\buffer\t_que.cpp |
|
15 // Overview: |
|
16 // Test double linked list functionality. |
|
17 // API Information: |
|
18 // TDblQueLinkBase, TDeltaQueLink, TDblQueLink, TPriQueLink, |
|
19 // TDblQueIterBase, TDblQueIter |
|
20 // Details: |
|
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 |
|
33 // and Reset methods. |
|
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 |
|
40 // as expected. |
|
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 |
|
52 // are as expected. |
|
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 |
|
82 // is as expected. |
|
83 // - Create TPriQueLink list, insert many links with different priorities check it is |
|
84 // as expected. |
|
85 // - Create TDeltaQueLink list, add ,remove links and check the links and check |
|
86 // it is as expected. |
|
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 |
|
98 // as expected. |
|
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: |
|
117 // All |
|
118 // Assumptions/Requirement/Pre-requisites: |
|
119 // Failures and causes: |
|
120 // Base Port information: |
|
121 // |
|
122 // |
|
123 |
|
124 #include <e32test.h> |
|
125 |
|
126 LOCAL_D RTest test(_L("T_QUE")); |
|
127 |
|
128 #ifndef _DEBUG |
|
129 #pragma warning(disable : 4710) //fuction not expanded |
|
130 #endif |
|
131 |
|
132 #define SIZE 10 |
|
133 #define MAX_OFFSET 10 |
|
134 |
|
135 struct Item |
|
136 { |
|
137 TDblQueLink iLink; |
|
138 TInt iSpace[MAX_OFFSET]; // Reserve some space |
|
139 }; |
|
140 |
|
141 class CItem : public CBase |
|
142 { |
|
143 public: |
|
144 TDblQueLink iLink; |
|
145 //int iSpac[MAX_OFFSET]; // Reserve some space |
|
146 }; |
|
147 |
|
148 template<class T> |
|
149 class TestTQueLink |
|
150 { |
|
151 public: |
|
152 void TestQueLinkBase(); // Calls Test: 1. |
|
153 void TestQueLink(); // Calls Test: 1,2. |
|
154 void Test1(); // Test Enque |
|
155 void Test2(); // Test Deque |
|
156 protected: |
|
157 void CreateObjects(TInt aBaseLink); |
|
158 void DestroyObjects(); |
|
159 private: |
|
160 void CallTest1(); |
|
161 T* iLink[SIZE]; |
|
162 }; |
|
163 |
|
164 template<class T> |
|
165 void TestTQueLink<T>::CallTest1() |
|
166 { |
|
167 test.Start(_L("Test Enque")); |
|
168 Test1(); |
|
169 } |
|
170 |
|
171 template<class T> |
|
172 void TestTQueLink<T>::CreateObjects(TInt aBaseLink) |
|
173 { |
|
174 TInt i; |
|
175 |
|
176 for (i=0;i<SIZE;i++) |
|
177 iLink[i]=new T; |
|
178 if (aBaseLink>=0&&aBaseLink<SIZE) |
|
179 (iLink[aBaseLink])->iNext=(iLink[aBaseLink])->iPrev=iLink[aBaseLink]; |
|
180 } |
|
181 |
|
182 template<class T> |
|
183 void TestTQueLink<T>::DestroyObjects() |
|
184 { |
|
185 TInt i; |
|
186 |
|
187 for (i=0;i<SIZE;i++) |
|
188 delete iLink[i]; |
|
189 } |
|
190 |
|
191 template<class T> |
|
192 void TestTQueLink<T>::TestQueLinkBase() |
|
193 { |
|
194 CallTest1(); |
|
195 test.Next(_L("Finished")); |
|
196 test.End(); |
|
197 } |
|
198 |
|
199 template <class T> |
|
200 void TestTQueLink<T>::TestQueLink() |
|
201 { |
|
202 CallTest1(); |
|
203 test.Next(_L("Text Deque")); |
|
204 Test2(); |
|
205 test.Next(_L("Finished")); |
|
206 test.End(); |
|
207 } |
|
208 |
|
209 template<class T> |
|
210 void TestTQueLink<T>::Test1() |
|
211 { |
|
212 CreateObjects(1); |
|
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")); |
|
247 DestroyObjects(); |
|
248 test.End(); |
|
249 } |
|
250 |
|
251 template<class T> |
|
252 void TestTQueLink<T>::Test2() |
|
253 { |
|
254 CreateObjects(1); |
|
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]); |
|
260 iLink[5]->Deque(); |
|
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]); |
|
272 iLink[3]->Deque(); |
|
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]); |
|
281 iLink[1]->Deque(); |
|
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]); |
|
288 iLink[4]->Deque(); |
|
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")); |
|
294 DestroyObjects(); |
|
295 test.End(); |
|
296 } |
|
297 |
|
298 class VDblQueBase : public TDblQueBase |
|
299 { |
|
300 public: |
|
301 VDblQueBase(); |
|
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();} |
|
307 TDblQueLink* sHead; |
|
308 TInt* sOffset; |
|
309 private: |
|
310 void SetMembers(); |
|
311 }; |
|
312 |
|
313 class VDeltaQueBase : public TDeltaQueBase |
|
314 { |
|
315 public: |
|
316 VDeltaQueBase(); |
|
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();} |
|
321 TInt** sFirstDelta; |
|
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);} |
|
325 TDblQueLink* sHead; |
|
326 TInt* sOffset; |
|
327 private: |
|
328 void SetMembers(); |
|
329 }; |
|
330 |
|
331 template <class T> |
|
332 class VDblQue : public TDblQue<T> |
|
333 { |
|
334 public: |
|
335 VDblQue(); |
|
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);} |
|
344 TDblQueLink* sHead; |
|
345 TInt* sOffset; |
|
346 private: |
|
347 void SetMembers(); |
|
348 }; |
|
349 |
|
350 template <class T> |
|
351 class VPriQue : public TPriQue<T> |
|
352 { |
|
353 public: |
|
354 VPriQue(); |
|
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);} |
|
363 TDblQueLink* sHead; |
|
364 TInt* sOffset; |
|
365 private: |
|
366 void SetMembers(); |
|
367 }; |
|
368 |
|
369 template <class T> |
|
370 class VDeltaQue : public TDeltaQue<T> |
|
371 { |
|
372 public: |
|
373 VDeltaQue(); |
|
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();} |
|
378 TInt** sFirstDelta; |
|
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);} |
|
382 TDblQueLink* sHead; |
|
383 TInt* sOffset; |
|
384 private: |
|
385 void SetMembers(); |
|
386 }; |
|
387 |
|
388 VDblQueBase::VDblQueBase() |
|
389 { |
|
390 SetMembers(); |
|
391 } |
|
392 |
|
393 VDblQueBase::VDblQueBase(TInt anOffset) |
|
394 :TDblQueBase(anOffset) |
|
395 { |
|
396 SetMembers(); |
|
397 } |
|
398 |
|
399 void VDblQueBase::SetMembers() |
|
400 { |
|
401 sHead=&iHead; |
|
402 sOffset=&iOffset; |
|
403 } |
|
404 |
|
405 VDeltaQueBase::VDeltaQueBase() |
|
406 { |
|
407 SetMembers(); |
|
408 } |
|
409 |
|
410 VDeltaQueBase::VDeltaQueBase(TInt anOffset) |
|
411 :TDeltaQueBase(anOffset) |
|
412 { |
|
413 SetMembers(); |
|
414 } |
|
415 |
|
416 void VDeltaQueBase::SetMembers() |
|
417 { |
|
418 sFirstDelta=&iFirstDelta; |
|
419 sHead=&iHead; |
|
420 sOffset=&iOffset; |
|
421 } |
|
422 |
|
423 template <class T> |
|
424 VDblQue<T>::VDblQue() |
|
425 { |
|
426 SetMembers(); |
|
427 } |
|
428 |
|
429 template <class T> |
|
430 VDblQue<T>::VDblQue(TInt anOffset) |
|
431 :TDblQue<T>(anOffset) |
|
432 { |
|
433 SetMembers(); |
|
434 } |
|
435 |
|
436 template <class T> |
|
437 void VDblQue<T>::SetMembers() |
|
438 { |
|
439 //sFirstDelta=&iFirstDelta; |
|
440 sHead=&this->iHead; |
|
441 sOffset=&this->iOffset; |
|
442 } |
|
443 |
|
444 template <class T> |
|
445 VPriQue<T>::VPriQue() |
|
446 { |
|
447 SetMembers(); |
|
448 } |
|
449 |
|
450 template <class T> |
|
451 VPriQue<T>::VPriQue(TInt anOffset) |
|
452 :TPriQue<T>(anOffset) |
|
453 { |
|
454 SetMembers(); |
|
455 } |
|
456 |
|
457 template <class T> |
|
458 void VPriQue<T>::SetMembers() |
|
459 { |
|
460 //sFirstDelta=&iFirstDelta; |
|
461 sHead=&this->iHead; |
|
462 sOffset=&this->iOffset; |
|
463 } |
|
464 |
|
465 template <class T> |
|
466 VDeltaQue<T>::VDeltaQue() |
|
467 { |
|
468 SetMembers(); |
|
469 } |
|
470 |
|
471 template <class T> |
|
472 VDeltaQue<T>::VDeltaQue(TInt anOffset) |
|
473 :TDeltaQue<T>(anOffset) |
|
474 { |
|
475 SetMembers(); |
|
476 } |
|
477 |
|
478 template <class T> |
|
479 void VDeltaQue<T>::SetMembers() |
|
480 { |
|
481 sFirstDelta=&this->iFirstDelta; |
|
482 sHead=&this->iHead; |
|
483 sOffset=&this->iOffset; |
|
484 } |
|
485 |
|
486 template<class T> |
|
487 class TestTQue |
|
488 { |
|
489 friend class TestTQueLink<TDblQueLinkBase>; |
|
490 public: |
|
491 void TestQueBase(); |
|
492 void TestDeltaBase(); |
|
493 void TestDblQue(); |
|
494 void TestPriQue(); |
|
495 void TestDeltaQue(); |
|
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 |
|
515 private: |
|
516 void CallTest3_4(TBool aTestPri); |
|
517 void CallTest7_8(); |
|
518 }; |
|
519 |
|
520 template<class T> |
|
521 void TestTQue<T>::CallTest3_4(TBool aTestPri) |
|
522 { |
|
523 test.Next(_L("Test DoAdd's")); |
|
524 Test3(aTestPri); |
|
525 test.Next(_L("Test public functions")); |
|
526 Test4(); |
|
527 } |
|
528 |
|
529 template<class T> |
|
530 void TestTQue<T>::CallTest7_8() |
|
531 { |
|
532 test.Next(_L("Test Do's")); |
|
533 Test7(); |
|
534 test.Next(_L("CountDown")); |
|
535 Test8(); |
|
536 } |
|
537 |
|
538 template<class T> |
|
539 void TestTQue<T>::TestQueBase() |
|
540 { |
|
541 test.Start(_L("Test all member functions (simply)")); |
|
542 Test1(); |
|
543 test.Next(_L("Test Constructors")); |
|
544 Test2(); |
|
545 CallTest3_4(ETrue); |
|
546 test.Next(_L("Finished")); |
|
547 test.End(); |
|
548 } |
|
549 |
|
550 template<class T> |
|
551 void TestTQue<T>::TestDeltaBase() |
|
552 { |
|
553 test.Start(_L("Test all member functions (simply)")); |
|
554 Test5(); |
|
555 CallTest3_4(EFalse); |
|
556 test.Next(_L("Test Constructors")); |
|
557 Test6(); |
|
558 CallTest7_8(); |
|
559 test.Next(_L("Finished")); |
|
560 test.End(); |
|
561 } |
|
562 |
|
563 template<class T> |
|
564 void TestTQue<T>::TestDblQue() |
|
565 { |
|
566 test.Start(_L("Test all member functions (simply)")); |
|
567 Test9(); |
|
568 CallTest3_4(EFalse); |
|
569 test.Next(_L("Test Constructor")); |
|
570 Test10(); |
|
571 test.Next(_L("Test Add's")); |
|
572 Test11(); |
|
573 test.Next(_L("Test Is's")); |
|
574 Test12(); |
|
575 test.Next(_L("Get's")); |
|
576 Test13(); |
|
577 test.Next(_L("Finished")); |
|
578 test.End(); |
|
579 } |
|
580 |
|
581 template<class T> |
|
582 void TestTQue<T>::TestPriQue() |
|
583 { |
|
584 test.Start(_L("Test all member functions (simply)")); |
|
585 Test14(); |
|
586 CallTest3_4(ETrue); |
|
587 test.Next(_L("Test Constructor")); |
|
588 Test15(); |
|
589 test.Next(_L("Test Add")); |
|
590 Test16(); |
|
591 test.Next(_L("Finished")); |
|
592 test.End(); |
|
593 } |
|
594 |
|
595 template<class T> |
|
596 void TestTQue<T>::TestDeltaQue() |
|
597 { |
|
598 test.Start(_L("Test all member functions (simply)")); |
|
599 Test17(); |
|
600 CallTest3_4(EFalse); |
|
601 CallTest7_8(); |
|
602 test.Next(_L("Test Constructor")); |
|
603 Test18(); |
|
604 test.Next(_L("Test Add/Removes")); |
|
605 Test19(); |
|
606 test.Next(_L("Finished")); |
|
607 test.End(); |
|
608 } |
|
609 |
|
610 template<class T> |
|
611 void TestTQue<T>::Test1() |
|
612 { |
|
613 T* que; |
|
614 TPriQueLink link1,link2; |
|
615 TInt offset=4; |
|
616 |
|
617 test.Start(_L("Constructors")); |
|
618 que=new VDblQueBase(offset); |
|
619 delete que; |
|
620 que=new VDblQueBase; |
|
621 //delete que; |
|
622 test.Next(_L("DoAdd's")); |
|
623 que->sDoAddFirst(&link1); |
|
624 link1.Deque(); |
|
625 que->sDoAddLast(&link1); |
|
626 link1.iPriority=1; |
|
627 link2.iPriority=2; |
|
628 que->sDoAddPriority(&link2); |
|
629 test.Next(_L("Public")); |
|
630 que->IsEmpty(); |
|
631 que->SetOffset(offset); |
|
632 que->Reset(); |
|
633 test.Next(_L("Finished")); |
|
634 delete que; |
|
635 test.End(); |
|
636 } |
|
637 |
|
638 template<class T> |
|
639 void TestTQue<T>::Test2() |
|
640 { |
|
641 T* que; |
|
642 TInt offset; |
|
643 |
|
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); |
|
649 delete que; |
|
650 test.Next(_L("Offset constructor")); |
|
651 for (offset=0;offset<40;offset+=4) |
|
652 { |
|
653 que=new VDblQueBase(offset); |
|
654 test(*(que->sOffset)==offset); |
|
655 test(que->sHead->iNext==que->sHead); |
|
656 test(que->sHead->iPrev==que->sHead); |
|
657 delete que; |
|
658 } |
|
659 test.Next(_L("Finished")); |
|
660 test.End(); |
|
661 } |
|
662 |
|
663 template<class T> |
|
664 void TestTQue<T>::Test3(TBool aTestPri) |
|
665 { |
|
666 T* que; |
|
667 TDblQueLink link1,link2,link3,link4; |
|
668 |
|
669 test.Start(_L("AddFirst")); |
|
670 que=new T(); |
|
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); |
|
703 link1.Deque(); |
|
704 link2.Deque(); |
|
705 link3.Deque(); |
|
706 link4.Deque(); |
|
707 delete que; |
|
708 test.Next(_L("AddLast")); |
|
709 que=new T(); |
|
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); |
|
742 link1.Deque(); |
|
743 link2.Deque(); |
|
744 link3.Deque(); |
|
745 link4.Deque(); |
|
746 delete que; |
|
747 test.Next(_L("Combined AddFirst and AddLast")); |
|
748 que=new T(); |
|
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); |
|
777 link1.Deque(); |
|
778 link2.Deque(); |
|
779 link3.Deque(); |
|
780 link4.Deque(); |
|
781 delete que; |
|
782 if (aTestPri) |
|
783 { |
|
784 TPriQueLink link5,link6,link7,link8,link9,link10; |
|
785 |
|
786 test.Next(_L("AddPriority")); |
|
787 que=new T(); |
|
788 link5.iPriority=4; |
|
789 link6.iPriority=6; |
|
790 link7.iPriority=8; |
|
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); |
|
802 link8.iPriority=7; |
|
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); |
|
814 link9.iPriority=5; |
|
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); |
|
828 link10.iPriority=3; |
|
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); |
|
844 link5.Deque(); |
|
845 link6.Deque(); |
|
846 link7.Deque(); |
|
847 link8.Deque(); |
|
848 delete que; |
|
849 } |
|
850 test.Next(_L("Finished")); |
|
851 test.End(); |
|
852 } |
|
853 |
|
854 template<class T> |
|
855 void TestTQue<T>::Test4() |
|
856 { |
|
857 T* que; |
|
858 TInt offset; |
|
859 |
|
860 test.Start(_L("IsEmpty")); |
|
861 que=new T(); |
|
862 test(que->IsEmpty()==TRUE); |
|
863 TDblQueLink link1,link2; |
|
864 que->sDoAddFirst(&link1); |
|
865 test(que->IsEmpty()==FALSE); |
|
866 link1.Deque(); |
|
867 test(que->IsEmpty()==TRUE); |
|
868 que->sDoAddLast(&link2); |
|
869 test(que->IsEmpty()==FALSE); |
|
870 link1.Enque(&link2); |
|
871 test(que->IsEmpty()==FALSE); |
|
872 link2.Deque(); |
|
873 test(que->IsEmpty()==FALSE); |
|
874 link1.Deque(); |
|
875 test(que->IsEmpty()==TRUE); |
|
876 test.Next(_L("Reset")); |
|
877 que->sDoAddFirst(&link1); |
|
878 test(que->IsEmpty()==FALSE); |
|
879 que->Reset(); |
|
880 test(que->IsEmpty()==TRUE); |
|
881 test.Next(_L("SetOffset")); |
|
882 for (offset=0;offset<40;offset+=4) |
|
883 { |
|
884 que->SetOffset(offset); |
|
885 test(*(que->sOffset)==offset); |
|
886 } |
|
887 test.Next(_L("Finished")); |
|
888 delete que; |
|
889 test.End(); |
|
890 } |
|
891 |
|
892 template<class T> |
|
893 void TestTQue<T>::Test5() |
|
894 { |
|
895 T* que; |
|
896 TDeltaQueLink link1,link2,link3; |
|
897 TInt offset=4; |
|
898 |
|
899 test.Start(_L("Constructors")); |
|
900 que=new VDeltaQueBase(offset); |
|
901 delete que; |
|
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")); |
|
910 que->CountDown(); |
|
911 test.Next(_L("Finished")); |
|
912 delete que; |
|
913 test.End(); |
|
914 } |
|
915 |
|
916 template<class T> |
|
917 void TestTQue<T>::Test6() |
|
918 { |
|
919 T* que; |
|
920 TInt offset; |
|
921 |
|
922 test.Start(_L("Default constructor")); |
|
923 que=new VDeltaQueBase(); |
|
924 test(*(que->sFirstDelta)==NULL); |
|
925 delete que; |
|
926 test.Next(_L("Offset constructor")); |
|
927 for (offset=0;offset<40;offset+=4) |
|
928 { |
|
929 que=new VDeltaQueBase(offset); |
|
930 test(*(que->sOffset)==offset); |
|
931 test(*(que->sFirstDelta)==NULL); |
|
932 delete que; |
|
933 } |
|
934 test.Next(_L("Finished")); |
|
935 test.End(); |
|
936 } |
|
937 |
|
938 template<class T> |
|
939 void TestTQue<T>::Test7() |
|
940 { |
|
941 T* que; |
|
942 TDeltaQueLink link1,link2,link3,link4,link5,link6; |
|
943 |
|
944 test.Start(_L("DoAddDelta")); |
|
945 que=new T(); |
|
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); |
|
1009 link2.iDelta=1; |
|
1010 test(NULL==que->sDoRemoveFirst()); |
|
1011 test(*(que->sFirstDelta)==&link2.iDelta); |
|
1012 test(link2.iDelta==1); |
|
1013 link2.iDelta=0; |
|
1014 test(&link2==que->sDoRemoveFirst()); |
|
1015 delete que; |
|
1016 test.Next(_L("Finished")); |
|
1017 test.End(); |
|
1018 } |
|
1019 |
|
1020 template<class T> |
|
1021 void TestTQue<T>::Test8() |
|
1022 { |
|
1023 T* que; |
|
1024 TDeltaQueLink link1,link2,link3; |
|
1025 |
|
1026 que=new T(); |
|
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(); |
|
1039 delete que; |
|
1040 } |
|
1041 |
|
1042 template<class T> |
|
1043 void TestTQue<T>::Test9() |
|
1044 { |
|
1045 T* que; |
|
1046 TDblQueLink link1,link2; |
|
1047 TInt offset=4; |
|
1048 |
|
1049 test.Start(_L("Constructors")); |
|
1050 que=new VDblQue<TDblQueLink>(offset); |
|
1051 delete que; |
|
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")); |
|
1061 que->First(); |
|
1062 que->Last(); |
|
1063 test.Next(_L("Finished")); |
|
1064 delete que; |
|
1065 test.End(); |
|
1066 } |
|
1067 |
|
1068 template<class T> |
|
1069 void TestTQue<T>::Test10() |
|
1070 { |
|
1071 T* que; |
|
1072 TInt offset; |
|
1073 |
|
1074 test.Start(_L("Offset constructor")); |
|
1075 for (offset=0;offset<40;offset+=4) |
|
1076 { |
|
1077 que=new VDblQue<TDblQueLink>(offset); |
|
1078 test(*(que->sOffset)==offset); |
|
1079 delete que; |
|
1080 } |
|
1081 test.Next(_L("Finished")); |
|
1082 test.End(); |
|
1083 } |
|
1084 |
|
1085 template<class T> |
|
1086 void TestTQue<T>::Test11() |
|
1087 { |
|
1088 T* que; |
|
1089 TDblQueLink link1,link2,link3,link4; |
|
1090 |
|
1091 test.Start(_L("AddFirst")); |
|
1092 que=new T(); |
|
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); |
|
1125 link1.Deque(); |
|
1126 link2.Deque(); |
|
1127 link3.Deque(); |
|
1128 link4.Deque(); |
|
1129 delete que; |
|
1130 test.Next(_L("AddLast")); |
|
1131 que=new T(); |
|
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); |
|
1164 link1.Deque(); |
|
1165 link2.Deque(); |
|
1166 link3.Deque(); |
|
1167 link4.Deque(); |
|
1168 delete que; |
|
1169 test.Next(_L("Combined AddFirst and AddLast")); |
|
1170 que=new T(); |
|
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); |
|
1199 link1.Deque(); |
|
1200 link2.Deque(); |
|
1201 link3.Deque(); |
|
1202 link4.Deque(); |
|
1203 delete que; |
|
1204 test.Next(_L("Finished")); |
|
1205 test.End(); |
|
1206 } |
|
1207 |
|
1208 template<class T> |
|
1209 void TestTQue<T>::Test12() |
|
1210 { |
|
1211 T* que; |
|
1212 TDblQueLink link1,link2,link3,link4,*head; |
|
1213 |
|
1214 que=new T(); |
|
1215 que->AddFirst(link1); |
|
1216 que->AddLast(link2); |
|
1217 que->AddLast(link3); |
|
1218 que->AddLast(link4); |
|
1219 head=que->sHead; |
|
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); |
|
1238 delete que; |
|
1239 test.Next(_L("Finished")); |
|
1240 test.End(); |
|
1241 } |
|
1242 |
|
1243 template<class T> |
|
1244 void TestTQue<T>::Test13() |
|
1245 { |
|
1246 T* que; |
|
1247 TDblQueLink link1,link2,link3,link4; |
|
1248 |
|
1249 test.Start(_L("First")); |
|
1250 que=new T(); |
|
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); |
|
1259 link1.Deque(); |
|
1260 link2.Deque(); |
|
1261 link3.Deque(); |
|
1262 link4.Deque(); |
|
1263 delete que; |
|
1264 test.Next(_L("Last")); |
|
1265 que=new T(); |
|
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); |
|
1274 link1.Deque(); |
|
1275 link2.Deque(); |
|
1276 link3.Deque(); |
|
1277 link4.Deque(); |
|
1278 delete que; |
|
1279 test.Next(_L("Finished")); |
|
1280 test.End(); |
|
1281 } |
|
1282 |
|
1283 template<class T> |
|
1284 void TestTQue<T>::Test14() |
|
1285 { |
|
1286 T* que; |
|
1287 TPriQueLink link; |
|
1288 TInt offset=4; |
|
1289 |
|
1290 test.Start(_L("Constructors")); |
|
1291 que=new VPriQue<TPriQueLink>(offset); |
|
1292 delete que; |
|
1293 que=new VPriQue<TPriQueLink>; |
|
1294 test.Next(_L("Add")); |
|
1295 que->Add(link); |
|
1296 test.Next(_L("Finished")); |
|
1297 delete que; |
|
1298 test.End(); |
|
1299 } |
|
1300 |
|
1301 template<class T> |
|
1302 void TestTQue<T>::Test15() |
|
1303 { |
|
1304 T* que; |
|
1305 TInt offset; |
|
1306 |
|
1307 test.Start(_L("Offset constructor")); |
|
1308 for (offset=0;offset<40;offset+=4) |
|
1309 { |
|
1310 que=new VPriQue<TPriQueLink>(offset); |
|
1311 test(*(que->sOffset)==offset); |
|
1312 delete que; |
|
1313 } |
|
1314 test.Next(_L("Finished")); |
|
1315 test.End(); |
|
1316 } |
|
1317 |
|
1318 template<class T> |
|
1319 void TestTQue<T>::Test16() |
|
1320 { |
|
1321 T* que; |
|
1322 TPriQueLink link1,link2,link3,link4,link5,link6; |
|
1323 |
|
1324 que=new T(); |
|
1325 link1.iPriority=4; |
|
1326 link2.iPriority=6; |
|
1327 link3.iPriority=2; |
|
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); |
|
1339 link4.iPriority=3; |
|
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); |
|
1351 link5.iPriority=5; |
|
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); |
|
1365 link6.iPriority=1; |
|
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); |
|
1381 delete que; |
|
1382 } |
|
1383 |
|
1384 template<class T> |
|
1385 void TestTQue<T>::Test17() |
|
1386 { |
|
1387 T* que; |
|
1388 TDeltaQueLink link1,link2; |
|
1389 TInt offset=4; |
|
1390 |
|
1391 test.Start(_L("Constructors")); |
|
1392 que=new VDeltaQue<TDeltaQueLink>(offset); |
|
1393 delete que; |
|
1394 que=new VDeltaQue<TDeltaQueLink>; |
|
1395 test.Next(_L("Add/Remove")); |
|
1396 que->Add(link1,0); |
|
1397 que->Add(link2,2); |
|
1398 que->Remove(link2); |
|
1399 que->RemoveFirst(); |
|
1400 test.Next(_L("Finished")); |
|
1401 test.End(); |
|
1402 } |
|
1403 |
|
1404 template<class T> |
|
1405 void TestTQue<T>::Test18() |
|
1406 { |
|
1407 T* que; |
|
1408 TInt offset; |
|
1409 |
|
1410 test.Start(_L("Offset constructor")); |
|
1411 for (offset=0;offset<40;offset+=4) |
|
1412 { |
|
1413 que=new VDeltaQue<TDeltaQueLink>(offset); |
|
1414 test(*(que->sOffset)==offset); |
|
1415 delete que; |
|
1416 } |
|
1417 test.Next(_L("Finished")); |
|
1418 test.End(); |
|
1419 } |
|
1420 |
|
1421 template<class T> |
|
1422 void TestTQue<T>::Test19() |
|
1423 { |
|
1424 T* que; |
|
1425 TDeltaQueLink link1,link2,link3,link4,link5,link6; |
|
1426 |
|
1427 test.Start(_L("Add")); |
|
1428 que=new T(); |
|
1429 que->Add(link2,3); |
|
1430 test(*(que->sFirstDelta)==&link2.iDelta); |
|
1431 test(link2.iDelta==3); |
|
1432 que->Add(link5,15); |
|
1433 test(*(que->sFirstDelta)==&link2.iDelta); |
|
1434 test(link2.iDelta==3); |
|
1435 test(link5.iDelta==12); |
|
1436 que->Add(link3,6); |
|
1437 test(*(que->sFirstDelta)==&link2.iDelta); |
|
1438 test(link2.iDelta==3); |
|
1439 test(link3.iDelta==3); |
|
1440 test(link5.iDelta==9); |
|
1441 que->Add(link4,10); |
|
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); |
|
1447 que->Add(link1,1); |
|
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); |
|
1454 que->Add(link6,21); |
|
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")); |
|
1463 que->Remove(link6); |
|
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); |
|
1470 que->Remove(link1); |
|
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); |
|
1476 que->Remove(link4); |
|
1477 test(*(que->sFirstDelta)==&link2.iDelta); |
|
1478 test(link2.iDelta==3); |
|
1479 test(link3.iDelta==3); |
|
1480 test(link5.iDelta==9); |
|
1481 que->Remove(link3); |
|
1482 test(*(que->sFirstDelta)==&link2.iDelta); |
|
1483 test(link2.iDelta==3); |
|
1484 test(link5.iDelta==12); |
|
1485 que->Remove(link5); |
|
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); |
|
1492 link2.iDelta=1; |
|
1493 test(NULL==que->RemoveFirst()); |
|
1494 test(*(que->sFirstDelta)==&link2.iDelta); |
|
1495 test(link2.iDelta==1); |
|
1496 link2.iDelta=0; |
|
1497 test(&link2==que->RemoveFirst()); |
|
1498 test.Next(_L("Finished")); |
|
1499 delete que; |
|
1500 test.End(); |
|
1501 } |
|
1502 |
|
1503 class VDblQueIterBase : public TDblQueIterBase |
|
1504 { |
|
1505 public: |
|
1506 VDblQueIterBase(TDblQueBase& aQue); |
|
1507 inline TAny* sDoPostInc() {return DoPostInc();} |
|
1508 inline TAny* sDoPostDec() {return DoPostDec();} |
|
1509 inline TAny* sDoCurrent() {return DoCurrent();} |
|
1510 TInt* sOffset; |
|
1511 TDblQueLinkBase** sHead; |
|
1512 TDblQueLinkBase** sNext; |
|
1513 private: |
|
1514 void SetMember(); |
|
1515 }; |
|
1516 |
|
1517 template <class T> |
|
1518 class VDblQueIter : public TDblQueIter<T> |
|
1519 { |
|
1520 public: |
|
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();} |
|
1525 TInt* sOffset; |
|
1526 TDblQueLinkBase** sHead; |
|
1527 TDblQueLinkBase** sNext; |
|
1528 private: |
|
1529 void SetMember(); |
|
1530 }; |
|
1531 |
|
1532 VDblQueIterBase::VDblQueIterBase(TDblQueBase& aQue) |
|
1533 :TDblQueIterBase(aQue) |
|
1534 { |
|
1535 SetMember(); |
|
1536 } |
|
1537 |
|
1538 void VDblQueIterBase::SetMember() |
|
1539 { |
|
1540 sOffset=&iOffset; |
|
1541 sHead=&iHead; |
|
1542 sNext=&iNext; |
|
1543 } |
|
1544 |
|
1545 template <class T> |
|
1546 VDblQueIter<T>::VDblQueIter(TDblQueBase& aQue) |
|
1547 :TDblQueIter<T>(aQue) |
|
1548 { |
|
1549 SetMember(); |
|
1550 } |
|
1551 |
|
1552 template <class T> |
|
1553 void VDblQueIter<T>::SetMember() |
|
1554 { |
|
1555 sOffset=&this->iOffset; |
|
1556 sHead=&this->iHead; |
|
1557 sNext=&this->iNext; |
|
1558 } |
|
1559 |
|
1560 template<class T> |
|
1561 class TestTQueIter |
|
1562 { |
|
1563 public: |
|
1564 void TestIterBase(); |
|
1565 void TestQueIter(); |
|
1566 void Test1(); //All functions //TDblQueIterBase |
|
1567 void Test2(); //Constructors |
|
1568 void Test3(); //Do's |
|
1569 void Test4(); //Set |
|
1570 void Test5(); //All functions //TDblQueIter |
|
1571 void Test1Item(); |
|
1572 //void Test6(); //Constructors //Redundant |
|
1573 void Test7(); //Iterators |
|
1574 private: |
|
1575 void CallTest2_4(); |
|
1576 }; |
|
1577 |
|
1578 template<class T> |
|
1579 void TestTQueIter<T>::CallTest2_4() |
|
1580 { |
|
1581 test.Next(_L("Constructors")); |
|
1582 Test2(); |
|
1583 test.Next(_L("Do's")); |
|
1584 Test3(); |
|
1585 test.Next(_L("Sets")); |
|
1586 Test4(); |
|
1587 } |
|
1588 |
|
1589 template<class T> |
|
1590 void TestTQueIter<T>::TestIterBase() |
|
1591 { |
|
1592 test.Start(_L("All Methods")); |
|
1593 Test1(); |
|
1594 CallTest2_4(); |
|
1595 test.Next(_L("Finished")); |
|
1596 test.End(); |
|
1597 } |
|
1598 |
|
1599 template<class T> |
|
1600 void TestTQueIter<T>::TestQueIter() |
|
1601 { |
|
1602 test.Start(_L("All Methods")); |
|
1603 Test5(); |
|
1604 CallTest2_4(); |
|
1605 test.Next(_L("One item in queue")); |
|
1606 Test1Item(); |
|
1607 test.Next(_L("Iterators")); |
|
1608 Test7(); |
|
1609 test.Next(_L("Finished")); |
|
1610 test.End(); |
|
1611 } |
|
1612 |
|
1613 template<class T> |
|
1614 void TestTQueIter<T>::Test1() |
|
1615 { |
|
1616 Item item1,item2; |
|
1617 TDblQue<Item> que; |
|
1618 T* iter; |
|
1619 |
|
1620 que.AddFirst(item2); |
|
1621 que.AddFirst(item1); |
|
1622 test.Start(_L("Constructor")); |
|
1623 iter=new VDblQueIterBase(que); |
|
1624 test.Next(_L("Do's")); |
|
1625 iter->sDoCurrent(); |
|
1626 iter->sDoPostInc(); |
|
1627 iter->sDoPostDec(); |
|
1628 test.Next(_L("Sets")); |
|
1629 iter->SetToFirst(); |
|
1630 iter->SetToLast(); |
|
1631 delete iter; |
|
1632 test.Next(_L("Finished")); |
|
1633 test.End(); |
|
1634 } |
|
1635 |
|
1636 template<class T> |
|
1637 void TestTQueIter<T>::Test2() |
|
1638 { |
|
1639 Item item; |
|
1640 TDblQue<Item>* que; |
|
1641 TInt offset; |
|
1642 T* iter; |
|
1643 |
|
1644 for(offset=0;offset<40;offset+=4) |
|
1645 { |
|
1646 que=new TDblQue<Item>(offset); |
|
1647 new(PtrAdd(&item.iLink,offset)) TDblQueLink(); // create the link at this offset |
|
1648 iter=new T(*que); |
|
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); |
|
1652 delete iter; |
|
1653 delete que; |
|
1654 que=new TDblQue<Item>(offset); |
|
1655 new(PtrAdd(&item.iLink,offset)) TDblQueLink(); // create the link at this offset |
|
1656 que->AddFirst(item); |
|
1657 iter=new T(*que); |
|
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(); |
|
1662 delete iter; |
|
1663 delete que; |
|
1664 } |
|
1665 } |
|
1666 |
|
1667 template<class T> |
|
1668 void TestTQueIter<T>::Test3() |
|
1669 { |
|
1670 Item item1,item2,item3,item4; |
|
1671 TDblQue<Item> que; |
|
1672 T* iter; |
|
1673 |
|
1674 que.AddFirst(item4); |
|
1675 que.AddFirst(item3); |
|
1676 que.AddFirst(item2); |
|
1677 que.AddFirst(item1); |
|
1678 test.Start(_L("DoPostInc")); |
|
1679 iter=new T(que); |
|
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); |
|
1689 delete iter; |
|
1690 test.Next(_L("DoPostDec")); |
|
1691 iter=new T(que); |
|
1692 iter->sDoPostInc(); |
|
1693 iter->sDoPostInc(); |
|
1694 iter->sDoPostInc(); |
|
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); |
|
1705 delete iter; |
|
1706 test.Next(_L("DoCurrent")); |
|
1707 iter=new T(que); |
|
1708 test(&item1==iter->sDoCurrent()); |
|
1709 iter->sDoPostInc(); |
|
1710 test(&item2==iter->sDoCurrent()); |
|
1711 iter->sDoPostInc(); |
|
1712 test(&item3==iter->sDoCurrent()); |
|
1713 iter->sDoPostInc(); |
|
1714 test(&item4==iter->sDoCurrent()); |
|
1715 iter->sDoPostInc(); |
|
1716 test(iter->sDoCurrent()==NULL); |
|
1717 delete iter; |
|
1718 test.Next(_L("Finished")); |
|
1719 test.End(); |
|
1720 } |
|
1721 |
|
1722 template<class T> |
|
1723 void TestTQueIter<T>::Test4() |
|
1724 { |
|
1725 Item item1,item2,item3,item4; |
|
1726 TDblQue<Item> que; |
|
1727 T* iter; |
|
1728 TInt i,j; |
|
1729 |
|
1730 que.AddFirst(item4); |
|
1731 que.AddFirst(item3); |
|
1732 que.AddFirst(item2); |
|
1733 que.AddFirst(item1); |
|
1734 test.Start(_L("SetToFirst")); |
|
1735 iter=new T(que); |
|
1736 for(i=0;i<5;i++) |
|
1737 { |
|
1738 for(j=0;j<i;j++) |
|
1739 iter->sDoPostInc(); |
|
1740 iter->SetToFirst(); |
|
1741 test(*(iter->sNext)==&item1.iLink); |
|
1742 } |
|
1743 delete iter; |
|
1744 test.Next(_L("SetToLast")); |
|
1745 iter=new T(que); |
|
1746 for(i=0;i<5;i++) |
|
1747 { |
|
1748 iter->SetToFirst(); |
|
1749 for(j=0;j<i;j++) |
|
1750 iter->sDoPostInc(); |
|
1751 iter->SetToLast(); |
|
1752 test(*(iter->sNext)==&item4.iLink); |
|
1753 } |
|
1754 delete iter; |
|
1755 test.Next(_L("Finished")); |
|
1756 test.End(); |
|
1757 } |
|
1758 |
|
1759 template<class T> |
|
1760 void TestTQueIter<T>::Test5() |
|
1761 { |
|
1762 Item item1,item2; |
|
1763 TDblQue<Item> que; |
|
1764 T* iter; |
|
1765 Item* a; |
|
1766 |
|
1767 que.AddFirst(item2); |
|
1768 que.AddFirst(item1); |
|
1769 test.Start(_L("Constructor")); |
|
1770 iter=new T(que); |
|
1771 test.Next(_L("Iterators")); |
|
1772 a=*iter; |
|
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); |
|
1781 iter->Set(item2); |
|
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); |
|
1790 delete iter; |
|
1791 test.Next(_L("Finished")); |
|
1792 test.End(); |
|
1793 } |
|
1794 |
|
1795 template<class T> |
|
1796 void TestTQueIter<T>::Test1Item() |
|
1797 { |
|
1798 Item item; |
|
1799 TDblQue<Item> que; |
|
1800 T* iter; |
|
1801 |
|
1802 test.Start(_L("Constructor")); |
|
1803 iter=new T(que); |
|
1804 que.AddFirst(item); |
|
1805 iter->Set(item); |
|
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); |
|
1813 iter->Set(item); |
|
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); |
|
1821 delete iter; |
|
1822 test.Next(_L("Finished")); |
|
1823 test.End(); |
|
1824 } |
|
1825 |
|
1826 /*template<class T> //Redundant |
|
1827 void TestTQueIter<T>::Test6() |
|
1828 { |
|
1829 Item item; |
|
1830 TDblQue<Item>* que; |
|
1831 TInt offset; |
|
1832 T* iter; |
|
1833 |
|
1834 for(offset=0;offset<40;offset+=4) |
|
1835 { |
|
1836 que=new TDblQue<Item>(offset); |
|
1837 iter=new T(*que); |
|
1838 test(que->IsHead((Item*) *(iter->sHead))); |
|
1839 test(que->IsHead((Item*) *(iter->sNext))); |
|
1840 test(*(iter->sOffset)==offset); |
|
1841 delete iter; |
|
1842 delete que; |
|
1843 que=new TDblQue<Item>(offset); |
|
1844 que->AddFirst(item); |
|
1845 iter=new T(*que); |
|
1846 test(que->IsHead((Item*) *(iter->sHead))); |
|
1847 test(*(iter->sNext)==&item.iLink); |
|
1848 test(*(iter->sOffset)==offset); |
|
1849 delete iter; |
|
1850 delete que; |
|
1851 } |
|
1852 }*/ |
|
1853 |
|
1854 template<class T> |
|
1855 void TestTQueIter<T>::Test7() |
|
1856 { |
|
1857 Item item1,item2,item3,item4; |
|
1858 TDblQue<Item> que; |
|
1859 T* iter; |
|
1860 |
|
1861 que.AddFirst(item4); |
|
1862 que.AddFirst(item3); |
|
1863 que.AddFirst(item2); |
|
1864 que.AddFirst(item1); |
|
1865 test.Start(_L("PostFix ++")); |
|
1866 iter=new T(que); |
|
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); |
|
1876 delete iter; |
|
1877 test.Next(_L("PostFix --")); |
|
1878 iter=new T(que); |
|
1879 iter->SetToLast(); |
|
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); |
|
1890 delete iter; |
|
1891 test.Next(_L("Conversion Operator")); |
|
1892 iter=new T(que); |
|
1893 test(&item1==*iter); |
|
1894 (*iter)++; |
|
1895 test(&item2==*iter); |
|
1896 (*iter)++; |
|
1897 test(&item3==*iter); |
|
1898 (*iter)++; |
|
1899 test(&item4==*iter); |
|
1900 (*iter)++; |
|
1901 test(*iter==NULL); |
|
1902 delete iter; |
|
1903 test.Next(_L("Finished")); |
|
1904 test.End(); |
|
1905 } |
|
1906 |
|
1907 GLDEF_C TInt E32Main() |
|
1908 { |
|
1909 |
|
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; |
|
1921 |
|
1922 // Test the queue classes. |
|
1923 test.Title(); |
|
1924 test.Start(_L("class TDblQueLinkBase")); |
|
1925 testDblQueLinkBase=new TestTQueLink<TDblQueLinkBase>; |
|
1926 testDblQueLinkBase->TestQueLinkBase(); |
|
1927 delete testDblQueLinkBase; |
|
1928 |
|
1929 test.Next(_L("class TDeltaQueLink")); |
|
1930 testDeltaQueLink=new TestTQueLink<TDeltaQueLink>; |
|
1931 testDeltaQueLink->TestQueLinkBase(); |
|
1932 delete testDeltaQueLink; |
|
1933 |
|
1934 test.Next(_L("class TDblQueLink")); |
|
1935 testDblQueLink=new TestTQueLink<TDblQueLink>; |
|
1936 testDblQueLink->TestQueLink(); |
|
1937 delete testDblQueLink; |
|
1938 |
|
1939 test.Next(_L("class TPriQueLink")); |
|
1940 testPriQueLink=new TestTQueLink<TPriQueLink>; |
|
1941 testPriQueLink->TestQueLink(); |
|
1942 delete testPriQueLink; |
|
1943 |
|
1944 test.Next(_L("class TDblQueBase")); |
|
1945 testDblQueBase=new TestTQue<VDblQueBase>; |
|
1946 testDblQueBase->TestQueBase(); |
|
1947 delete testDblQueBase; |
|
1948 |
|
1949 test.Next(_L("class TDeltaQueBase")); |
|
1950 testDeltaQueBase=new TestTQue<VDeltaQueBase>; |
|
1951 testDeltaQueBase->TestDeltaBase(); |
|
1952 delete testDeltaQueBase; |
|
1953 |
|
1954 test.Next(_L("class TDlbQue")); |
|
1955 testDblQue=new TestTQue<VDblQue<TDblQueLink> >; |
|
1956 testDblQue->TestDblQue(); |
|
1957 delete testDblQue; |
|
1958 |
|
1959 test.Next(_L("class TPriQue")); |
|
1960 testPriQue=new TestTQue<VPriQue<TPriQueLink> >; |
|
1961 testPriQue->TestPriQue(); |
|
1962 delete testPriQue; |
|
1963 |
|
1964 test.Next(_L("class TDeltaQue")); |
|
1965 testDeltaQue=new TestTQue<VDeltaQue<TDeltaQueLink> >; |
|
1966 testDeltaQue->TestDeltaQue(); |
|
1967 delete testDeltaQue; |
|
1968 |
|
1969 test.Next(_L("class TDblQueIterBase")); |
|
1970 testDblQueIterBase=new TestTQueIter<VDblQueIterBase>; |
|
1971 testDblQueIterBase->TestIterBase(); |
|
1972 delete testDblQueIterBase; |
|
1973 |
|
1974 test.Next(_L("class TDblQueIter")); |
|
1975 testDblQueIter=new TestTQueIter<VDblQueIter<Item> >; |
|
1976 testDblQueIter->TestQueIter(); |
|
1977 delete testDblQueIter; |
|
1978 |
|
1979 test.Next(_L("Finished")); |
|
1980 test.End(); |
|
1981 return(0); |
|
1982 } |
|
1983 |
|
1984 #pragma warning(default : 4710) //fuction not expanded |
|
1985 |