1 // Created on: 2002-04-30
2 // Created by: Alexander KARTOMIN (akm)
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef QANCollection_FuncMaps_HeaderFile
17 #define QANCollection_FuncMaps_HeaderFile
19 // ===================== Test methods of Map type =============================
20 ////////////////////////////////void TestMap (QANCollection_Map& theM)
21 void TestMap (QANCollection_MapFunc& theM)
24 Standard_Integer iExt=theM.Extent();
27 printf ("Info: testing Map(l=%d)\n", iExt);
28 theM.Statistics(cout);
31 theM.Statistics(cout);
34 ////////////////////////////////QANCollection_Map aM;
35 QANCollection_MapFunc aM;
44 if (!aM.Contains(aKey))
46 printf("Error : map says that it does not contain its key ");
52 printf(" successfully removed item, l=%d\n", aM.Size());
54 // Copy constructor (including operator=)
55 ////////////////////////////////QANCollection_Map aM2 = QANCollection_Map(aM);
56 QANCollection_MapFunc aM2 = QANCollection_MapFunc(aM);
58 AssignCollection (aM2,theM);
64 // ===================== Test methods of DataMap type =========================
65 ////////////////////////////////void TestDataMap (QANCollection_DataMap& theM)
66 void TestDataMap (QANCollection_DataMapFunc& theM)
69 Standard_Integer iExt=theM.Extent();
72 printf ("Info: testing DataMap(l=%d)\n", iExt);
73 theM.Statistics(cout);
76 theM.Statistics(cout);
79 ////////////////////////////////QANCollection_DataMap aM;
80 QANCollection_DataMapFunc aM;
81 // Bind, Find, ChangeFind, ()
88 aM.Bind (aKey, anItem);
89 PrintItem(aM.Find(aKey));
93 if (!aM.IsBound(aKey))
95 printf("Error : map says that it does not contain its key ");
101 printf(" successfully unbound the key, l=%d\n", aM.Size());
103 // Copy constructor (including operator=)
104 ////////////////////////////////theM = QANCollection_DataMap(aM);
105 theM = QANCollection_DataMapFunc(aM);
106 // Assign - prohibited
107 // AssignCollection (aM2,theM);
108 printCollection (theM, "DataMap:");
115 // ===================== Test methods of DoubleMap type =======================
116 ////////////////////////////////void TestDoubleMap (QANCollection_DoubleMap& theM)
117 void TestDoubleMap (QANCollection_DoubleMapFunc& theM)
120 Standard_Integer iExt=theM.Extent();
123 printf ("Info: testing DoubleMap(l=%d)\n", iExt);
124 theM.Statistics(cout);
127 theM.Statistics(cout);
130 ////////////////////////////////QANCollection_DoubleMap aM;
131 QANCollection_DoubleMapFunc aM;
139 aM.Bind (aKey1, aKey2);
140 PrintItem(aM.Find1(aKey1));
141 if (!aM.IsBound1(aKey1))
143 printf("Error : map says that it does not contain its key ");
146 PrintItem(aM.Find2(aKey2));
147 if (!aM.IsBound2(aKey2))
149 printf("Error : map says that it does not contain its key ");
154 if (!aM.AreBound(aKey1,aKey2))
156 printf("Error : map says that it does not contain its keys ");
162 if (aM.UnBind2(aKey2))
163 printf(" successfully unbound the key, l=%d\n", aM.Size());
164 if (aM.UnBind1(aKey1))
165 printf("Error : unbound both keys?!\n");
167 // Copy constructor (including operator=)
168 ////////////////////////////////theM = QANCollection_DoubleMap(aM);
169 theM = QANCollection_DoubleMapFunc(aM);
170 // Assign - prohibited
171 // AssignCollection (aM2,theM);
172 printCollection (theM, "DoubleMap:");
178 // ===================== Test methods of IndexedMap type ======================
179 ////////////////////////////////void TestIndexedMap (QANCollection_IndexedMap& theM)
180 void TestIndexedMap (QANCollection_IndexedMapFunc& theM)
183 Standard_Integer iExt=theM.Extent();
186 printf ("Info: testing IndexedMap(l=%d)\n", iExt);
187 theM.Statistics(cout);
190 theM.Statistics(cout);
193 ////////////////////////////////QANCollection_IndexedMap aM;
194 QANCollection_IndexedMapFunc aM;
195 // Add, FindKey, FindIndex
201 Standard_Integer iIndex=aM.FindIndex(aKey);
202 printf (" added a key, i=%d, k=",iIndex);
203 PrintItem(aM(iIndex));
206 if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey))))
208 printf("Error : map says that it does not contain its key ");
214 printf(" successfully removed item, l=%d\n", aM.Size());
218 aM.Substitute(1,aKey);
219 // Copy constructor (including operator=)
220 ////////////////////////////////QANCollection_IndexedMap aM2 = QANCollection_IndexedMap(aM);
221 QANCollection_IndexedMapFunc aM2 = QANCollection_IndexedMapFunc(aM);
223 AssignCollection (aM2,theM);
229 // ===================== Test methods of IndexedDataMap type ==================
230 ////////////////////////////////void TestIndexedDataMap (QANCollection_IDMap& theM)
231 void TestIndexedDataMap (QANCollection_IDMapFunc& theM)
234 Standard_Integer iExt=theM.Extent();
237 printf ("Info: testing IndexedDataMap(l=%d)\n", iExt);
238 theM.Statistics(cout);
241 theM.Statistics(cout);
244 ////////////////////////////////QANCollection_IDMap aM;
245 QANCollection_IDMapFunc aM;
246 // Add, FindKey, FindIndex, FindFromIndex, Change..., ()
253 aM.Add (aKey, anItem);
254 Standard_Integer iIndex=aM.FindIndex(aKey);
255 printf (" added a key, i=%d, k=",iIndex);
256 PrintItem(aM.FindKey(iIndex));
257 PrintItem(aM(iIndex));
258 Random(aM.ChangeFromIndex(iIndex));
260 // Contains, Remove, FindFromKey
261 if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey))))
263 printf("Error : map says that it does not contain its key ");
268 anItem = aM.FindFromKey(aKey);
270 printf(" successfully removed item, l=%d\n", aM.Size());
274 aM.Substitute (1, aKey, anItem);
275 // Copy constructor (including operator=)
276 ////////////////////////////////theM = QANCollection_IDMap(aM);
277 theM = QANCollection_IDMapFunc(aM);
278 // Assign - prohibited
279 // AssignCollection (aM2,theM);
280 printCollection (theM, "DoubleMap:");