0024971: Incomplete interface of NCollection classes
[occt.git] / src / QANCollection / QANCollection_Test.cxx
CommitLineData
3a01a933 1// Created on: 2004-03-05
2// Created by: Mikhail KUZMITCHEV
3// Copyright (c) 2004-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <QANCollection.hxx>
17#include <QANCollection_Common.hxx>
18
19#include <Draw.hxx>
20#include <Draw_Interpretor.hxx>
21
22#include <gp_Pnt.hxx>
23
e3a6386d 24#include <NCollection_Vector.hxx>
25
3a01a933 26#define ItemType gp_Pnt
27#define Key1Type Standard_Real
28#define Key2Type Standard_Integer
29
30#include <NCollection_DefineArray1.hxx>
31#include <NCollection_DefineHArray1.hxx>
32////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType)
33////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1)
34DEFINE_ARRAY1(QANCollection_Array1Func,QANCollection_BaseColFunc,ItemType)
35DEFINE_HARRAY1(QANCollection_HArray1Func,QANCollection_Array1Func)
36IMPLEMENT_HARRAY1(QANCollection_HArray1Func)
37
38#include <NCollection_DefineArray2.hxx>
39#include <NCollection_DefineHArray2.hxx>
40////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType)
41////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2)
42DEFINE_ARRAY2(QANCollection_Array2Func,QANCollection_BaseColFunc,ItemType)
43DEFINE_HARRAY2(QANCollection_HArray2Func,QANCollection_Array2Func)
44IMPLEMENT_HARRAY2(QANCollection_HArray2Func)
45
46#include <NCollection_DefineMap.hxx>
47#include <NCollection_DefineDataMap.hxx>
48#include <NCollection_DefineDoubleMap.hxx>
49#include <NCollection_DefineIndexedMap.hxx>
50#include <NCollection_DefineIndexedDataMap.hxx>
51////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type)
52////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType)
53////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type)
54////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type)
55////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType)
56DEFINE_MAP(QANCollection_MapFunc,QANCollection_Key1BaseColFunc,Key1Type)
57DEFINE_DATAMAP(QANCollection_DataMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType)
58DEFINE_DOUBLEMAP(QANCollection_DoubleMapFunc,QANCollection_Key2BaseColFunc,Key1Type,Key2Type)
59DEFINE_INDEXEDMAP(QANCollection_IndexedMapFunc,QANCollection_Key1BaseColFunc,Key1Type)
60DEFINE_INDEXEDDATAMAP(QANCollection_IDMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType)
61
62#include <NCollection_DefineList.hxx>
63////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
64DEFINE_LIST(QANCollection_ListFunc,QANCollection_BaseColFunc,ItemType)
65
66#include <NCollection_DefineSequence.hxx>
67#include <NCollection_DefineHSequence.hxx>
68////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType)
69////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence)
70DEFINE_SEQUENCE(QANCollection_SequenceFunc,QANCollection_BaseColFunc,ItemType)
71DEFINE_HSEQUENCE(QANCollection_HSequenceFunc,QANCollection_SequenceFunc)
72IMPLEMENT_HSEQUENCE(QANCollection_HSequenceFunc)
73
74// HashCode and IsEquel must be defined for key types of maps
75Standard_Integer HashCode(const gp_Pnt thePnt, int theUpper)
76{
77 return HashCode(thePnt.X(),theUpper);
78}
79
80Standard_Boolean IsEqual(const gp_Pnt& theP1, const gp_Pnt& theP2)
81{
82 return theP1.IsEqual(theP2,gp::Resolution());
83}
84
85////////////////////////////////void printCollection (QANCollection_Key1BaseCol& aColl,
86template <class Coll>
87void printCollection (Coll& aColl, const char * str)
88{
89 printf ("%s:\n",str);
90 Standard_Integer iSize = aColl.Size();
91 ////////////////////////////////QANCollection_Key1BaseCol::Iterator& anIter = aColl.CreateIterator();
92 typename Coll::Iterator anIter (aColl);
93 if (!anIter.More())
94 {
95 if (iSize==0)
96 printf (" <Empty collection>\n");
97 else
98 printf ("Error : empty collection has size==%d",iSize);
99 }
100 else
101 {
102 printf (" Size==%d\n",iSize);
103 for (; anIter.More(); anIter.Next())
104 PrintItem(anIter.Value());
105 }
106}
107
108////////////////////////////////void AssignCollection (QANCollection_BaseCol& aCollSrc,
109//////////////////////////////// QANCollection_BaseCol& aCollDst)
110template <class Coll>
111void AssignCollection (Coll& aCollSrc, Coll& aCollDst)
112{
113 printCollection (aCollSrc,"Source collection");
114 aCollDst.Assign(aCollSrc);
115 printCollection (aCollDst,"Target collection");
116}
117
118// ===================== Test methods of Array1 type ==========================
119////////////////////////////////void TestArray1 (QANCollection_Array1& theA1)
120static void TestArray1 (QANCollection_Array1Func& theA1)
121{
122 // Bounds
123 Standard_Integer iLow=theA1.Lower();
124 Standard_Integer iUpp=theA1.Upper();
125 Standard_Integer i;
126
127 printf ("Info: testing Array1(%d,%d), %s\n",
128 iLow, iUpp, (theA1.IsDeletable()?"deletable":"frozen"));
129 // C-array constructor, Length, Init
130 ItemType anItem;
131 Random(anItem);
132 theA1.Init (anItem);
133 ItemType * rBlock = new ItemType[theA1.Length()];
134 ////////////////////////////////QANCollection_Array1 aCArr(*rBlock, iLow-100, iUpp-100);
135 QANCollection_Array1Func aCArr(*rBlock, iLow-100, iUpp-100);
136 printf (" created the same sized preallocated array (%d,%d), %s\n",
137 aCArr.Lower(),aCArr.Upper(),(aCArr.IsDeletable()?"deletable":"frozen"));
138 // *Value, operator()
139 for (i=iLow+1; i<iUpp; i++)
140 {
141 Random (aCArr.ChangeValue (i-101));
142 aCArr.SetValue (i-100, ItemType(aCArr.Value(i-101)));
143 aCArr(i-99) = aCArr(i-100) = aCArr(i-101);
144 }
145 // Handle, copy constructor (including operator=)
146 ////////////////////////////////Handle(QANCollection_HArray1) aHa = new QANCollection_HArray1(aCArr);
147 Handle(QANCollection_HArray1Func) aHa = new QANCollection_HArray1Func(aCArr);
148 // Assign
149 AssignCollection (aHa->ChangeArray1(), theA1);
150}
151
152// ===================== Test methods of Array2 type ==========================
153////////////////////////////////void TestArray2 (QANCollection_Array2& theA2)
154static void TestArray2 (QANCollection_Array2Func& theA2)
155{
156 // Bounds
157 Standard_Integer iLR=theA2.LowerRow(), iLC=theA2.LowerCol();
158 Standard_Integer iUR=theA2.UpperRow(), iUC=theA2.UpperCol();
159 Standard_Integer i,j;
160
161 printf ("Info: testing Array2 (%d,%d)(%d,%d), %s\n",
162 iLR, iUR, iLC, iUC, (theA2.IsDeletable()?"deletable":"frozen"));
163 // C-array constructor, Length, Init, RowLength, ColLength
164 ItemType anItem;
165 Random(anItem);
166 theA2.Init (anItem);
167 ItemType * rBlock = new ItemType[theA2.Length()];
168 ////////////////////////////////QANCollection_Array2 aCArr(*rBlock, iLR-100, iUR-100, iLC, iUC);
169 QANCollection_Array2Func aCArr(*rBlock, iLR-100, iUR-100, iLC, iUC);
170 printf (" created the same sized preallocated array (%d*%d), %s\n",
171 aCArr.RowLength(), aCArr.ColLength(),
172 (aCArr.IsDeletable()?"deletable":"frozen"));
173 // *Value, operator()
174 for (i=iLR+1; i<iUR; i++)
175 {
176 for (j=iLC; j<=iUC; j++)
177 {
178 Random (aCArr.ChangeValue (i-101, j));
179 aCArr.SetValue (i-100, j,
180 ItemType(aCArr.Value(i-101,j)));
181 aCArr(i-99,j) = aCArr(i-100,j) = aCArr(i-101,j);
182 }
183 }
184 // Handle, copy constructor (including operator=)
185 ////////////////////////////////Handle(QANCollection_HArray2) aHa = new QANCollection_HArray2(aCArr);
186 Handle(QANCollection_HArray2Func) aHa = new QANCollection_HArray2Func(aCArr);
187 // Assign
188 AssignCollection (aHa->ChangeArray2(), theA2);
189}
190
191// ===================== Test methods of List type ==========================
192////////////////////////////////void TestList (QANCollection_List& theL)
193static void TestList (QANCollection_ListFunc& theL)
194{
195 // Extent
196 Standard_Integer iExt=theL.Extent();
197 Standard_Integer i;
198
199 printf ("Info: testing List(%d)\n", iExt);
200 // Append(2), Prepend(2), InsertBefore(2), InsertAfter(2),
201 // Remove, RemoveFirst, First, Last
202 ItemType anItem;
203 ////////////////////////////////QANCollection_List aL, aL1;
204 QANCollection_ListFunc aL, aL1;
205 for (i=0; i<4; i++)
206 {
207 Random (anItem);
208 aL.Append (anItem); // #1
209 aL.Append (aL1); // #2
210 Random (anItem);
211 aL1.Prepend (anItem); // #3
212 aL1.Prepend (aL); // #4
213 ////////////////////////////////QANCollection_List::Iterator anI(theL);
214 QANCollection_ListFunc::Iterator anI(theL);
215 if (anI.More())
216 {
217 Random (anItem);
218 theL.InsertBefore (anItem, anI); // #5
219 theL.InsertBefore (aL1, anI); // #6
220 Random (anItem);
221 theL.InsertAfter (anItem, anI); // #7
222 theL.InsertAfter (aL, anI); // #8
223 theL.Remove (anI); // #9
224 if (theL.Extent() > 0)
225 theL.RemoveFirst(); // #10
226 }
227 else
228 {
229 theL.Prepend (anItem);
230 PrintItem(theL.First());
231 PrintItem(theL.Last());
232 }
233 }
234 // Copy constructor + operator=
235 ////////////////////////////////aL = QANCollection_List(theL);
236 aL = QANCollection_ListFunc(theL);
237
238 // Assign
239 AssignCollection (theL, aL);
240
241 // Clear
242 aL.Clear();
243}
244
245// ===================== Test methods of Sequence type ========================
246////////////////////////////////void TestSequence (QANCollection_Sequence& theS)
247static void TestSequence (QANCollection_SequenceFunc& theS)
248{
249 Standard_Integer i;
250
251 printf ("Info: testing Sequence\n");
252 // Append(2)
253 ItemType anItem;
254 ////////////////////////////////QANCollection_Sequence aS, aS1;
255 QANCollection_SequenceFunc aS, aS1;
256 // Append(2), Prepend(2), InsertBefore(2), InsertAfter(2),
257 // Remove, RemoveFirst, First, Last
258 for (i=0; i<4; i++)
259 {
260 Random (anItem);
261 aS.Append (anItem); // #1
262 aS.Append (aS1); // #2
263 Random (anItem);
264 aS1.Prepend (anItem); // #3
265 aS1.Prepend (aS); // #4
266 if (theS.Length() > 0)
267 {
268 Random (anItem);
269 theS.InsertBefore (1, anItem); // #5
270 theS.InsertBefore (2, aS1); // #6
271 Random (anItem);
272 theS.InsertAfter (1, anItem); // #7
273 theS.InsertAfter (2, aS); // #8
274 theS.Remove (1); // #9
275 if (theS.Length() > 0)
276 theS.Remove(1); // #10
277 }
278 else
279 {
280 theS.Prepend (anItem);
281 PrintItem(theS.First());
282 PrintItem(theS.Last());
283 }
284 }
285
286 // ()
287 PrintItem(theS(1));
288
289 // Handle, Split
290 ////////////////////////////////Handle(QANCollection_HSequence) aHS = new QANCollection_HSequence(aS1);
291 Handle(QANCollection_HSequenceFunc) aHS = new QANCollection_HSequenceFunc(aS1);
292 theS.Split (3, aHS->ChangeSequence());
293
294 // Assign
295 AssignCollection (theS, aS);
296
297 // Clear
298 aS.Clear();
299}
300
301// ===================== Test methods of Map type =============================
302////////////////////////////////void TestMap (QANCollection_Map& theM)
303static void TestMap (QANCollection_MapFunc& theM)
304{
305 // Extent
306 Standard_Integer iExt=theM.Extent();
307 Standard_Integer i;
308
309 printf ("Info: testing Map(l=%d)\n", iExt);
310 theM.Statistics(cout);
311 // Resize
312 theM.ReSize(8);
313 theM.Statistics(cout);
314 cout.flush();
315 // Constructor
316 ////////////////////////////////QANCollection_Map aM;
317 QANCollection_MapFunc aM;
318 // Add
319 Key1Type aKey;
320 for (i=0; i<8; i++)
321 {
322 Random (aKey);
323 aM.Add (aKey);
324 }
325 // Contains, Remove
326 if (!aM.Contains(aKey))
327 {
328 printf("Error : map says that it does not contain its key ");
329 PrintItem(aKey);
330 }
331 else
332 {
333 aM.Remove(aKey);
334 printf(" successfully removed item, l=%d\n", aM.Size());
335 }
336 // Copy constructor (including operator=)
337 ////////////////////////////////QANCollection_Map aM2 = QANCollection_Map(aM);
338 QANCollection_MapFunc aM2 = QANCollection_MapFunc(aM);
339 // Assign
340 AssignCollection (aM2,theM);
341
342 // Clear
343 aM.Clear();
344}
345
346// ===================== Test methods of DataMap type =========================
347////////////////////////////////void TestDataMap (QANCollection_DataMap& theM)
348static void TestDataMap (QANCollection_DataMapFunc& theM)
349{
350 // Extent
351 Standard_Integer iExt=theM.Extent();
352 Standard_Integer i;
353
354 printf ("Info: testing DataMap(l=%d)\n", iExt);
355 theM.Statistics(cout);
356 // Resize
357 theM.ReSize(8);
358 theM.Statistics(cout);
359 cout.flush();
360 // Constructor
361 ////////////////////////////////QANCollection_DataMap aM;
362 QANCollection_DataMapFunc aM;
363 // Bind, Find, ChangeFind, ()
364 Key1Type aKey;
365 ItemType anItem;
366 for (i=0; i<8; i++)
367 {
368 Random (aKey);
369 Random (anItem);
370 aM.Bind (aKey, anItem);
371 PrintItem(aM.Find(aKey));
372 Random(aM(aKey));
373 }
374 // IsBound, UnBind
375 if (!aM.IsBound(aKey))
376 {
377 printf("Error : map says that it does not contain its key ");
378 PrintItem(aKey);
379 }
380 else
381 {
382 aM.UnBind(aKey);
383 printf(" successfully unbound the key, l=%d\n", aM.Size());
384 }
385 // Copy constructor (including operator=)
386 ////////////////////////////////theM = QANCollection_DataMap(aM);
387 theM = QANCollection_DataMapFunc(aM);
388 // Assign - prohibited
389 // AssignCollection (aM2,theM);
390 printCollection (theM, "DataMap:");
391
392 // Clear
393 aM.Clear();
394}
395
396
397// ===================== Test methods of DoubleMap type =======================
398////////////////////////////////void TestDoubleMap (QANCollection_DoubleMap& theM)
399static void TestDoubleMap (QANCollection_DoubleMapFunc& theM)
400{
401 // Extent
402 Standard_Integer iExt=theM.Extent();
403 Standard_Integer i;
404
405 printf ("Info: testing DoubleMap(l=%d)\n", iExt);
406 theM.Statistics(cout);
407 // Resize
408 theM.ReSize(8);
409 theM.Statistics(cout);
410 cout.flush();
411 // Constructor
412 ////////////////////////////////QANCollection_DoubleMap aM;
413 QANCollection_DoubleMapFunc aM;
414 // Bind, Find?,
415 Key1Type aKey1;
416 Key2Type aKey2;
417 for (i=0; i<8; i++)
418 {
419 Random (aKey1);
420 Random (aKey2);
421 aM.Bind (aKey1, aKey2);
422 PrintItem(aM.Find1(aKey1));
423 if (!aM.IsBound1(aKey1))
424 {
425 printf("Error : map says that it does not contain its key ");
426 PrintItem(aKey1);
427 }
428 PrintItem(aM.Find2(aKey2));
429 if (!aM.IsBound2(aKey2))
430 {
431 printf("Error : map says that it does not contain its key ");
432 PrintItem(aKey2);
433 }
434 }
435 // AreBound, UnBind
436 if (!aM.AreBound(aKey1,aKey2))
437 {
438 printf("Error : map says that it does not contain its keys ");
439 PrintItem(aKey1);
440 PrintItem(aKey2);
441 }
442 else
443 {
444 if (aM.UnBind2(aKey2))
445 printf(" successfully unbound the key, l=%d\n", aM.Size());
446 if (aM.UnBind1(aKey1))
447 printf("Error : unbound both keys?!\n");
448 }
449 // Copy constructor (including operator=)
450 ////////////////////////////////theM = QANCollection_DoubleMap(aM);
451 theM = QANCollection_DoubleMapFunc(aM);
452 // Assign - prohibited
453 // AssignCollection (aM2,theM);
454 printCollection (theM, "DoubleMap:");
455
456 // Clear
457 aM.Clear();
458}
459
460// ===================== Test methods of IndexedMap type ======================
461////////////////////////////////void TestIndexedMap (QANCollection_IndexedMap& theM)
462static void TestIndexedMap (QANCollection_IndexedMapFunc& theM)
463{
464 // Extent
465 Standard_Integer iExt=theM.Extent();
466 Standard_Integer i;
467
468 printf ("Info: testing IndexedMap(l=%d)\n", iExt);
469 theM.Statistics(cout);
470 // Resize
471 theM.ReSize(8);
472 theM.Statistics(cout);
473 cout.flush();
474 // Constructor
475 ////////////////////////////////QANCollection_IndexedMap aM;
476 QANCollection_IndexedMapFunc aM;
477 // Add, FindKey, FindIndex
478 Key1Type aKey;
479 for (i=0; i<8; i++)
480 {
481 Random (aKey);
482 aM.Add (aKey);
483 Standard_Integer iIndex=aM.FindIndex(aKey);
484 printf (" added a key, i=%d, k=",iIndex);
485 PrintItem(aM(iIndex));
486 }
487 // Contains, Remove
488 if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey))))
489 {
490 printf("Error : map says that it does not contain its key ");
491 PrintItem(aKey);
492 }
493 else
494 {
495 aM.RemoveLast();
496 printf(" successfully removed item, l=%d\n", aM.Size());
497 }
498 // Substitute
499 Random(aKey);
500 aM.Substitute(1,aKey);
501 // Copy constructor (including operator=)
502 ////////////////////////////////QANCollection_IndexedMap aM2 = QANCollection_IndexedMap(aM);
503 QANCollection_IndexedMapFunc aM2 = QANCollection_IndexedMapFunc(aM);
504 // Assign
505 AssignCollection (aM2,theM);
506
507 // Clear
508 aM.Clear();
509}
510
511// ===================== Test methods of IndexedDataMap type ==================
512////////////////////////////////void TestIndexedDataMap (QANCollection_IDMap& theM)
513static void TestIndexedDataMap (QANCollection_IDMapFunc& theM)
514{
515 // Extent
516 Standard_Integer iExt=theM.Extent();
517 Standard_Integer i;
518
519 printf ("Info: testing IndexedDataMap(l=%d)\n", iExt);
520 theM.Statistics(cout);
521 // Resize
522 theM.ReSize(8);
523 theM.Statistics(cout);
524 cout.flush();
525 // Constructor
526 ////////////////////////////////QANCollection_IDMap aM;
527 QANCollection_IDMapFunc aM;
528 // Add, FindKey, FindIndex, FindFromIndex, Change..., ()
529 Key1Type aKey;
530 ItemType anItem;
531 for (i=0; i<8; i++)
532 {
533 Random (aKey);
534 Random (anItem);
535 aM.Add (aKey, anItem);
536 Standard_Integer iIndex=aM.FindIndex(aKey);
537 printf (" added a key, i=%d, k=",iIndex);
538 PrintItem(aM.FindKey(iIndex));
539 PrintItem(aM(iIndex));
540 Random(aM.ChangeFromIndex(iIndex));
541 }
542 // Contains, Remove, FindFromKey
543 if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey))))
544 {
545 printf("Error : map says that it does not contain its key ");
546 PrintItem(aKey);
547 }
548 else
549 {
550 anItem = aM.FindFromKey(aKey);
551 aM.RemoveLast();
552 printf(" successfully removed item, l=%d\n", aM.Size());
553 }
554 // Substitute
555 Random(aKey);
556 aM.Substitute (1, aKey, anItem);
557 // Copy constructor (including operator=)
558 ////////////////////////////////theM = QANCollection_IDMap(aM);
559 theM = QANCollection_IDMapFunc(aM);
560 // Assign - prohibited
561 // AssignCollection (aM2,theM);
562 printCollection (theM, "DoubleMap:");
563
564 // Clear
565 aM.Clear();
566}
567
568//=======================================================================
569//function : CheckArguments1
570//purpose :
571//=======================================================================
572Standard_Integer CheckArguments1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& Lower, Standard_Integer& Upper)
573{
574 if ( argc != 3) {
575 di << "Usage : " << argv[0] << " Lower Upper" << "\n";
576 return 1;
577 }
578 Lower = Draw::Atoi(argv[1]);
579 Upper = Draw::Atoi(argv[2]);
580 if ( Lower > Upper ) {
581 di << "Lower > Upper" << "\n";
582 return 1;
583 }
584 return 0;
585}
586
587//=======================================================================
588//function : CheckArguments2
589//purpose :
590//=======================================================================
591Standard_Integer CheckArguments2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& LowerRow, Standard_Integer& UpperRow, Standard_Integer& LowerCol, Standard_Integer& UpperCol)
592{
593 if ( argc != 5) {
594 di << "Usage : " << argv[0] << " LowerRow UpperRow LowerCol UpperCol" << "\n";
595 return 1;
596 }
597 LowerRow = Draw::Atoi(argv[1]);
598 UpperRow = Draw::Atoi(argv[2]);
599 LowerCol = Draw::Atoi(argv[3]);
600 UpperCol = Draw::Atoi(argv[4]);
601 if ( LowerRow > UpperRow ) {
602 di << "LowerRow > UpperRow" << "\n";
603 return 1;
604 }
605 if ( LowerCol > UpperCol ) {
606 di << "LowerCol UpperCol> " << "\n";
607 return 1;
608 }
609 return 0;
610}
611
612
613//=======================================================================
614//function : QANColTestArray1
615//purpose :
616//=======================================================================
617static Standard_Integer QANColTestArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
618{
619 Standard_Integer Lower, Upper;
620 if ( CheckArguments1(di, argc, argv, Lower, Upper) ) {
621 return 1;
622 }
623 QANCollection_Array1Func anArr1(Lower, Upper);
624 TestArray1(anArr1);
625 return 0;
626}
627
628//=======================================================================
629//function : QANColTestArray2
630//purpose :
631//=======================================================================
632static Standard_Integer QANColTestArray2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
633{
634 Standard_Integer LowerRow, UpperRow, LowerCol, UpperCol;
635 if ( CheckArguments2(di, argc, argv, LowerRow, UpperRow, LowerCol, UpperCol) ) {
636 return 1;
637 }
638 QANCollection_Array2Func anArr2(LowerRow, UpperRow, LowerCol, UpperCol);
639 TestArray2(anArr2);
640 return 0;
641}
642
643//=======================================================================
644//function : QANColTestMap
645//purpose :
646//=======================================================================
647static Standard_Integer QANColTestMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
648{
649 if ( argc != 1) {
650 di << "Usage : " << argv[0] << "\n";
651 return 1;
652 }
653 QANCollection_MapFunc aMap;
654 TestMap(aMap);
655 return 0;
656}
657
658//=======================================================================
659//function : QANColTestDataMap
660//purpose :
661//=======================================================================
662static Standard_Integer QANColTestDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
663{
664 if ( argc != 1) {
665 di << "Usage : " << argv[0] << "\n";
666 return 1;
667 }
668 QANCollection_DataMapFunc aDataMap;
669 TestDataMap(aDataMap);
670 return 0;
671}
672
673//=======================================================================
674//function : QANColTestDoubleMap
675//purpose :
676//=======================================================================
677static Standard_Integer QANColTestDoubleMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
678{
679 if ( argc != 1) {
680 di << "Usage : " << argv[0] << "\n";
681 return 1;
682 }
683 QANCollection_DoubleMapFunc aDoubleMap;
684 TestDoubleMap(aDoubleMap);
685 return 0;
686}
687
688//=======================================================================
689//function : QANColTestIndexedMap
690//purpose :
691//=======================================================================
692static Standard_Integer QANColTestIndexedMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
693{
694 if ( argc != 1) {
695 di << "Usage : " << argv[0] << "\n";
696 return 1;
697 }
698 QANCollection_IndexedMapFunc aIndexedMap;
699 TestIndexedMap(aIndexedMap);
700 return 0;
701}
702
703//=======================================================================
704//function : QANColTestIndexedDataMap
705//purpose :
706//=======================================================================
707static Standard_Integer QANColTestIndexedDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
708{
709 if ( argc != 1) {
710 di << "Usage : " << argv[0] << "\n";
711 return 1;
712 }
713 QANCollection_IDMapFunc aIDMap;
714 TestIndexedDataMap(aIDMap);
715 return 0;
716}
717
718//=======================================================================
719//function : QANColTestList
720//purpose :
721//=======================================================================
722static Standard_Integer QANColTestList(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
723{
724 if ( argc != 1) {
725 di << "Usage : " << argv[0] << "\n";
726 return 1;
727 }
728 QANCollection_ListFunc aList;
729 TestList(aList);
730 return 0;
731}
732
e3a6386d 733//=======================================================================
734//function : QANColTestVector
735//purpose :
736//=======================================================================
737static Standard_Integer QANColTestVector (Draw_Interpretor&, Standard_Integer, const char**)
738{
739 // test method Append and copying of empty vector
740 NCollection_Vector<int> aVec;
741 NCollection_Vector<int> aVec2 (aVec);
742 NCollection_Vector<int> aVec3;
743 aVec3 = aVec;
744
745 aVec.Append(5);
746 if (aVec(0) != 5)
747 std::cout << "Error: wrong value in original vector!" << endl;
748 aVec2.Append(5);
749 if (aVec2(0) != 5)
750 std::cout << "Error: wrong value in copy-constructed vector!" << endl;
751 aVec3.Append(5);
752 if (aVec3(0) != 5)
753 std::cout << "Error: wrong value in copied vector!" << endl;
754 std::cout << "Test OK" << endl;
755
756 return 0;
757}
758
3a01a933 759//=======================================================================
760//function : QANColTestSequence
761//purpose :
762//=======================================================================
763static Standard_Integer QANColTestSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
764{
765 if ( argc != 1) {
766 di << "Usage : " << argv[0] << "\n";
767 return 1;
768 }
769 QANCollection_SequenceFunc aSeq;
770 TestSequence(aSeq);
771 return 0;
772}
773
774void QANCollection::CommandsTest(Draw_Interpretor& theCommands) {
775 const char *group = "QANCollection";
776
777 // from agvCollTest/src/CollectionEXE/FuncTestEXE.cxx
778 theCommands.Add("QANColTestArray1", "QANColTestArray1", __FILE__, QANColTestArray1, group);
779 theCommands.Add("QANColTestArray2", "QANColTestArray2", __FILE__, QANColTestArray2, group);
780 theCommands.Add("QANColTestMap", "QANColTestMap", __FILE__, QANColTestMap, group);
781 theCommands.Add("QANColTestDataMap", "QANColTestDataMap", __FILE__, QANColTestDataMap, group);
782 theCommands.Add("QANColTestDoubleMap", "QANColTestDoubleMap", __FILE__, QANColTestDoubleMap, group);
783 theCommands.Add("QANColTestIndexedMap", "QANColTestIndexedMap", __FILE__, QANColTestIndexedMap, group);
784 theCommands.Add("QANColTestIndexedDataMap", "QANColTestIndexedDataMap", __FILE__, QANColTestIndexedDataMap, group);
785 theCommands.Add("QANColTestList", "QANColTestList", __FILE__, QANColTestList, group);
786 theCommands.Add("QANColTestSequence", "QANColTestSequence", __FILE__, QANColTestSequence, group);
e3a6386d 787 theCommands.Add("QANColTestVector", "QANColTestVector", __FILE__, QANColTestVector, group);
3a01a933 788}