1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/buffer/t_que.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1985 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\buffer\t_que.cpp
1.18 +// Overview:
1.19 +// Test double linked list functionality.
1.20 +// API Information:
1.21 +// TDblQueLinkBase, TDeltaQueLink, TDblQueLink, TPriQueLink,
1.22 +// TDblQueIterBase, TDblQueIter
1.23 +// Details:
1.24 +// - Create many TDblQueLinkBase links, insert links at specified locations
1.25 +// and check previous and next links are as expected.
1.26 +// - Create many TDeltaQueLink links, insert these links at specified locations
1.27 +// and check previous and next links are as expected.
1.28 +// - Create many TDblQueLink links, insert, remove these links at specified
1.29 +// locations and check previous and next links are as expected.
1.30 +// - Create many TPriQueLink links, insert, remove these links at specified
1.31 +// locations and check previous and next links are as expected.
1.32 +// - Create TDblQueBase based object without offset, with specified offset
1.33 +// and check it is constructed as expected.
1.34 +// - Create TDblQueBase based object, insert and remove TPriQueLink list
1.35 +// element, set priorities of TPriQueLink list elements, call IsEmpty
1.36 +// and Reset methods.
1.37 +// - Create TDblQueBase based object without, with offset and check
1.38 +// it is constructed as expected
1.39 +// - Create TDblQueBase based object, insert TDblQueLink links at
1.40 +// specified locations and check that they are added as expected.
1.41 +// - Initialise TPriQueLink link with different priorities, insert
1.42 +// the elements in priority order and check that they are added
1.43 +// as expected.
1.44 +// - Create TDblQueBase based object, check the double linked list for empty
1.45 +// before inserting, after inserting, before/after Deque, before/after Enque,
1.46 +// after Reset. Verify that results are as expected.
1.47 +// - Create TDeltaQueBase object without offset, with specified offset
1.48 +// and check it is constructed as expected. Insert TDeltaQueLink list
1.49 +// elements at specified distance from the zero point, remove the elements
1.50 +// at specified distance, decrement the delta value.
1.51 +// - Create TDeltaQueBase based object, insert TDblQueLink link at specified
1.52 +// locations and check the previous, next link are as expected.
1.53 +// - Check the linked list for empty before inserting, after inserting,
1.54 +// before/after Deque, before/after Enque, after Reset. Verify that results
1.55 +// are as expected.
1.56 +// - Create TDeltaQueBase based object, insert links using DoAddDelta method,
1.57 +// check that links are as expected. Delete links using DoRemove and
1.58 +// DoRemoveFirst methods and check that links are as expected.
1.59 +// - Create TDeltaQueBase based object, insert links using DoAddDelta method,
1.60 +// check the return value of CountDown is as expected. Delete links using
1.61 +// DoRemoveFirst method and check the return value of CountDown is as expected.
1.62 +// - Create TDblQue based object, insert links at front and last, call IsHead,
1.63 +// IsFirst, IsLast, First and Last methods.
1.64 +// - Create TDblQue object, check list for empty before inserting, after
1.65 +// inserting, before/after Deque, before/after Enque, after Reset.
1.66 +// Verify that results are as expected.
1.67 +// - Create TDblQue based object with offset constructor, insert links at
1.68 +// specified locations and check it is added as specified.
1.69 +// - Create TDblQue based object, insert links using AddFirst and AddLast and
1.70 +// check the links are as expected.
1.71 +// - Create TDblQue based object, insert links using AddFirst and AddLast and
1.72 +// check the result of the IsHead, IsFirst and IsLast methods are as expected.
1.73 +// - Create TDblQue based object, insert links using AddFirst and AddLast, check
1.74 +// the results are as expected.
1.75 +// - Create TPriQueLink list without offset, with different offset, check the
1.76 +// construction is as expected.
1.77 +// - Create TPriQueLink list and insert many links at different specified location
1.78 +// and check it is added as specified.
1.79 +// - Create TPriQueLink link with different priorities, insert the elements in
1.80 +// priority order and check that they are added as expected.
1.81 +// - Create TPriQueLink list, check the double linked list for empty before
1.82 +// inserting, after inserting, before/after Deque, before/after Enque, after Reset.
1.83 +// Verify that results are as expected.
1.84 +// - Create TPriQueLink list with different offset, get the list offset and check it
1.85 +// is as expected.
1.86 +// - Create TPriQueLink list, insert many links with different priorities check it is
1.87 +// as expected.
1.88 +// - Create TDeltaQueLink list, add ,remove links and check the links and check
1.89 +// it is as expected.
1.90 +// - Create TDeltaQueLink list and insert many links at different specified location
1.91 +// and check it is added as specified.
1.92 +// - Create TDeltaQueLink list, check the double linked list for empty before, after
1.93 +// inserting, before Deque, after Enque, Reset method call is as expected.
1.94 +// - Create TDeltaQueLink list, insert links using DoAddDelta method,check that
1.95 +// links are as expected. Delete links using DoRemove and DoRemoveFirst methods
1.96 +// and check that links are as expected.
1.97 +// - Create TDeltaQueLink based object, insert links using DoAddDelta method,
1.98 +// check the return value of CountDown is as expected. Delete links using
1.99 +// DoRemoveFirst method and check the return value of CountDown is as expected.
1.100 +// - Create TDeltaQueLink list with different offset, get and check the offset is
1.101 +// as expected.
1.102 +// - Create TDeltaQueLink list, add, remove links at different specified location
1.103 +// and check it is added and removed successfully.
1.104 +// - Initialaize TDblQueIterBase based iterator, get the current item in the queue,
1.105 +// move the current position forward, backward, set the iterator to point to the
1.106 +// first element, last item and check it is as expected.
1.107 +// - Create TDblQueIterBase object with offset constructor, insert links at
1.108 +// specified locations and check it is added as specified.
1.109 +// - Create TDblQueIterBase object, iterate the list using operators, DoPostInc,
1.110 +// DoPostDec, DoCurrent and check it is as expected.
1.111 +// - Create TDblQue based link with specified offset, initialize TDblQueIter
1.112 +// based iterator, iterate the link and check the offset is as expected.
1.113 +// - Create TDblQueIter object with offset constructor, insert links at
1.114 +// specified locations and check it is added as specified.
1.115 +// - Create TDblQueIter object, iterate the list using operators, DoPostInc,
1.116 +// DoPostDec, DoCurrent and check it is as expected.
1.117 +// - Create TDblQueIter based object, insert links using AddFirst and SetToLast,
1.118 +// using IsHead, check the results are as expected.
1.119 +// Platforms/Drives/Compatibility:
1.120 +// All
1.121 +// Assumptions/Requirement/Pre-requisites:
1.122 +// Failures and causes:
1.123 +// Base Port information:
1.124 +//
1.125 +//
1.126 +
1.127 +#include <e32test.h>
1.128 +
1.129 +LOCAL_D RTest test(_L("T_QUE"));
1.130 +
1.131 +#ifndef _DEBUG
1.132 +#pragma warning(disable : 4710) //fuction not expanded
1.133 +#endif
1.134 +
1.135 +#define SIZE 10
1.136 +#define MAX_OFFSET 10
1.137 +
1.138 +struct Item
1.139 + {
1.140 + TDblQueLink iLink;
1.141 + TInt iSpace[MAX_OFFSET]; // Reserve some space
1.142 + };
1.143 +
1.144 +class CItem : public CBase
1.145 + {
1.146 +public:
1.147 + TDblQueLink iLink;
1.148 + //int iSpac[MAX_OFFSET]; // Reserve some space
1.149 + };
1.150 +
1.151 +template<class T>
1.152 +class TestTQueLink
1.153 + {
1.154 +public:
1.155 + void TestQueLinkBase(); // Calls Test: 1.
1.156 + void TestQueLink(); // Calls Test: 1,2.
1.157 + void Test1(); // Test Enque
1.158 + void Test2(); // Test Deque
1.159 +protected:
1.160 + void CreateObjects(TInt aBaseLink);
1.161 + void DestroyObjects();
1.162 +private:
1.163 + void CallTest1();
1.164 + T* iLink[SIZE];
1.165 + };
1.166 +
1.167 +template<class T>
1.168 +void TestTQueLink<T>::CallTest1()
1.169 + {
1.170 + test.Start(_L("Test Enque"));
1.171 + Test1();
1.172 + }
1.173 +
1.174 +template<class T>
1.175 +void TestTQueLink<T>::CreateObjects(TInt aBaseLink)
1.176 + {
1.177 + TInt i;
1.178 +
1.179 + for (i=0;i<SIZE;i++)
1.180 + iLink[i]=new T;
1.181 + if (aBaseLink>=0&&aBaseLink<SIZE)
1.182 + (iLink[aBaseLink])->iNext=(iLink[aBaseLink])->iPrev=iLink[aBaseLink];
1.183 + }
1.184 +
1.185 +template<class T>
1.186 +void TestTQueLink<T>::DestroyObjects()
1.187 + {
1.188 + TInt i;
1.189 +
1.190 + for (i=0;i<SIZE;i++)
1.191 + delete iLink[i];
1.192 + }
1.193 +
1.194 +template<class T>
1.195 +void TestTQueLink<T>::TestQueLinkBase()
1.196 + {
1.197 + CallTest1();
1.198 + test.Next(_L("Finished"));
1.199 + test.End();
1.200 + }
1.201 +
1.202 +template <class T>
1.203 +void TestTQueLink<T>::TestQueLink()
1.204 + {
1.205 + CallTest1();
1.206 + test.Next(_L("Text Deque"));
1.207 + Test2();
1.208 + test.Next(_L("Finished"));
1.209 + test.End();
1.210 + }
1.211 +
1.212 +template<class T>
1.213 +void TestTQueLink<T>::Test1()
1.214 + {
1.215 + CreateObjects(1);
1.216 + test.Start(_L("Check Next and Prev pointers set corectly."));
1.217 + iLink[2]->Enque(iLink[1]);
1.218 + test(iLink[1]->iPrev==iLink[2]);
1.219 + test(iLink[1]->iNext==iLink[2]);
1.220 + test(iLink[2]->iPrev==iLink[1]);
1.221 + test(iLink[2]->iNext==iLink[1]);
1.222 + iLink[3]->Enque(iLink[2]);
1.223 + test(iLink[1]->iPrev==iLink[3]);
1.224 + test(iLink[1]->iNext==iLink[2]);
1.225 + test(iLink[2]->iPrev==iLink[1]);
1.226 + test(iLink[2]->iNext==iLink[3]);
1.227 + test(iLink[3]->iPrev==iLink[2]);
1.228 + test(iLink[3]->iNext==iLink[1]);
1.229 + iLink[4]->Enque(iLink[3]);
1.230 + test(iLink[1]->iPrev==iLink[4]);
1.231 + test(iLink[1]->iNext==iLink[2]);
1.232 + test(iLink[2]->iPrev==iLink[1]);
1.233 + test(iLink[2]->iNext==iLink[3]);
1.234 + test(iLink[3]->iPrev==iLink[2]);
1.235 + test(iLink[3]->iNext==iLink[4]);
1.236 + test(iLink[4]->iPrev==iLink[3]);
1.237 + test(iLink[4]->iNext==iLink[1]);
1.238 + iLink[5]->Enque(iLink[2]);
1.239 + test(iLink[1]->iPrev==iLink[4]);
1.240 + test(iLink[1]->iNext==iLink[2]);
1.241 + test(iLink[2]->iPrev==iLink[1]);
1.242 + test(iLink[2]->iNext==iLink[5]);
1.243 + test(iLink[5]->iPrev==iLink[2]);
1.244 + test(iLink[5]->iNext==iLink[3]);
1.245 + test(iLink[3]->iPrev==iLink[5]);
1.246 + test(iLink[3]->iNext==iLink[4]);
1.247 + test(iLink[4]->iPrev==iLink[3]);
1.248 + test(iLink[4]->iNext==iLink[1]);
1.249 + test.Next(_L("Finished"));
1.250 + DestroyObjects();
1.251 + test.End();
1.252 + }
1.253 +
1.254 +template<class T>
1.255 +void TestTQueLink<T>::Test2()
1.256 + {
1.257 + CreateObjects(1);
1.258 + test.Start(_L("Check Next and Prev pointers set corectly"));
1.259 + iLink[2]->Enque(iLink[1]);
1.260 + iLink[3]->Enque(iLink[2]);
1.261 + iLink[4]->Enque(iLink[3]);
1.262 + iLink[5]->Enque(iLink[4]);
1.263 + iLink[5]->Deque();
1.264 + iLink[5]->Enque(iLink[2]);
1.265 + test(iLink[1]->iPrev==iLink[4]);
1.266 + test(iLink[1]->iNext==iLink[2]);
1.267 + test(iLink[2]->iPrev==iLink[1]);
1.268 + test(iLink[2]->iNext==iLink[5]);
1.269 + test(iLink[5]->iPrev==iLink[2]);
1.270 + test(iLink[5]->iNext==iLink[3]);
1.271 + test(iLink[3]->iPrev==iLink[5]);
1.272 + test(iLink[3]->iNext==iLink[4]);
1.273 + test(iLink[4]->iPrev==iLink[3]);
1.274 + test(iLink[4]->iNext==iLink[1]);
1.275 + iLink[3]->Deque();
1.276 + test(iLink[1]->iPrev==iLink[4]);
1.277 + test(iLink[1]->iNext==iLink[2]);
1.278 + test(iLink[2]->iPrev==iLink[1]);
1.279 + test(iLink[2]->iNext==iLink[5]);
1.280 + test(iLink[5]->iPrev==iLink[2]);
1.281 + test(iLink[5]->iNext==iLink[4]);
1.282 + test(iLink[4]->iPrev==iLink[5]);
1.283 + test(iLink[4]->iNext==iLink[1]);
1.284 + iLink[1]->Deque();
1.285 + test(iLink[2]->iPrev==iLink[4]);
1.286 + test(iLink[2]->iNext==iLink[5]);
1.287 + test(iLink[5]->iPrev==iLink[2]);
1.288 + test(iLink[5]->iNext==iLink[4]);
1.289 + test(iLink[4]->iPrev==iLink[5]);
1.290 + test(iLink[4]->iNext==iLink[2]);
1.291 + iLink[4]->Deque();
1.292 + test(iLink[2]->iPrev==iLink[5]);
1.293 + test(iLink[2]->iNext==iLink[5]);
1.294 + test(iLink[5]->iPrev==iLink[2]);
1.295 + test(iLink[5]->iNext==iLink[2]);
1.296 + test.Next(_L("Finished"));
1.297 + DestroyObjects();
1.298 + test.End();
1.299 + }
1.300 +
1.301 +class VDblQueBase : public TDblQueBase
1.302 + {
1.303 +public:
1.304 + VDblQueBase();
1.305 + VDblQueBase(TInt anOffset);
1.306 + inline void sDoAddFirst(TAny* aPtr) {DoAddFirst(aPtr);}
1.307 + inline void sDoAddLast(TAny* aPtr) {DoAddLast(aPtr);}
1.308 + inline void sDoAddPriority(TAny* aPtr) {DoAddPriority(aPtr);}
1.309 + inline void sTestEmpty() const {__DbgTestEmpty();}
1.310 + TDblQueLink* sHead;
1.311 + TInt* sOffset;
1.312 +private:
1.313 + void SetMembers();
1.314 + };
1.315 +
1.316 +class VDeltaQueBase : public TDeltaQueBase
1.317 + {
1.318 +public:
1.319 + VDeltaQueBase();
1.320 + VDeltaQueBase(TInt anOffset);
1.321 + inline void sDoAddDelta(TAny* aPtr,TInt aDelta) {DoAddDelta(aPtr,aDelta);} //From TDeltaQueBase
1.322 + inline void sDoRemove(TAny* aPtr) {this->DoRemove(aPtr);}
1.323 + inline TAny* sDoRemoveFirst() {return this->DoRemoveFirst();}
1.324 + TInt** sFirstDelta;
1.325 + inline void sDoAddFirst(TAny* aPtr) {DoAddFirst(aPtr);} //From TDblQueBase
1.326 + inline void sDoAddLast(TAny* aPtr) {DoAddLast(aPtr);}
1.327 + inline void sDoAddPriority(TAny* aPtr) {DoAddPriority(aPtr);}
1.328 + TDblQueLink* sHead;
1.329 + TInt* sOffset;
1.330 +private:
1.331 + void SetMembers();
1.332 + };
1.333 +
1.334 +template <class T>
1.335 +class VDblQue : public TDblQue<T>
1.336 + {
1.337 +public:
1.338 + VDblQue();
1.339 + VDblQue(TInt anOffset);
1.340 + /*inline void sDoAddDelta(TAny* aPtr,TInt aDelta) {DoAddDelta(aPtr,aDelta);} //From TDeltaQueBase
1.341 + inline void sDoRemove(TAny* aPtr) {this->DoRemove(aPtr);}
1.342 + inline TAny* sDoRemoveFirst() {return this->DoRemoveFirst();}
1.343 + TInt** sFirstDelta;*/
1.344 + inline void sDoAddFirst(TAny* aPtr) {this->DoAddFirst(aPtr);} //From TDblQueBase
1.345 + inline void sDoAddLast(TAny* aPtr) {this->DoAddLast(aPtr);}
1.346 + inline void sDoAddPriority(TAny* aPtr) {this->DoAddPriority(aPtr);}
1.347 + TDblQueLink* sHead;
1.348 + TInt* sOffset;
1.349 +private:
1.350 + void SetMembers();
1.351 + };
1.352 +
1.353 +template <class T>
1.354 +class VPriQue : public TPriQue<T>
1.355 + {
1.356 +public:
1.357 + VPriQue();
1.358 + VPriQue(TInt anOffset);
1.359 + /*inline void sDoAddDelta(TAny* aPtr,TInt aDelta) {DoAddDelta(aPtr,aDelta);} //From TDeltaQueBase
1.360 + inline void sDoRemove(TAny* aPtr) {this->DoRemove(aPtr);}
1.361 + inline TAny* sDoRemoveFirst() {return this->DoRemoveFirst();}
1.362 + TInt** sFirstDelta;*/
1.363 + inline void sDoAddFirst(TAny* aPtr) {this->DoAddFirst(aPtr);} //From TDblQueBase
1.364 + inline void sDoAddLast(TAny* aPtr) {this->DoAddLast(aPtr);}
1.365 + inline void sDoAddPriority(TAny* aPtr) {this->DoAddPriority(aPtr);}
1.366 + TDblQueLink* sHead;
1.367 + TInt* sOffset;
1.368 +private:
1.369 + void SetMembers();
1.370 + };
1.371 +
1.372 +template <class T>
1.373 +class VDeltaQue : public TDeltaQue<T>
1.374 + {
1.375 +public:
1.376 + VDeltaQue();
1.377 + VDeltaQue(TInt anOffset);
1.378 + inline void sDoAddDelta(TAny* aPtr,TInt aDelta) {this->DoAddDelta(aPtr,aDelta);} //From TDeltaQueBase
1.379 + inline void sDoRemove(TAny* aPtr) {this->DoRemove(aPtr);}
1.380 + inline TAny* sDoRemoveFirst() {return this->DoRemoveFirst();}
1.381 + TInt** sFirstDelta;
1.382 + inline void sDoAddFirst(TAny* aPtr) {this->DoAddFirst(aPtr);} //From TDblQueBase
1.383 + inline void sDoAddLast(TAny* aPtr) {this->DoAddLast(aPtr);}
1.384 + inline void sDoAddPriority(TAny* aPtr) {this->DoAddPriority(aPtr);}
1.385 + TDblQueLink* sHead;
1.386 + TInt* sOffset;
1.387 +private:
1.388 + void SetMembers();
1.389 + };
1.390 +
1.391 +VDblQueBase::VDblQueBase()
1.392 + {
1.393 + SetMembers();
1.394 + }
1.395 +
1.396 +VDblQueBase::VDblQueBase(TInt anOffset)
1.397 + :TDblQueBase(anOffset)
1.398 + {
1.399 + SetMembers();
1.400 + }
1.401 +
1.402 +void VDblQueBase::SetMembers()
1.403 + {
1.404 + sHead=&iHead;
1.405 + sOffset=&iOffset;
1.406 + }
1.407 +
1.408 +VDeltaQueBase::VDeltaQueBase()
1.409 + {
1.410 + SetMembers();
1.411 + }
1.412 +
1.413 +VDeltaQueBase::VDeltaQueBase(TInt anOffset)
1.414 + :TDeltaQueBase(anOffset)
1.415 + {
1.416 + SetMembers();
1.417 + }
1.418 +
1.419 +void VDeltaQueBase::SetMembers()
1.420 + {
1.421 + sFirstDelta=&iFirstDelta;
1.422 + sHead=&iHead;
1.423 + sOffset=&iOffset;
1.424 + }
1.425 +
1.426 +template <class T>
1.427 +VDblQue<T>::VDblQue()
1.428 + {
1.429 + SetMembers();
1.430 + }
1.431 +
1.432 +template <class T>
1.433 +VDblQue<T>::VDblQue(TInt anOffset)
1.434 + :TDblQue<T>(anOffset)
1.435 + {
1.436 + SetMembers();
1.437 + }
1.438 +
1.439 +template <class T>
1.440 +void VDblQue<T>::SetMembers()
1.441 + {
1.442 + //sFirstDelta=&iFirstDelta;
1.443 + sHead=&this->iHead;
1.444 + sOffset=&this->iOffset;
1.445 + }
1.446 +
1.447 +template <class T>
1.448 +VPriQue<T>::VPriQue()
1.449 + {
1.450 + SetMembers();
1.451 + }
1.452 +
1.453 +template <class T>
1.454 +VPriQue<T>::VPriQue(TInt anOffset)
1.455 + :TPriQue<T>(anOffset)
1.456 + {
1.457 + SetMembers();
1.458 + }
1.459 +
1.460 +template <class T>
1.461 +void VPriQue<T>::SetMembers()
1.462 + {
1.463 + //sFirstDelta=&iFirstDelta;
1.464 + sHead=&this->iHead;
1.465 + sOffset=&this->iOffset;
1.466 + }
1.467 +
1.468 +template <class T>
1.469 +VDeltaQue<T>::VDeltaQue()
1.470 + {
1.471 + SetMembers();
1.472 + }
1.473 +
1.474 +template <class T>
1.475 +VDeltaQue<T>::VDeltaQue(TInt anOffset)
1.476 + :TDeltaQue<T>(anOffset)
1.477 + {
1.478 + SetMembers();
1.479 + }
1.480 +
1.481 +template <class T>
1.482 +void VDeltaQue<T>::SetMembers()
1.483 + {
1.484 + sFirstDelta=&this->iFirstDelta;
1.485 + sHead=&this->iHead;
1.486 + sOffset=&this->iOffset;
1.487 + }
1.488 +
1.489 +template<class T>
1.490 +class TestTQue
1.491 + {
1.492 +friend class TestTQueLink<TDblQueLinkBase>;
1.493 +public:
1.494 + void TestQueBase();
1.495 + void TestDeltaBase();
1.496 + void TestDblQue();
1.497 + void TestPriQue();
1.498 + void TestDeltaQue();
1.499 + void Test1(); // All functions //TDblQueBase functions
1.500 + void Test2(); // Constructors
1.501 + void Test3(TBool aTestPri); // DoAdd's
1.502 + void Test4(); // Public functions
1.503 + void Test5(); // All functions //TDblDeltaQueBase
1.504 + void Test6(); // Constructors
1.505 + void Test7(); // Do's
1.506 + void Test8(); // CountDown
1.507 + void Test9(); // All functions //TDblQueBase
1.508 + void Test10(); // Constructors
1.509 + void Test11(); // Add's
1.510 + void Test12(); // Is's
1.511 + void Test13(); // Get's
1.512 + void Test14(); // All functions //TPriQue
1.513 + void Test15(); // Constructors
1.514 + void Test16(); // Add
1.515 + void Test17(); // All functions //TDeltaQue
1.516 + void Test18(); // Constructors
1.517 + void Test19(); // Add/Remove
1.518 +private:
1.519 + void CallTest3_4(TBool aTestPri);
1.520 + void CallTest7_8();
1.521 + };
1.522 +
1.523 +template<class T>
1.524 +void TestTQue<T>::CallTest3_4(TBool aTestPri)
1.525 + {
1.526 + test.Next(_L("Test DoAdd's"));
1.527 + Test3(aTestPri);
1.528 + test.Next(_L("Test public functions"));
1.529 + Test4();
1.530 + }
1.531 +
1.532 +template<class T>
1.533 +void TestTQue<T>::CallTest7_8()
1.534 + {
1.535 + test.Next(_L("Test Do's"));
1.536 + Test7();
1.537 + test.Next(_L("CountDown"));
1.538 + Test8();
1.539 + }
1.540 +
1.541 +template<class T>
1.542 +void TestTQue<T>::TestQueBase()
1.543 + {
1.544 + test.Start(_L("Test all member functions (simply)"));
1.545 + Test1();
1.546 + test.Next(_L("Test Constructors"));
1.547 + Test2();
1.548 + CallTest3_4(ETrue);
1.549 + test.Next(_L("Finished"));
1.550 + test.End();
1.551 + }
1.552 +
1.553 +template<class T>
1.554 +void TestTQue<T>::TestDeltaBase()
1.555 + {
1.556 + test.Start(_L("Test all member functions (simply)"));
1.557 + Test5();
1.558 + CallTest3_4(EFalse);
1.559 + test.Next(_L("Test Constructors"));
1.560 + Test6();
1.561 + CallTest7_8();
1.562 + test.Next(_L("Finished"));
1.563 + test.End();
1.564 + }
1.565 +
1.566 +template<class T>
1.567 +void TestTQue<T>::TestDblQue()
1.568 + {
1.569 + test.Start(_L("Test all member functions (simply)"));
1.570 + Test9();
1.571 + CallTest3_4(EFalse);
1.572 + test.Next(_L("Test Constructor"));
1.573 + Test10();
1.574 + test.Next(_L("Test Add's"));
1.575 + Test11();
1.576 + test.Next(_L("Test Is's"));
1.577 + Test12();
1.578 + test.Next(_L("Get's"));
1.579 + Test13();
1.580 + test.Next(_L("Finished"));
1.581 + test.End();
1.582 + }
1.583 +
1.584 +template<class T>
1.585 +void TestTQue<T>::TestPriQue()
1.586 + {
1.587 + test.Start(_L("Test all member functions (simply)"));
1.588 + Test14();
1.589 + CallTest3_4(ETrue);
1.590 + test.Next(_L("Test Constructor"));
1.591 + Test15();
1.592 + test.Next(_L("Test Add"));
1.593 + Test16();
1.594 + test.Next(_L("Finished"));
1.595 + test.End();
1.596 + }
1.597 +
1.598 +template<class T>
1.599 +void TestTQue<T>::TestDeltaQue()
1.600 + {
1.601 + test.Start(_L("Test all member functions (simply)"));
1.602 + Test17();
1.603 + CallTest3_4(EFalse);
1.604 + CallTest7_8();
1.605 + test.Next(_L("Test Constructor"));
1.606 + Test18();
1.607 + test.Next(_L("Test Add/Removes"));
1.608 + Test19();
1.609 + test.Next(_L("Finished"));
1.610 + test.End();
1.611 + }
1.612 +
1.613 +template<class T>
1.614 +void TestTQue<T>::Test1()
1.615 + {
1.616 + T* que;
1.617 + TPriQueLink link1,link2;
1.618 + TInt offset=4;
1.619 +
1.620 + test.Start(_L("Constructors"));
1.621 + que=new VDblQueBase(offset);
1.622 + delete que;
1.623 + que=new VDblQueBase;
1.624 + //delete que;
1.625 + test.Next(_L("DoAdd's"));
1.626 + que->sDoAddFirst(&link1);
1.627 + link1.Deque();
1.628 + que->sDoAddLast(&link1);
1.629 + link1.iPriority=1;
1.630 + link2.iPriority=2;
1.631 + que->sDoAddPriority(&link2);
1.632 + test.Next(_L("Public"));
1.633 + que->IsEmpty();
1.634 + que->SetOffset(offset);
1.635 + que->Reset();
1.636 + test.Next(_L("Finished"));
1.637 + delete que;
1.638 + test.End();
1.639 + }
1.640 +
1.641 +template<class T>
1.642 +void TestTQue<T>::Test2()
1.643 + {
1.644 + T* que;
1.645 + TInt offset;
1.646 +
1.647 + test.Start(_L("Default constructor"));
1.648 + que=new VDblQueBase();
1.649 + test(*(que->sOffset)==0);
1.650 + test(que->sHead->iNext==que->sHead);
1.651 + test(que->sHead->iPrev==que->sHead);
1.652 + delete que;
1.653 + test.Next(_L("Offset constructor"));
1.654 + for (offset=0;offset<40;offset+=4)
1.655 + {
1.656 + que=new VDblQueBase(offset);
1.657 + test(*(que->sOffset)==offset);
1.658 + test(que->sHead->iNext==que->sHead);
1.659 + test(que->sHead->iPrev==que->sHead);
1.660 + delete que;
1.661 + }
1.662 + test.Next(_L("Finished"));
1.663 + test.End();
1.664 + }
1.665 +
1.666 +template<class T>
1.667 +void TestTQue<T>::Test3(TBool aTestPri)
1.668 + {
1.669 + T* que;
1.670 + TDblQueLink link1,link2,link3,link4;
1.671 +
1.672 + test.Start(_L("AddFirst"));
1.673 + que=new T();
1.674 + que->sDoAddFirst(&link1);
1.675 + test(que->sHead->iNext==&link1);
1.676 + test(que->sHead->iPrev==&link1);
1.677 + test(link1.iNext==que->sHead);
1.678 + test(link1.iPrev==que->sHead);
1.679 + que->sDoAddFirst(&link2);
1.680 + test(que->sHead->iNext==&link2);
1.681 + test(que->sHead->iPrev==&link1);
1.682 + test(link1.iNext==que->sHead);
1.683 + test(link1.iPrev==&link2);
1.684 + test(link2.iNext==&link1);
1.685 + test(link2.iPrev==que->sHead);
1.686 + que->sDoAddFirst(&link3);
1.687 + test(que->sHead->iNext==&link3);
1.688 + test(que->sHead->iPrev==&link1);
1.689 + test(link1.iNext==que->sHead);
1.690 + test(link1.iPrev==&link2);
1.691 + test(link2.iNext==&link1);
1.692 + test(link2.iPrev==&link3);
1.693 + test(link3.iNext==&link2);
1.694 + test(link3.iPrev==que->sHead);
1.695 + que->sDoAddFirst(&link4);
1.696 + test(que->sHead->iNext==&link4);
1.697 + test(que->sHead->iPrev==&link1);
1.698 + test(link1.iNext==que->sHead);
1.699 + test(link1.iPrev==&link2);
1.700 + test(link2.iNext==&link1);
1.701 + test(link2.iPrev==&link3);
1.702 + test(link3.iNext==&link2);
1.703 + test(link3.iPrev==&link4);
1.704 + test(link4.iNext==&link3);
1.705 + test(link4.iPrev==que->sHead);
1.706 + link1.Deque();
1.707 + link2.Deque();
1.708 + link3.Deque();
1.709 + link4.Deque();
1.710 + delete que;
1.711 + test.Next(_L("AddLast"));
1.712 + que=new T();
1.713 + que->sDoAddLast(&link1);
1.714 + test(que->sHead->iNext==&link1);
1.715 + test(que->sHead->iPrev==&link1);
1.716 + test(link1.iNext==que->sHead);
1.717 + test(link1.iPrev==que->sHead);
1.718 + que->sDoAddLast(&link2);
1.719 + test(que->sHead->iNext==&link1);
1.720 + test(que->sHead->iPrev==&link2);
1.721 + test(link1.iNext==&link2);
1.722 + test(link1.iPrev==que->sHead);
1.723 + test(link2.iNext==que->sHead);
1.724 + test(link2.iPrev==&link1);
1.725 + que->sDoAddLast(&link3);
1.726 + test(que->sHead->iNext==&link1);
1.727 + test(que->sHead->iPrev==&link3);
1.728 + test(link1.iNext==&link2);
1.729 + test(link1.iPrev==que->sHead);
1.730 + test(link2.iNext==&link3);
1.731 + test(link2.iPrev==&link1);
1.732 + test(link3.iNext==que->sHead);
1.733 + test(link3.iPrev==&link2);
1.734 + que->sDoAddLast(&link4);
1.735 + test(que->sHead->iNext==&link1);
1.736 + test(que->sHead->iPrev==&link4);
1.737 + test(link1.iNext==&link2);
1.738 + test(link1.iPrev==que->sHead);
1.739 + test(link2.iNext==&link3);
1.740 + test(link2.iPrev==&link1);
1.741 + test(link3.iNext==&link4);
1.742 + test(link3.iPrev==&link2);
1.743 + test(link4.iNext==que->sHead);
1.744 + test(link4.iPrev==&link3);
1.745 + link1.Deque();
1.746 + link2.Deque();
1.747 + link3.Deque();
1.748 + link4.Deque();
1.749 + delete que;
1.750 + test.Next(_L("Combined AddFirst and AddLast"));
1.751 + que=new T();
1.752 + que->sDoAddFirst(&link1);
1.753 + que->sDoAddLast(&link2);
1.754 + test(que->sHead->iNext==&link1);
1.755 + test(que->sHead->iPrev==&link2);
1.756 + test(link1.iNext==&link2);
1.757 + test(link1.iPrev==que->sHead);
1.758 + test(link2.iNext==que->sHead);
1.759 + test(link2.iPrev==&link1);
1.760 + que->sDoAddFirst(&link3);
1.761 + test(que->sHead->iNext==&link3);
1.762 + test(que->sHead->iPrev==&link2);
1.763 + test(link1.iNext==&link2);
1.764 + test(link1.iPrev==&link3);
1.765 + test(link2.iNext==que->sHead);
1.766 + test(link2.iPrev==&link1);
1.767 + test(link3.iNext==&link1);
1.768 + test(link3.iPrev==que->sHead);
1.769 + que->sDoAddLast(&link4);
1.770 + test(que->sHead->iNext==&link3);
1.771 + test(que->sHead->iPrev==&link4);
1.772 + test(link1.iNext==&link2);
1.773 + test(link1.iPrev==&link3);
1.774 + test(link2.iNext==&link4);
1.775 + test(link2.iPrev==&link1);
1.776 + test(link3.iNext==&link1);
1.777 + test(link3.iPrev==que->sHead);
1.778 + test(link4.iNext==que->sHead);
1.779 + test(link4.iPrev==&link2);
1.780 + link1.Deque();
1.781 + link2.Deque();
1.782 + link3.Deque();
1.783 + link4.Deque();
1.784 + delete que;
1.785 + if (aTestPri)
1.786 + {
1.787 + TPriQueLink link5,link6,link7,link8,link9,link10;
1.788 +
1.789 + test.Next(_L("AddPriority"));
1.790 + que=new T();
1.791 + link5.iPriority=4;
1.792 + link6.iPriority=6;
1.793 + link7.iPriority=8;
1.794 + que->sDoAddPriority(&link5);
1.795 + que->sDoAddPriority(&link6);
1.796 + que->sDoAddPriority(&link7);
1.797 + test(que->sHead->iNext==&link7);
1.798 + test(que->sHead->iPrev==&link5);
1.799 + test(link5.iNext==que->sHead);
1.800 + test(link5.iPrev==&link6);
1.801 + test(link6.iNext==&link5);
1.802 + test(link6.iPrev==&link7);
1.803 + test(link7.iNext==&link6);
1.804 + test(link7.iPrev==que->sHead);
1.805 + link8.iPriority=7;
1.806 + que->sDoAddPriority(&link8);
1.807 + test(que->sHead->iNext==&link7);
1.808 + test(que->sHead->iPrev==&link5);
1.809 + test(link5.iNext==que->sHead);
1.810 + test(link5.iPrev==&link6);
1.811 + test(link6.iNext==&link5);
1.812 + test(link6.iPrev==&link8);
1.813 + test(link7.iNext==&link8);
1.814 + test(link7.iPrev==que->sHead);
1.815 + test(link8.iPrev==&link7);
1.816 + test(link8.iNext==&link6);
1.817 + link9.iPriority=5;
1.818 + que->sDoAddPriority(&link9);
1.819 + test(que->sHead->iNext==&link7);
1.820 + test(que->sHead->iPrev==&link5);
1.821 + test(link5.iNext==que->sHead);
1.822 + test(link5.iPrev==&link9);
1.823 + test(link6.iNext==&link9);
1.824 + test(link6.iPrev==&link8);
1.825 + test(link7.iNext==&link8);
1.826 + test(link7.iPrev==que->sHead);
1.827 + test(link8.iPrev==&link7);
1.828 + test(link8.iNext==&link6);
1.829 + test(link9.iPrev==&link6);
1.830 + test(link9.iNext==&link5);
1.831 + link10.iPriority=3;
1.832 + que->sDoAddPriority(&link10);
1.833 + test(que->sHead->iNext==&link7);
1.834 + test(que->sHead->iPrev==&link10);
1.835 + test(link5.iNext==&link10);
1.836 + test(link5.iPrev==&link9);
1.837 + test(link6.iNext==&link9);
1.838 + test(link6.iPrev==&link8);
1.839 + test(link7.iNext==&link8);
1.840 + test(link7.iPrev==que->sHead);
1.841 + test(link8.iPrev==&link7);
1.842 + test(link8.iNext==&link6);
1.843 + test(link9.iPrev==&link6);
1.844 + test(link9.iNext==&link5);
1.845 + test(link10.iNext==que->sHead);
1.846 + test(link10.iPrev==&link5);
1.847 + link5.Deque();
1.848 + link6.Deque();
1.849 + link7.Deque();
1.850 + link8.Deque();
1.851 + delete que;
1.852 + }
1.853 + test.Next(_L("Finished"));
1.854 + test.End();
1.855 + }
1.856 +
1.857 +template<class T>
1.858 +void TestTQue<T>::Test4()
1.859 + {
1.860 + T* que;
1.861 + TInt offset;
1.862 +
1.863 + test.Start(_L("IsEmpty"));
1.864 + que=new T();
1.865 + test(que->IsEmpty()==TRUE);
1.866 + TDblQueLink link1,link2;
1.867 + que->sDoAddFirst(&link1);
1.868 + test(que->IsEmpty()==FALSE);
1.869 + link1.Deque();
1.870 + test(que->IsEmpty()==TRUE);
1.871 + que->sDoAddLast(&link2);
1.872 + test(que->IsEmpty()==FALSE);
1.873 + link1.Enque(&link2);
1.874 + test(que->IsEmpty()==FALSE);
1.875 + link2.Deque();
1.876 + test(que->IsEmpty()==FALSE);
1.877 + link1.Deque();
1.878 + test(que->IsEmpty()==TRUE);
1.879 + test.Next(_L("Reset"));
1.880 + que->sDoAddFirst(&link1);
1.881 + test(que->IsEmpty()==FALSE);
1.882 + que->Reset();
1.883 + test(que->IsEmpty()==TRUE);
1.884 + test.Next(_L("SetOffset"));
1.885 + for (offset=0;offset<40;offset+=4)
1.886 + {
1.887 + que->SetOffset(offset);
1.888 + test(*(que->sOffset)==offset);
1.889 + }
1.890 + test.Next(_L("Finished"));
1.891 + delete que;
1.892 + test.End();
1.893 + }
1.894 +
1.895 +template<class T>
1.896 +void TestTQue<T>::Test5()
1.897 + {
1.898 + T* que;
1.899 + TDeltaQueLink link1,link2,link3;
1.900 + TInt offset=4;
1.901 +
1.902 + test.Start(_L("Constructors"));
1.903 + que=new VDeltaQueBase(offset);
1.904 + delete que;
1.905 + que=new VDeltaQueBase;
1.906 + test.Next(_L("Do's"));
1.907 + que->sDoAddDelta(&link1,3);
1.908 + que->sDoAddDelta(&link2,2);
1.909 + que->sDoAddDelta(&link3,0);
1.910 + que->sDoRemoveFirst();
1.911 + que->sDoRemove(&link2);
1.912 + test.Next(_L("CountDown"));
1.913 + que->CountDown();
1.914 + test.Next(_L("Finished"));
1.915 + delete que;
1.916 + test.End();
1.917 + }
1.918 +
1.919 +template<class T>
1.920 +void TestTQue<T>::Test6()
1.921 + {
1.922 + T* que;
1.923 + TInt offset;
1.924 +
1.925 + test.Start(_L("Default constructor"));
1.926 + que=new VDeltaQueBase();
1.927 + test(*(que->sFirstDelta)==NULL);
1.928 + delete que;
1.929 + test.Next(_L("Offset constructor"));
1.930 + for (offset=0;offset<40;offset+=4)
1.931 + {
1.932 + que=new VDeltaQueBase(offset);
1.933 + test(*(que->sOffset)==offset);
1.934 + test(*(que->sFirstDelta)==NULL);
1.935 + delete que;
1.936 + }
1.937 + test.Next(_L("Finished"));
1.938 + test.End();
1.939 + }
1.940 +
1.941 +template<class T>
1.942 +void TestTQue<T>::Test7()
1.943 + {
1.944 + T* que;
1.945 + TDeltaQueLink link1,link2,link3,link4,link5,link6;
1.946 +
1.947 + test.Start(_L("DoAddDelta"));
1.948 + que=new T();
1.949 + que->sDoAddDelta(&link2,3);
1.950 + test(*(que->sFirstDelta)==&link2.iDelta);
1.951 + test(link2.iDelta==3);
1.952 + que->sDoAddDelta(&link5,15);
1.953 + test(*(que->sFirstDelta)==&link2.iDelta);
1.954 + test(link2.iDelta==3);
1.955 + test(link5.iDelta==12);
1.956 + que->sDoAddDelta(&link3,6);
1.957 + test(*(que->sFirstDelta)==&link2.iDelta);
1.958 + test(link2.iDelta==3);
1.959 + test(link3.iDelta==3);
1.960 + test(link5.iDelta==9);
1.961 + que->sDoAddDelta(&link4,10);
1.962 + test(*(que->sFirstDelta)==&link2.iDelta);
1.963 + test(link2.iDelta==3);
1.964 + test(link3.iDelta==3);
1.965 + test(link4.iDelta==4);
1.966 + test(link5.iDelta==5);
1.967 + que->sDoAddDelta(&link1,1);
1.968 + test(*(que->sFirstDelta)==&link1.iDelta);
1.969 + test(link1.iDelta==1);
1.970 + test(link2.iDelta==2);
1.971 + test(link3.iDelta==3);
1.972 + test(link4.iDelta==4);
1.973 + test(link5.iDelta==5);
1.974 + que->sDoAddDelta(&link6,21);
1.975 + test(*(que->sFirstDelta)==&link1.iDelta);
1.976 + test(link1.iDelta==1);
1.977 + test(link2.iDelta==2);
1.978 + test(link3.iDelta==3);
1.979 + test(link4.iDelta==4);
1.980 + test(link5.iDelta==5);
1.981 + test(link6.iDelta==6);
1.982 + test.Next(_L("DoRemove"));
1.983 + que->sDoRemove(&link6);
1.984 + test(*(que->sFirstDelta)==&link1.iDelta);
1.985 + test(link1.iDelta==1);
1.986 + test(link2.iDelta==2);
1.987 + test(link3.iDelta==3);
1.988 + test(link4.iDelta==4);
1.989 + test(link5.iDelta==5);
1.990 + que->sDoRemove(&link1);
1.991 + test(*(que->sFirstDelta)==&link2.iDelta);
1.992 + test(link2.iDelta==3);
1.993 + test(link3.iDelta==3);
1.994 + test(link4.iDelta==4);
1.995 + test(link5.iDelta==5);
1.996 + que->sDoRemove(&link4);
1.997 + test(*(que->sFirstDelta)==&link2.iDelta);
1.998 + test(link2.iDelta==3);
1.999 + test(link3.iDelta==3);
1.1000 + test(link5.iDelta==9);
1.1001 + que->sDoRemove(&link3);
1.1002 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1003 + test(link2.iDelta==3);
1.1004 + test(link5.iDelta==12);
1.1005 + que->sDoRemove(&link5);
1.1006 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1007 + test(link2.iDelta==3);
1.1008 + test.Next(_L("DoRemoveFirst"));
1.1009 + test(NULL==que->sDoRemoveFirst());
1.1010 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1011 + test(link2.iDelta==3);
1.1012 + link2.iDelta=1;
1.1013 + test(NULL==que->sDoRemoveFirst());
1.1014 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1015 + test(link2.iDelta==1);
1.1016 + link2.iDelta=0;
1.1017 + test(&link2==que->sDoRemoveFirst());
1.1018 + delete que;
1.1019 + test.Next(_L("Finished"));
1.1020 + test.End();
1.1021 + }
1.1022 +
1.1023 +template<class T>
1.1024 +void TestTQue<T>::Test8()
1.1025 + {
1.1026 + T* que;
1.1027 + TDeltaQueLink link1,link2,link3;
1.1028 +
1.1029 + que=new T();
1.1030 + que->sDoAddDelta(&link1,1);
1.1031 + que->sDoAddDelta(&link2,3);
1.1032 + que->sDoAddDelta(&link3,6);
1.1033 + test(que->CountDown()==TRUE);
1.1034 + que->sDoRemoveFirst();
1.1035 + test(que->CountDown()==FALSE);
1.1036 + test(que->CountDown()==TRUE);
1.1037 + que->sDoRemoveFirst();
1.1038 + test(que->CountDown()==FALSE);
1.1039 + test(que->CountDown()==FALSE);
1.1040 + test(que->CountDown()==TRUE);
1.1041 + que->sDoRemoveFirst();
1.1042 + delete que;
1.1043 + }
1.1044 +
1.1045 +template<class T>
1.1046 +void TestTQue<T>::Test9()
1.1047 + {
1.1048 + T* que;
1.1049 + TDblQueLink link1,link2;
1.1050 + TInt offset=4;
1.1051 +
1.1052 + test.Start(_L("Constructors"));
1.1053 + que=new VDblQue<TDblQueLink>(offset);
1.1054 + delete que;
1.1055 + que=new VDblQue<TDblQueLink>;
1.1056 + test.Next(_L("Add's"));
1.1057 + que->AddFirst(link1);
1.1058 + que->AddLast(link2);
1.1059 + test.Next(_L("Is's"));
1.1060 + que->IsHead(que->sHead);
1.1061 + que->IsFirst(&link1);
1.1062 + que->IsLast(&link2);
1.1063 + test.Next(_L("Get's"));
1.1064 + que->First();
1.1065 + que->Last();
1.1066 + test.Next(_L("Finished"));
1.1067 + delete que;
1.1068 + test.End();
1.1069 + }
1.1070 +
1.1071 +template<class T>
1.1072 +void TestTQue<T>::Test10()
1.1073 + {
1.1074 + T* que;
1.1075 + TInt offset;
1.1076 +
1.1077 + test.Start(_L("Offset constructor"));
1.1078 + for (offset=0;offset<40;offset+=4)
1.1079 + {
1.1080 + que=new VDblQue<TDblQueLink>(offset);
1.1081 + test(*(que->sOffset)==offset);
1.1082 + delete que;
1.1083 + }
1.1084 + test.Next(_L("Finished"));
1.1085 + test.End();
1.1086 + }
1.1087 +
1.1088 +template<class T>
1.1089 +void TestTQue<T>::Test11()
1.1090 + {
1.1091 + T* que;
1.1092 + TDblQueLink link1,link2,link3,link4;
1.1093 +
1.1094 + test.Start(_L("AddFirst"));
1.1095 + que=new T();
1.1096 + que->AddFirst(link1);
1.1097 + test(que->sHead->iNext==&link1);
1.1098 + test(que->sHead->iPrev==&link1);
1.1099 + test(link1.iNext==que->sHead);
1.1100 + test(link1.iPrev==que->sHead);
1.1101 + que->AddFirst(link2);
1.1102 + test(que->sHead->iNext==&link2);
1.1103 + test(que->sHead->iPrev==&link1);
1.1104 + test(link1.iNext==que->sHead);
1.1105 + test(link1.iPrev==&link2);
1.1106 + test(link2.iNext==&link1);
1.1107 + test(link2.iPrev==que->sHead);
1.1108 + que->AddFirst(link3);
1.1109 + test(que->sHead->iNext==&link3);
1.1110 + test(que->sHead->iPrev==&link1);
1.1111 + test(link1.iNext==que->sHead);
1.1112 + test(link1.iPrev==&link2);
1.1113 + test(link2.iNext==&link1);
1.1114 + test(link2.iPrev==&link3);
1.1115 + test(link3.iNext==&link2);
1.1116 + test(link3.iPrev==que->sHead);
1.1117 + que->AddFirst(link4);
1.1118 + test(que->sHead->iNext==&link4);
1.1119 + test(que->sHead->iPrev==&link1);
1.1120 + test(link1.iNext==que->sHead);
1.1121 + test(link1.iPrev==&link2);
1.1122 + test(link2.iNext==&link1);
1.1123 + test(link2.iPrev==&link3);
1.1124 + test(link3.iNext==&link2);
1.1125 + test(link3.iPrev==&link4);
1.1126 + test(link4.iNext==&link3);
1.1127 + test(link4.iPrev==que->sHead);
1.1128 + link1.Deque();
1.1129 + link2.Deque();
1.1130 + link3.Deque();
1.1131 + link4.Deque();
1.1132 + delete que;
1.1133 + test.Next(_L("AddLast"));
1.1134 + que=new T();
1.1135 + que->AddLast(link1);
1.1136 + test(que->sHead->iNext==&link1);
1.1137 + test(que->sHead->iPrev==&link1);
1.1138 + test(link1.iNext==que->sHead);
1.1139 + test(link1.iPrev==que->sHead);
1.1140 + que->AddLast(link2);
1.1141 + test(que->sHead->iNext==&link1);
1.1142 + test(que->sHead->iPrev==&link2);
1.1143 + test(link1.iNext==&link2);
1.1144 + test(link1.iPrev==que->sHead);
1.1145 + test(link2.iNext==que->sHead);
1.1146 + test(link2.iPrev==&link1);
1.1147 + que->AddLast(link3);
1.1148 + test(que->sHead->iNext==&link1);
1.1149 + test(que->sHead->iPrev==&link3);
1.1150 + test(link1.iNext==&link2);
1.1151 + test(link1.iPrev==que->sHead);
1.1152 + test(link2.iNext==&link3);
1.1153 + test(link2.iPrev==&link1);
1.1154 + test(link3.iNext==que->sHead);
1.1155 + test(link3.iPrev==&link2);
1.1156 + que->AddLast(link4);
1.1157 + test(que->sHead->iNext==&link1);
1.1158 + test(que->sHead->iPrev==&link4);
1.1159 + test(link1.iNext==&link2);
1.1160 + test(link1.iPrev==que->sHead);
1.1161 + test(link2.iNext==&link3);
1.1162 + test(link2.iPrev==&link1);
1.1163 + test(link3.iNext==&link4);
1.1164 + test(link3.iPrev==&link2);
1.1165 + test(link4.iNext==que->sHead);
1.1166 + test(link4.iPrev==&link3);
1.1167 + link1.Deque();
1.1168 + link2.Deque();
1.1169 + link3.Deque();
1.1170 + link4.Deque();
1.1171 + delete que;
1.1172 + test.Next(_L("Combined AddFirst and AddLast"));
1.1173 + que=new T();
1.1174 + que->AddFirst(link1);
1.1175 + que->AddLast(link2);
1.1176 + test(que->sHead->iNext==&link1);
1.1177 + test(que->sHead->iPrev==&link2);
1.1178 + test(link1.iNext==&link2);
1.1179 + test(link1.iPrev==que->sHead);
1.1180 + test(link2.iNext==que->sHead);
1.1181 + test(link2.iPrev==&link1);
1.1182 + que->AddFirst(link3);
1.1183 + test(que->sHead->iNext==&link3);
1.1184 + test(que->sHead->iPrev==&link2);
1.1185 + test(link1.iNext==&link2);
1.1186 + test(link1.iPrev==&link3);
1.1187 + test(link2.iNext==que->sHead);
1.1188 + test(link2.iPrev==&link1);
1.1189 + test(link3.iNext==&link1);
1.1190 + test(link3.iPrev==que->sHead);
1.1191 + que->AddLast(link4);
1.1192 + test(que->sHead->iNext==&link3);
1.1193 + test(que->sHead->iPrev==&link4);
1.1194 + test(link1.iNext==&link2);
1.1195 + test(link1.iPrev==&link3);
1.1196 + test(link2.iNext==&link4);
1.1197 + test(link2.iPrev==&link1);
1.1198 + test(link3.iNext==&link1);
1.1199 + test(link3.iPrev==que->sHead);
1.1200 + test(link4.iNext==que->sHead);
1.1201 + test(link4.iPrev==&link2);
1.1202 + link1.Deque();
1.1203 + link2.Deque();
1.1204 + link3.Deque();
1.1205 + link4.Deque();
1.1206 + delete que;
1.1207 + test.Next(_L("Finished"));
1.1208 + test.End();
1.1209 + }
1.1210 +
1.1211 +template<class T>
1.1212 +void TestTQue<T>::Test12()
1.1213 + {
1.1214 + T* que;
1.1215 + TDblQueLink link1,link2,link3,link4,*head;
1.1216 +
1.1217 + que=new T();
1.1218 + que->AddFirst(link1);
1.1219 + que->AddLast(link2);
1.1220 + que->AddLast(link3);
1.1221 + que->AddLast(link4);
1.1222 + head=que->sHead;
1.1223 + test.Start(_L("IsHead"));
1.1224 + test(que->IsHead(head)==TRUE);
1.1225 + test(que->IsHead(&link1)==FALSE);
1.1226 + test(que->IsHead(&link2)==FALSE);
1.1227 + test(que->IsHead(&link3)==FALSE);
1.1228 + test(que->IsHead(&link4)==FALSE);
1.1229 + test.Next(_L("IsFirst"));
1.1230 + test(que->IsFirst(head)==FALSE);
1.1231 + test(que->IsFirst(&link1)==TRUE);
1.1232 + test(que->IsFirst(&link2)==FALSE);
1.1233 + test(que->IsFirst(&link3)==FALSE);
1.1234 + test(que->IsFirst(&link4)==FALSE);
1.1235 + test.Next(_L("IsLast"));
1.1236 + test(que->IsLast(head)==FALSE);
1.1237 + test(que->IsLast(&link1)==FALSE);
1.1238 + test(que->IsLast(&link2)==FALSE);
1.1239 + test(que->IsLast(&link3)==FALSE);
1.1240 + test(que->IsLast(&link4)==TRUE);
1.1241 + delete que;
1.1242 + test.Next(_L("Finished"));
1.1243 + test.End();
1.1244 + }
1.1245 +
1.1246 +template<class T>
1.1247 +void TestTQue<T>::Test13()
1.1248 + {
1.1249 + T* que;
1.1250 + TDblQueLink link1,link2,link3,link4;
1.1251 +
1.1252 + test.Start(_L("First"));
1.1253 + que=new T();
1.1254 + que->AddFirst(link1);
1.1255 + test(que->First()==&link1);
1.1256 + que->AddFirst(link2);
1.1257 + test(que->First()==&link2);
1.1258 + que->AddFirst(link3);
1.1259 + test(que->First()==&link3);
1.1260 + que->AddFirst(link4);
1.1261 + test(que->First()==&link4);
1.1262 + link1.Deque();
1.1263 + link2.Deque();
1.1264 + link3.Deque();
1.1265 + link4.Deque();
1.1266 + delete que;
1.1267 + test.Next(_L("Last"));
1.1268 + que=new T();
1.1269 + que->AddLast(link1);
1.1270 + test(que->Last()==&link1);
1.1271 + que->AddLast(link2);
1.1272 + test(que->Last()==&link2);
1.1273 + que->AddLast(link3);
1.1274 + test(que->Last()==&link3);
1.1275 + que->AddLast(link4);
1.1276 + test(que->Last()==&link4);
1.1277 + link1.Deque();
1.1278 + link2.Deque();
1.1279 + link3.Deque();
1.1280 + link4.Deque();
1.1281 + delete que;
1.1282 + test.Next(_L("Finished"));
1.1283 + test.End();
1.1284 + }
1.1285 +
1.1286 +template<class T>
1.1287 +void TestTQue<T>::Test14()
1.1288 + {
1.1289 + T* que;
1.1290 + TPriQueLink link;
1.1291 + TInt offset=4;
1.1292 +
1.1293 + test.Start(_L("Constructors"));
1.1294 + que=new VPriQue<TPriQueLink>(offset);
1.1295 + delete que;
1.1296 + que=new VPriQue<TPriQueLink>;
1.1297 + test.Next(_L("Add"));
1.1298 + que->Add(link);
1.1299 + test.Next(_L("Finished"));
1.1300 + delete que;
1.1301 + test.End();
1.1302 + }
1.1303 +
1.1304 +template<class T>
1.1305 +void TestTQue<T>::Test15()
1.1306 + {
1.1307 + T* que;
1.1308 + TInt offset;
1.1309 +
1.1310 + test.Start(_L("Offset constructor"));
1.1311 + for (offset=0;offset<40;offset+=4)
1.1312 + {
1.1313 + que=new VPriQue<TPriQueLink>(offset);
1.1314 + test(*(que->sOffset)==offset);
1.1315 + delete que;
1.1316 + }
1.1317 + test.Next(_L("Finished"));
1.1318 + test.End();
1.1319 + }
1.1320 +
1.1321 +template<class T>
1.1322 +void TestTQue<T>::Test16()
1.1323 + {
1.1324 + T* que;
1.1325 + TPriQueLink link1,link2,link3,link4,link5,link6;
1.1326 +
1.1327 + que=new T();
1.1328 + link1.iPriority=4;
1.1329 + link2.iPriority=6;
1.1330 + link3.iPriority=2;
1.1331 + que->sDoAddPriority(&link1);
1.1332 + que->sDoAddPriority(&link2);
1.1333 + que->sDoAddPriority(&link3);
1.1334 + test(que->sHead->iNext==&link2);
1.1335 + test(que->sHead->iPrev==&link3);
1.1336 + test(link1.iNext==&link3);
1.1337 + test(link1.iPrev==&link2);
1.1338 + test(link2.iNext==&link1);
1.1339 + test(link2.iPrev==que->sHead);
1.1340 + test(link3.iNext==que->sHead);
1.1341 + test(link3.iPrev==&link1);
1.1342 + link4.iPriority=3;
1.1343 + que->sDoAddPriority(&link4);
1.1344 + test(que->sHead->iNext==&link2);
1.1345 + test(que->sHead->iPrev==&link3);
1.1346 + test(link1.iNext==&link4);
1.1347 + test(link1.iPrev==&link2);
1.1348 + test(link2.iNext==&link1);
1.1349 + test(link2.iPrev==que->sHead);
1.1350 + test(link3.iNext==que->sHead);
1.1351 + test(link3.iPrev==&link4);
1.1352 + test(link4.iNext==&link3);
1.1353 + test(link4.iPrev==&link1);
1.1354 + link5.iPriority=5;
1.1355 + que->sDoAddPriority(&link5);
1.1356 + test(que->sHead->iNext==&link2);
1.1357 + test(que->sHead->iPrev==&link3);
1.1358 + test(link1.iNext==&link4);
1.1359 + test(link1.iPrev==&link5);
1.1360 + test(link2.iNext==&link5);
1.1361 + test(link2.iPrev==que->sHead);
1.1362 + test(link3.iNext==que->sHead);
1.1363 + test(link3.iPrev==&link4);
1.1364 + test(link4.iNext==&link3);
1.1365 + test(link4.iPrev==&link1);
1.1366 + test(link5.iNext==&link1);
1.1367 + test(link5.iPrev==&link2);
1.1368 + link6.iPriority=1;
1.1369 + que->sDoAddPriority(&link6);
1.1370 + test(que->sHead->iNext==&link2);
1.1371 + test(que->sHead->iPrev==&link6);
1.1372 + test(link1.iNext==&link4);
1.1373 + test(link1.iPrev==&link5);
1.1374 + test(link2.iNext==&link5);
1.1375 + test(link2.iPrev==que->sHead);
1.1376 + test(link3.iNext==&link6);
1.1377 + test(link3.iPrev==&link4);
1.1378 + test(link4.iNext==&link3);
1.1379 + test(link4.iPrev==&link1);
1.1380 + test(link5.iNext==&link1);
1.1381 + test(link5.iPrev==&link2);
1.1382 + test(link6.iNext==que->sHead);
1.1383 + test(link6.iPrev==&link3);
1.1384 + delete que;
1.1385 + }
1.1386 +
1.1387 +template<class T>
1.1388 +void TestTQue<T>::Test17()
1.1389 + {
1.1390 + T* que;
1.1391 + TDeltaQueLink link1,link2;
1.1392 + TInt offset=4;
1.1393 +
1.1394 + test.Start(_L("Constructors"));
1.1395 + que=new VDeltaQue<TDeltaQueLink>(offset);
1.1396 + delete que;
1.1397 + que=new VDeltaQue<TDeltaQueLink>;
1.1398 + test.Next(_L("Add/Remove"));
1.1399 + que->Add(link1,0);
1.1400 + que->Add(link2,2);
1.1401 + que->Remove(link2);
1.1402 + que->RemoveFirst();
1.1403 + test.Next(_L("Finished"));
1.1404 + test.End();
1.1405 + }
1.1406 +
1.1407 +template<class T>
1.1408 +void TestTQue<T>::Test18()
1.1409 + {
1.1410 + T* que;
1.1411 + TInt offset;
1.1412 +
1.1413 + test.Start(_L("Offset constructor"));
1.1414 + for (offset=0;offset<40;offset+=4)
1.1415 + {
1.1416 + que=new VDeltaQue<TDeltaQueLink>(offset);
1.1417 + test(*(que->sOffset)==offset);
1.1418 + delete que;
1.1419 + }
1.1420 + test.Next(_L("Finished"));
1.1421 + test.End();
1.1422 + }
1.1423 +
1.1424 +template<class T>
1.1425 +void TestTQue<T>::Test19()
1.1426 + {
1.1427 + T* que;
1.1428 + TDeltaQueLink link1,link2,link3,link4,link5,link6;
1.1429 +
1.1430 + test.Start(_L("Add"));
1.1431 + que=new T();
1.1432 + que->Add(link2,3);
1.1433 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1434 + test(link2.iDelta==3);
1.1435 + que->Add(link5,15);
1.1436 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1437 + test(link2.iDelta==3);
1.1438 + test(link5.iDelta==12);
1.1439 + que->Add(link3,6);
1.1440 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1441 + test(link2.iDelta==3);
1.1442 + test(link3.iDelta==3);
1.1443 + test(link5.iDelta==9);
1.1444 + que->Add(link4,10);
1.1445 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1446 + test(link2.iDelta==3);
1.1447 + test(link3.iDelta==3);
1.1448 + test(link4.iDelta==4);
1.1449 + test(link5.iDelta==5);
1.1450 + que->Add(link1,1);
1.1451 + test(*(que->sFirstDelta)==&link1.iDelta);
1.1452 + test(link1.iDelta==1);
1.1453 + test(link2.iDelta==2);
1.1454 + test(link3.iDelta==3);
1.1455 + test(link4.iDelta==4);
1.1456 + test(link5.iDelta==5);
1.1457 + que->Add(link6,21);
1.1458 + test(*(que->sFirstDelta)==&link1.iDelta);
1.1459 + test(link1.iDelta==1);
1.1460 + test(link2.iDelta==2);
1.1461 + test(link3.iDelta==3);
1.1462 + test(link4.iDelta==4);
1.1463 + test(link5.iDelta==5);
1.1464 + test(link6.iDelta==6);
1.1465 + test.Next(_L("Remove"));
1.1466 + que->Remove(link6);
1.1467 + test(*(que->sFirstDelta)==&link1.iDelta);
1.1468 + test(link1.iDelta==1);
1.1469 + test(link2.iDelta==2);
1.1470 + test(link3.iDelta==3);
1.1471 + test(link4.iDelta==4);
1.1472 + test(link5.iDelta==5);
1.1473 + que->Remove(link1);
1.1474 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1475 + test(link2.iDelta==3);
1.1476 + test(link3.iDelta==3);
1.1477 + test(link4.iDelta==4);
1.1478 + test(link5.iDelta==5);
1.1479 + que->Remove(link4);
1.1480 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1481 + test(link2.iDelta==3);
1.1482 + test(link3.iDelta==3);
1.1483 + test(link5.iDelta==9);
1.1484 + que->Remove(link3);
1.1485 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1486 + test(link2.iDelta==3);
1.1487 + test(link5.iDelta==12);
1.1488 + que->Remove(link5);
1.1489 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1490 + test(link2.iDelta==3);
1.1491 + test.Next(_L("RemoveFirst"));
1.1492 + test(NULL==que->RemoveFirst());
1.1493 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1494 + test(link2.iDelta==3);
1.1495 + link2.iDelta=1;
1.1496 + test(NULL==que->RemoveFirst());
1.1497 + test(*(que->sFirstDelta)==&link2.iDelta);
1.1498 + test(link2.iDelta==1);
1.1499 + link2.iDelta=0;
1.1500 + test(&link2==que->RemoveFirst());
1.1501 + test.Next(_L("Finished"));
1.1502 + delete que;
1.1503 + test.End();
1.1504 + }
1.1505 +
1.1506 +class VDblQueIterBase : public TDblQueIterBase
1.1507 + {
1.1508 +public:
1.1509 + VDblQueIterBase(TDblQueBase& aQue);
1.1510 + inline TAny* sDoPostInc() {return DoPostInc();}
1.1511 + inline TAny* sDoPostDec() {return DoPostDec();}
1.1512 + inline TAny* sDoCurrent() {return DoCurrent();}
1.1513 + TInt* sOffset;
1.1514 + TDblQueLinkBase** sHead;
1.1515 + TDblQueLinkBase** sNext;
1.1516 +private:
1.1517 + void SetMember();
1.1518 + };
1.1519 +
1.1520 +template <class T>
1.1521 +class VDblQueIter : public TDblQueIter<T>
1.1522 + {
1.1523 +public:
1.1524 + VDblQueIter(TDblQueBase& aQue);
1.1525 + inline TAny* sDoPostInc() {return this->DoPostInc();}
1.1526 + inline TAny* sDoPostDec() {return this->DoPostDec();}
1.1527 + inline TAny* sDoCurrent() {return this->DoCurrent();}
1.1528 + TInt* sOffset;
1.1529 + TDblQueLinkBase** sHead;
1.1530 + TDblQueLinkBase** sNext;
1.1531 +private:
1.1532 + void SetMember();
1.1533 + };
1.1534 +
1.1535 +VDblQueIterBase::VDblQueIterBase(TDblQueBase& aQue)
1.1536 + :TDblQueIterBase(aQue)
1.1537 + {
1.1538 + SetMember();
1.1539 + }
1.1540 +
1.1541 +void VDblQueIterBase::SetMember()
1.1542 + {
1.1543 + sOffset=&iOffset;
1.1544 + sHead=&iHead;
1.1545 + sNext=&iNext;
1.1546 + }
1.1547 +
1.1548 +template <class T>
1.1549 +VDblQueIter<T>::VDblQueIter(TDblQueBase& aQue)
1.1550 + :TDblQueIter<T>(aQue)
1.1551 + {
1.1552 + SetMember();
1.1553 + }
1.1554 +
1.1555 +template <class T>
1.1556 +void VDblQueIter<T>::SetMember()
1.1557 + {
1.1558 + sOffset=&this->iOffset;
1.1559 + sHead=&this->iHead;
1.1560 + sNext=&this->iNext;
1.1561 + }
1.1562 +
1.1563 +template<class T>
1.1564 +class TestTQueIter
1.1565 + {
1.1566 +public:
1.1567 + void TestIterBase();
1.1568 + void TestQueIter();
1.1569 + void Test1(); //All functions //TDblQueIterBase
1.1570 + void Test2(); //Constructors
1.1571 + void Test3(); //Do's
1.1572 + void Test4(); //Set
1.1573 + void Test5(); //All functions //TDblQueIter
1.1574 + void Test1Item();
1.1575 + //void Test6(); //Constructors //Redundant
1.1576 + void Test7(); //Iterators
1.1577 +private:
1.1578 + void CallTest2_4();
1.1579 + };
1.1580 +
1.1581 +template<class T>
1.1582 +void TestTQueIter<T>::CallTest2_4()
1.1583 + {
1.1584 + test.Next(_L("Constructors"));
1.1585 + Test2();
1.1586 + test.Next(_L("Do's"));
1.1587 + Test3();
1.1588 + test.Next(_L("Sets"));
1.1589 + Test4();
1.1590 + }
1.1591 +
1.1592 +template<class T>
1.1593 +void TestTQueIter<T>::TestIterBase()
1.1594 + {
1.1595 + test.Start(_L("All Methods"));
1.1596 + Test1();
1.1597 + CallTest2_4();
1.1598 + test.Next(_L("Finished"));
1.1599 + test.End();
1.1600 + }
1.1601 +
1.1602 +template<class T>
1.1603 +void TestTQueIter<T>::TestQueIter()
1.1604 + {
1.1605 + test.Start(_L("All Methods"));
1.1606 + Test5();
1.1607 + CallTest2_4();
1.1608 + test.Next(_L("One item in queue"));
1.1609 + Test1Item();
1.1610 + test.Next(_L("Iterators"));
1.1611 + Test7();
1.1612 + test.Next(_L("Finished"));
1.1613 + test.End();
1.1614 + }
1.1615 +
1.1616 +template<class T>
1.1617 +void TestTQueIter<T>::Test1()
1.1618 + {
1.1619 + Item item1,item2;
1.1620 + TDblQue<Item> que;
1.1621 + T* iter;
1.1622 +
1.1623 + que.AddFirst(item2);
1.1624 + que.AddFirst(item1);
1.1625 + test.Start(_L("Constructor"));
1.1626 + iter=new VDblQueIterBase(que);
1.1627 + test.Next(_L("Do's"));
1.1628 + iter->sDoCurrent();
1.1629 + iter->sDoPostInc();
1.1630 + iter->sDoPostDec();
1.1631 + test.Next(_L("Sets"));
1.1632 + iter->SetToFirst();
1.1633 + iter->SetToLast();
1.1634 + delete iter;
1.1635 + test.Next(_L("Finished"));
1.1636 + test.End();
1.1637 + }
1.1638 +
1.1639 +template<class T>
1.1640 +void TestTQueIter<T>::Test2()
1.1641 + {
1.1642 + Item item;
1.1643 + TDblQue<Item>* que;
1.1644 + TInt offset;
1.1645 + T* iter;
1.1646 +
1.1647 + for(offset=0;offset<40;offset+=4)
1.1648 + {
1.1649 + que=new TDblQue<Item>(offset);
1.1650 + new(PtrAdd(&item.iLink,offset)) TDblQueLink(); // create the link at this offset
1.1651 + iter=new T(*que);
1.1652 + test(que->IsHead((Item*) PtrSub(*(iter->sHead),offset))); //Need to pass a pointer to a item
1.1653 + test(que->IsHead((Item*) PtrSub(*(iter->sNext),offset)));
1.1654 + test(*(iter->sOffset)==offset);
1.1655 + delete iter;
1.1656 + delete que;
1.1657 + que=new TDblQue<Item>(offset);
1.1658 + new(PtrAdd(&item.iLink,offset)) TDblQueLink(); // create the link at this offset
1.1659 + que->AddFirst(item);
1.1660 + iter=new T(*que);
1.1661 + test(que->IsHead((Item*) PtrSub(*(iter->sHead),offset)));
1.1662 + test(*(iter->sNext)==PtrAdd(&item.iLink,offset)); //Need a pointer to a link
1.1663 + test(*(iter->sOffset)==offset);
1.1664 + PtrAdd(&item.iLink,offset)->Deque();
1.1665 + delete iter;
1.1666 + delete que;
1.1667 + }
1.1668 + }
1.1669 +
1.1670 +template<class T>
1.1671 +void TestTQueIter<T>::Test3()
1.1672 + {
1.1673 + Item item1,item2,item3,item4;
1.1674 + TDblQue<Item> que;
1.1675 + T* iter;
1.1676 +
1.1677 + que.AddFirst(item4);
1.1678 + que.AddFirst(item3);
1.1679 + que.AddFirst(item2);
1.1680 + que.AddFirst(item1);
1.1681 + test.Start(_L("DoPostInc"));
1.1682 + iter=new T(que);
1.1683 + test(&item1==iter->sDoPostInc());
1.1684 + test(&item2.iLink==*(iter->sNext));
1.1685 + test(&item2==iter->sDoPostInc());
1.1686 + test(&item3.iLink==*(iter->sNext));
1.1687 + test(&item3==iter->sDoPostInc());
1.1688 + test(&item4.iLink==*(iter->sNext));
1.1689 + test(&item4==iter->sDoPostInc());
1.1690 + test(que.IsHead((Item*) *(iter->sNext)));
1.1691 + test(iter->sDoPostInc()==NULL);
1.1692 + delete iter;
1.1693 + test.Next(_L("DoPostDec"));
1.1694 + iter=new T(que);
1.1695 + iter->sDoPostInc();
1.1696 + iter->sDoPostInc();
1.1697 + iter->sDoPostInc();
1.1698 + test(&item4.iLink==*(iter->sNext));
1.1699 + test(&item4==iter->sDoPostDec());
1.1700 + test(&item3.iLink==*(iter->sNext));
1.1701 + test(&item3==iter->sDoPostDec());
1.1702 + test(&item2.iLink==*(iter->sNext));
1.1703 + test(&item2==iter->sDoPostDec());
1.1704 + test(&item1.iLink==*(iter->sNext));
1.1705 + test(&item1==iter->sDoPostDec());
1.1706 + test(que.IsHead((Item*) *(iter->sNext)));
1.1707 + test(iter->sDoPostDec()==NULL);
1.1708 + delete iter;
1.1709 + test.Next(_L("DoCurrent"));
1.1710 + iter=new T(que);
1.1711 + test(&item1==iter->sDoCurrent());
1.1712 + iter->sDoPostInc();
1.1713 + test(&item2==iter->sDoCurrent());
1.1714 + iter->sDoPostInc();
1.1715 + test(&item3==iter->sDoCurrent());
1.1716 + iter->sDoPostInc();
1.1717 + test(&item4==iter->sDoCurrent());
1.1718 + iter->sDoPostInc();
1.1719 + test(iter->sDoCurrent()==NULL);
1.1720 + delete iter;
1.1721 + test.Next(_L("Finished"));
1.1722 + test.End();
1.1723 + }
1.1724 +
1.1725 +template<class T>
1.1726 +void TestTQueIter<T>::Test4()
1.1727 + {
1.1728 + Item item1,item2,item3,item4;
1.1729 + TDblQue<Item> que;
1.1730 + T* iter;
1.1731 + TInt i,j;
1.1732 +
1.1733 + que.AddFirst(item4);
1.1734 + que.AddFirst(item3);
1.1735 + que.AddFirst(item2);
1.1736 + que.AddFirst(item1);
1.1737 + test.Start(_L("SetToFirst"));
1.1738 + iter=new T(que);
1.1739 + for(i=0;i<5;i++)
1.1740 + {
1.1741 + for(j=0;j<i;j++)
1.1742 + iter->sDoPostInc();
1.1743 + iter->SetToFirst();
1.1744 + test(*(iter->sNext)==&item1.iLink);
1.1745 + }
1.1746 + delete iter;
1.1747 + test.Next(_L("SetToLast"));
1.1748 + iter=new T(que);
1.1749 + for(i=0;i<5;i++)
1.1750 + {
1.1751 + iter->SetToFirst();
1.1752 + for(j=0;j<i;j++)
1.1753 + iter->sDoPostInc();
1.1754 + iter->SetToLast();
1.1755 + test(*(iter->sNext)==&item4.iLink);
1.1756 + }
1.1757 + delete iter;
1.1758 + test.Next(_L("Finished"));
1.1759 + test.End();
1.1760 + }
1.1761 +
1.1762 +template<class T>
1.1763 +void TestTQueIter<T>::Test5()
1.1764 + {
1.1765 + Item item1,item2;
1.1766 + TDblQue<Item> que;
1.1767 + T* iter;
1.1768 + Item* a;
1.1769 +
1.1770 + que.AddFirst(item2);
1.1771 + que.AddFirst(item1);
1.1772 + test.Start(_L("Constructor"));
1.1773 + iter=new T(que);
1.1774 + test.Next(_L("Iterators"));
1.1775 + a=*iter;
1.1776 + test(((*iter)++)==&item1);
1.1777 + test(((*iter)--)==&item2);
1.1778 + test(((*iter)++)==&item1);
1.1779 + test(((*iter)++)==&item2);
1.1780 + test(((*iter)++)==NULL);
1.1781 + test(((*iter)++)==NULL);
1.1782 + test(((*iter)--)==NULL);
1.1783 + test(((*iter)--)==NULL);
1.1784 + iter->Set(item2);
1.1785 + test(((*iter)--)==&item2);
1.1786 + test(((*iter)++)==&item1);
1.1787 + test(((*iter)--)==&item2);
1.1788 + test(((*iter)--)==&item1);
1.1789 + test(((*iter)++)==NULL);
1.1790 + test(((*iter)++)==NULL);
1.1791 + test(((*iter)--)==NULL);
1.1792 + test(((*iter)--)==NULL);
1.1793 + delete iter;
1.1794 + test.Next(_L("Finished"));
1.1795 + test.End();
1.1796 + }
1.1797 +
1.1798 +template<class T>
1.1799 +void TestTQueIter<T>::Test1Item()
1.1800 + {
1.1801 + Item item;
1.1802 + TDblQue<Item> que;
1.1803 + T* iter;
1.1804 +
1.1805 + test.Start(_L("Constructor"));
1.1806 + iter=new T(que);
1.1807 + que.AddFirst(item);
1.1808 + iter->Set(item);
1.1809 + test.Next(_L("Iterators"));
1.1810 + test(((*iter)++)==&item);
1.1811 + test(((*iter)++)==NULL);
1.1812 + test(((*iter)++)==NULL);
1.1813 + test(((*iter)++)==NULL);
1.1814 + test(((*iter)--)==NULL);
1.1815 + test(((*iter)--)==NULL);
1.1816 + iter->Set(item);
1.1817 + test(((*iter)--)==&item);
1.1818 + test(((*iter)++)==NULL);
1.1819 + test(((*iter)--)==NULL);
1.1820 + test(((*iter)--)==NULL);
1.1821 + test(((*iter)--)==NULL);
1.1822 + test(((*iter)++)==NULL);
1.1823 + test(((*iter)++)==NULL);
1.1824 + delete iter;
1.1825 + test.Next(_L("Finished"));
1.1826 + test.End();
1.1827 + }
1.1828 +
1.1829 +/*template<class T> //Redundant
1.1830 +void TestTQueIter<T>::Test6()
1.1831 + {
1.1832 + Item item;
1.1833 + TDblQue<Item>* que;
1.1834 + TInt offset;
1.1835 + T* iter;
1.1836 +
1.1837 + for(offset=0;offset<40;offset+=4)
1.1838 + {
1.1839 + que=new TDblQue<Item>(offset);
1.1840 + iter=new T(*que);
1.1841 + test(que->IsHead((Item*) *(iter->sHead)));
1.1842 + test(que->IsHead((Item*) *(iter->sNext)));
1.1843 + test(*(iter->sOffset)==offset);
1.1844 + delete iter;
1.1845 + delete que;
1.1846 + que=new TDblQue<Item>(offset);
1.1847 + que->AddFirst(item);
1.1848 + iter=new T(*que);
1.1849 + test(que->IsHead((Item*) *(iter->sHead)));
1.1850 + test(*(iter->sNext)==&item.iLink);
1.1851 + test(*(iter->sOffset)==offset);
1.1852 + delete iter;
1.1853 + delete que;
1.1854 + }
1.1855 + }*/
1.1856 +
1.1857 +template<class T>
1.1858 +void TestTQueIter<T>::Test7()
1.1859 + {
1.1860 + Item item1,item2,item3,item4;
1.1861 + TDblQue<Item> que;
1.1862 + T* iter;
1.1863 +
1.1864 + que.AddFirst(item4);
1.1865 + que.AddFirst(item3);
1.1866 + que.AddFirst(item2);
1.1867 + que.AddFirst(item1);
1.1868 + test.Start(_L("PostFix ++"));
1.1869 + iter=new T(que);
1.1870 + test(&item1==(*iter)++);
1.1871 + test(&item2.iLink==*(iter->sNext));
1.1872 + test(&item2==(*iter)++);
1.1873 + test(&item3.iLink==*(iter->sNext));
1.1874 + test(&item3==(*iter)++);
1.1875 + test(&item4.iLink==*(iter->sNext));
1.1876 + test(&item4==(*iter)++);
1.1877 + test(que.IsHead((Item*) *(iter->sNext)));
1.1878 + test((*iter)++==NULL);
1.1879 + delete iter;
1.1880 + test.Next(_L("PostFix --"));
1.1881 + iter=new T(que);
1.1882 + iter->SetToLast();
1.1883 + test(&item4.iLink==*(iter->sNext));
1.1884 + test(&item4==(*iter)--);
1.1885 + test(&item3.iLink==*(iter->sNext));
1.1886 + test(&item3==(*iter)--);
1.1887 + test(&item2.iLink==*(iter->sNext));
1.1888 + test(&item2==(*iter)--);
1.1889 + test(&item1.iLink==*(iter->sNext));
1.1890 + test(&item1==(*iter)--);
1.1891 + test(que.IsHead((Item*) *(iter->sNext)));
1.1892 + test((*iter)--==NULL);
1.1893 + delete iter;
1.1894 + test.Next(_L("Conversion Operator"));
1.1895 + iter=new T(que);
1.1896 + test(&item1==*iter);
1.1897 + (*iter)++;
1.1898 + test(&item2==*iter);
1.1899 + (*iter)++;
1.1900 + test(&item3==*iter);
1.1901 + (*iter)++;
1.1902 + test(&item4==*iter);
1.1903 + (*iter)++;
1.1904 + test(*iter==NULL);
1.1905 + delete iter;
1.1906 + test.Next(_L("Finished"));
1.1907 + test.End();
1.1908 + }
1.1909 +
1.1910 +GLDEF_C TInt E32Main()
1.1911 + {
1.1912 +
1.1913 + TestTQueLink<TDblQueLinkBase>* testDblQueLinkBase;
1.1914 + TestTQueLink<TDeltaQueLink>* testDeltaQueLink;
1.1915 + TestTQueLink<TDblQueLink>* testDblQueLink;
1.1916 + TestTQueLink<TPriQueLink>* testPriQueLink;
1.1917 + TestTQue<VDblQueBase>* testDblQueBase;
1.1918 + TestTQue<VDeltaQueBase>* testDeltaQueBase;
1.1919 + TestTQue<VDblQue<TDblQueLink> >* testDblQue;
1.1920 + TestTQue<VPriQue<TPriQueLink> >* testPriQue;
1.1921 + TestTQue<VDeltaQue<TDeltaQueLink> >* testDeltaQue;
1.1922 + TestTQueIter<VDblQueIterBase>* testDblQueIterBase;
1.1923 + TestTQueIter<VDblQueIter<Item> >* testDblQueIter;
1.1924 +
1.1925 +// Test the queue classes.
1.1926 + test.Title();
1.1927 + test.Start(_L("class TDblQueLinkBase"));
1.1928 + testDblQueLinkBase=new TestTQueLink<TDblQueLinkBase>;
1.1929 + testDblQueLinkBase->TestQueLinkBase();
1.1930 + delete testDblQueLinkBase;
1.1931 +
1.1932 + test.Next(_L("class TDeltaQueLink"));
1.1933 + testDeltaQueLink=new TestTQueLink<TDeltaQueLink>;
1.1934 + testDeltaQueLink->TestQueLinkBase();
1.1935 + delete testDeltaQueLink;
1.1936 +
1.1937 + test.Next(_L("class TDblQueLink"));
1.1938 + testDblQueLink=new TestTQueLink<TDblQueLink>;
1.1939 + testDblQueLink->TestQueLink();
1.1940 + delete testDblQueLink;
1.1941 +
1.1942 + test.Next(_L("class TPriQueLink"));
1.1943 + testPriQueLink=new TestTQueLink<TPriQueLink>;
1.1944 + testPriQueLink->TestQueLink();
1.1945 + delete testPriQueLink;
1.1946 +
1.1947 + test.Next(_L("class TDblQueBase"));
1.1948 + testDblQueBase=new TestTQue<VDblQueBase>;
1.1949 + testDblQueBase->TestQueBase();
1.1950 + delete testDblQueBase;
1.1951 +
1.1952 + test.Next(_L("class TDeltaQueBase"));
1.1953 + testDeltaQueBase=new TestTQue<VDeltaQueBase>;
1.1954 + testDeltaQueBase->TestDeltaBase();
1.1955 + delete testDeltaQueBase;
1.1956 +
1.1957 + test.Next(_L("class TDlbQue"));
1.1958 + testDblQue=new TestTQue<VDblQue<TDblQueLink> >;
1.1959 + testDblQue->TestDblQue();
1.1960 + delete testDblQue;
1.1961 +
1.1962 + test.Next(_L("class TPriQue"));
1.1963 + testPriQue=new TestTQue<VPriQue<TPriQueLink> >;
1.1964 + testPriQue->TestPriQue();
1.1965 + delete testPriQue;
1.1966 +
1.1967 + test.Next(_L("class TDeltaQue"));
1.1968 + testDeltaQue=new TestTQue<VDeltaQue<TDeltaQueLink> >;
1.1969 + testDeltaQue->TestDeltaQue();
1.1970 + delete testDeltaQue;
1.1971 +
1.1972 + test.Next(_L("class TDblQueIterBase"));
1.1973 + testDblQueIterBase=new TestTQueIter<VDblQueIterBase>;
1.1974 + testDblQueIterBase->TestIterBase();
1.1975 + delete testDblQueIterBase;
1.1976 +
1.1977 + test.Next(_L("class TDblQueIter"));
1.1978 + testDblQueIter=new TestTQueIter<VDblQueIter<Item> >;
1.1979 + testDblQueIter->TestQueIter();
1.1980 + delete testDblQueIter;
1.1981 +
1.1982 + test.Next(_L("Finished"));
1.1983 + test.End();
1.1984 + return(0);
1.1985 + }
1.1986 +
1.1987 +#pragma warning(default : 4710) //fuction not expanded
1.1988 +