1 // Copyright (c) 2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <QANCollection.hxx>
17 #include <Draw_Interpretor.hxx>
19 #include <Message_Status.hxx>
20 #include <NCollection_StdAllocator.hxx>
21 #include <NCollection_IncAllocator.hxx>
22 #include <NCollection_HeapAllocator.hxx>
23 #include <OSD_Timer.hxx>
24 #include <Standard_Assert.hxx>
25 #include <Standard_DefineHandle.hxx>
26 #include <Standard_Transient.hxx>
27 #include <TCollection_AsciiString.hxx>
28 #include <Geom_Circle.hxx>
29 #include <Geom_Line.hxx>
30 #include <Geom_BSplineCurve.hxx>
31 #include <Geom_Surface.hxx>
37 // Auxiliary macro to check and report status.
38 // Note that if() is used to ensure that condition is
39 // evaluated before calls to stream output functions, to
40 // prevent side effects from such calls in cases when condition
41 // may contain references to freed objects in the stack.
42 #define CHECK(di,ok,what) \
43 if (ok) di << "Checking " << what << ": OK\n";\
44 else di << "Checking " << what << ": Error\n"
46 //=======================================================================
47 //function : QAHandleOps
48 //purpose : Test Handle operations (mostly compile-time checks)
49 //=======================================================================
51 // set of overloaded functions for checking resolution of arguments
52 inline void f (const Handle(Geom_Curve)&) {}
53 inline void func (const Handle(Geom_Curve)&) {}
54 inline void func (const Handle(Geom_BSplineCurve)&) {}
55 inline void func (const Handle(Geom_Surface)&) {}
56 inline void func (const Handle(gp_Pnt)&) {}
57 inline void func (const Handle(gp_XYZ)&) {}
58 inline void func (const Handle(gp_Trsf)&) {}
60 static Standard_Integer QAHandleOps (Draw_Interpretor& theDI,
61 Standard_Integer /*theArgNb*/,
62 const char** /*theArgVec*/)
64 // ===============================================================
65 // Part 1: classes inheriting transient
66 // ===============================================================
68 Handle(Geom_Line) aLine = new Geom_Line (gp::Origin(), gp::DZ());
69 CHECK(theDI, ! aLine.IsNull(), "handle for non-null");
71 const Handle(Geom_Line)& cLine = aLine; // cast to self const ref
72 const Handle(Geom_Curve)& cCurve = aLine; // cast to base const ref
73 Geom_Line* pLine = aLine.get();
74 const Geom_Line* cpLine = aLine.get();
75 Geom_Line& rLine = *aLine;
76 const Geom_Line& crLine = *cLine;
77 Handle(Geom_Curve) aCurve = aLine; // copy from handle to derived type
78 aCurve = cLine; // assignment to handle of derived type
79 Handle(Geom_Line) dLine (cpLine); // copy from handle to derived type
81 aLine = Handle(Geom_Line)::DownCast (cCurve);
82 CHECK(theDI, ! aLine.IsNull(), "down cast");
84 // comparison operators
85 CHECK(theDI, aLine == aLine, "equality of handle to itself");
86 CHECK(theDI, cLine == cLine, "equality of const handle to itself");
87 CHECK(theDI, aLine == cLine, "equality of const and non-const handle");
88 CHECK(theDI, aLine == cCurve, "equality of handle and base handle");
89 CHECK(theDI, aLine == pLine, "equality of handle and pointer");
90 CHECK(theDI, pLine == aLine, "equality of pointer and handle");
91 CHECK(theDI, aLine == cpLine, "equality of handle and const pointer");
92 CHECK(theDI, cpLine == aLine, "equality of const pointer and handle");
93 CHECK(theDI, &rLine == aLine, "equality of reference and handle");
94 CHECK(theDI, &crLine == aLine, "equality of reference and handle");
95 CHECK(theDI, aLine, "cast to bool");
97 Handle(Geom_Line) aLin2;
98 CHECK(theDI, aLine != aLin2, "inequality of handle to the same type handle");
99 CHECK(theDI, aLin2 != cLine, "inequality of const and non-const handle");
100 CHECK(theDI, aLin2 != cCurve, "inequality of handle and base handle");
101 CHECK(theDI, aLin2 != pLine, "inequality of handle and pointer");
102 CHECK(theDI, pLine != aLin2, "inequality of pointer and handle");
103 CHECK(theDI, aLin2 != cpLine, "inequality of handle and const pointer");
104 CHECK(theDI, cpLine != aLin2, "inequality of const pointer and handle");
106 Handle(Geom_Curve) aCur2;
107 CHECK(theDI, aLine != aCur2, "inequality of handles of different types");
108 CHECK(theDI, aCur2 != cLine, "inequality of const and non-const handle");
109 CHECK(theDI, aCur2 != cCurve, "inequality of handle and base handle");
110 CHECK(theDI, aCur2 != pLine, "inequality of handle and pointer");
111 CHECK(theDI, pLine != aCur2, "inequality of pointer and handle");
112 CHECK(theDI, aCur2 != cpLine, "inequality of handle and const pointer");
113 CHECK(theDI, cpLine != aCur2, "inequality of const pointer and handle");
115 // passing handle as reference to base class
118 // passing handle to overloaded function accepting handle to another type
119 // will fail on VC below 12 and GCC below 4.3 due to ambiguity of overloads
120 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) || (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
125 const Handle(Geom_Curve)& aCurve2 = aLine; // cast to base const ref
126 CHECK (theDI, !aCurve2.IsNull (), "cast to base class const reference");
128 Handle(Geom_Line) qLine = cpLine; // constructor from const pointer -- could be made explicit...
130 // check that compiler keeps temporary object referenced by local variable
131 const Handle(Geom_Line)& aTmpRef (Handle(Geom_Line)::DownCast (aCurve2));
132 // note that here and in similar checks below we use comparison of pointers instead
133 // of checking handle for Null, since such check may fail if temporary object is
134 // destroyed prematurely and its location is used for other object.
135 CHECK(theDI, aTmpRef.get() == aCurve2.get(), "local reference of to temporary handle object");
137 // check undesired but logical situation:
138 // compiler does not keep temporary object referenced by local variable of base type;
139 // here compiler does not recognize that it should keep the temporary object because handle
140 // classes do not inherit each other and they use hard cast for references to simulate inheritance
141 const Handle(Geom_Curve)& aTmpRefBase (Handle(Geom_Line)::DownCast (aCurve2));
142 CHECK(theDI, aTmpRefBase.get() != aCurve2.get(), "local reference to temporary handle object (base type)");
144 // check operations with Handle_* classes
145 Handle(Geom_Line) hLine = aLine;
146 CHECK(theDI, ! hLine.IsNull(), "hhandle for non-null");
148 const Handle_Geom_Line& chLine = aLine; // cast to self const ref
149 const Handle_Geom_Curve& chCurve = aLine; // cast to base const ref
150 const Handle_Geom_Line& hhLine = hLine; // cast to self const ref
151 const Handle_Geom_Curve& hhCurve = hLine; // cast to base const ref
152 Handle_Geom_Curve hCurve = aLine; // copy from handle to derived type
153 Handle_Geom_Line phLine (aLine.get()); // construct from pointer
155 hLine = Handle_Geom_Line::DownCast (cCurve); // inheritance of downcast
156 CHECK(theDI, ! hLine.IsNull(), "down cast");
158 // comparison operators
159 CHECK(theDI, hLine == hLine, "equality of hhandle to itself");
160 CHECK(theDI, hLine == aLine, "equality of hhandle to handle");
161 CHECK(theDI, hhLine == hLine, "equality of hhandle to const");
162 CHECK(theDI, chLine == hLine, "equality of hhandle to const");
163 CHECK(theDI, hhCurve == hLine, "equality of hhandle to const");
164 CHECK(theDI, chCurve == hLine, "equality of hhandle to const");
165 CHECK(theDI, hLine, "cast to bool");
167 // passing hhandle as reference to base class
170 // passing handle to overloaded function accepting handle to another type
171 // will fail on VC below 12 and GCC below 4.3 due to ambiguity of overloads
172 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) || (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
177 Handle_Geom_Line qhLine = cpLine; // constructor from const pointer -- could be made explicit...
179 // check that compiler keeps temporary object referenced by local variable
180 const Handle_Geom_Line& hTmpRef (Handle(Geom_Line)::DownCast (aCurve2));
181 CHECK(theDI, hTmpRef.get() == aCurve2.get(), "local reference to temporary object (Handle_)");
183 // check lifetime of temporary object referenced by local variable (base type)
184 const Handle_Geom_Curve& hTmpRefBase (Handle(Geom_Line)::DownCast (aCurve2));
185 // here we have different behavior for MSVC 2013+ where Handle_ is a class
186 // (compiler creates temporary object of approprtiate type and keeps it living
187 // until the reference is valid) and other compilers where Handle_ is
188 // typedef to handle<> (compiler does not know that the reference that is being
189 // assigned is pointing to temporary object, due to involved type cast operation)
190 #if (defined(_MSC_VER) && _MSC_VER >= 1800)
191 CHECK(theDI, hTmpRefBase.get() == aCurve2.get(), "local reference to temporary handle object (Handle_ to base type)");
193 CHECK(theDI, hTmpRefBase.get() != aCurve2.get(), "local reference to temporary handle object (Handle_ to base type)");
196 Handle(Geom_Surface) aSurf;
200 // each test in this section must cause compiler error
201 gunc (cLine); // passing const handle as non-const reference to base type
202 pLine = cLine.get(); // getting non-const pointer to contained object from const handle
203 Handle(Geom_Line) xLine = cCurve; // copy from handle to base type
204 Handle(Geom_BSplineCurve) aBSpl (new Geom_Line (gp::Origin(), gp::DX())); // construction from pointer to incompatible type
206 CHECK(theDI, aLine == aSurf, "equality of handles of incompatible types");
207 CHECK(theDI, aSurf == cLine, "equality of const and non-const handle");
208 CHECK(theDI, aSurf == cCurve, "equality of handle and base handle");
209 CHECK(theDI, aSurf == pLine, "equality of handle and pointer");
210 CHECK(theDI, pLine == aSurf, "equality of pointer and handle");
211 CHECK(theDI, aSurf == cpLine, "equality of handle and const pointer");
212 CHECK(theDI, cpLine != aSurf, "equality of const pointer and handle");
214 CHECK(theDI, aLine != aSurf, "inequality of handles of incompatible types");
215 CHECK(theDI, aSurf != cLine, "inequality of const and non-const handle");
216 CHECK(theDI, aSurf != cCurve, "inequality of handle and base handle");
217 CHECK(theDI, aSurf != pLine, "inequality of handle and pointer");
218 CHECK(theDI, pLine != aSurf, "inequality of pointer and handle");
219 CHECK(theDI, aSurf != cpLine, "inequality of handle and const pointer");
220 CHECK(theDI, cpLine != aSurf, "inequality of const pointer and handle");
223 // ===============================================================
224 // Part 2: classes not inheriting transient
225 // ===============================================================
227 Handle(gp_Pnt) aPnt = new gp_Pnt (gp::Origin());
228 CHECK(theDI, ! aPnt.IsNull(), "handle for non-null");
230 const Handle(gp_Pnt)& cPnt = aPnt; // cast to self const ref
231 // const Handle(gp_XYZ)& cXYZ = aPnt; // cast to base const ref
232 gp_Pnt* pPnt = aPnt.get();
233 const gp_Pnt* cpPnt = aPnt.get();
234 gp_Pnt& rPnt = *aPnt;
235 const gp_Pnt& crPnt = *cPnt;
236 // Handle(gp_XYZ) aXYZ = aPnt; // copy from handle to derived type
237 // aXYZ = cPnt; // assignment to handle of derived type
239 // aPnt = Handle(gp_Pnt)::DownCast (cXYZ);
240 // CHECK(theDI, ! aPnt.IsNull(), "down cast");
242 // comparison operators
243 CHECK(theDI, aPnt == aPnt, "equality of handle to itself");
244 CHECK(theDI, cPnt == cPnt, "equality of const handle to itself");
245 CHECK(theDI, aPnt == cPnt, "equality of const and non-const handle");
246 // CHECK(theDI, aPnt == cXYZ, "equality of handle and base handle");
247 CHECK(theDI, aPnt == pPnt, "equality of handle and pointer");
248 CHECK(theDI, pPnt == aPnt, "equality of pointer and handle");
249 CHECK(theDI, aPnt == cpPnt, "equality of handle and const pointer");
250 CHECK(theDI, cpPnt == aPnt, "equality of const pointer and handle");
251 CHECK(theDI, &rPnt == aPnt, "equality of reference and handle");
252 CHECK(theDI, &crPnt == aPnt, "equality of reference and handle");
254 Handle(gp_Pnt) aPnt2;
255 CHECK(theDI, aPnt != aPnt2, "inequality of handle to the same type handle");
256 CHECK(theDI, aPnt2 != cPnt, "inequality of const and non-const handle");
257 // CHECK(theDI, aPnt2 != cXYZ, "inequality of handle and base handle");
258 CHECK(theDI, aPnt2 != pPnt, "inequality of handle and pointer");
259 CHECK(theDI, pPnt != aPnt2, "inequality of pointer and handle");
260 CHECK(theDI, aPnt2 != cpPnt, "inequality of handle and const pointer");
261 CHECK(theDI, cpPnt != aPnt2, "inequality of const pointer and handle");
263 Handle(gp_XYZ) aXYZ2;
264 CHECK(theDI, aLine != aPnt2, "inequality of handles of different types");
265 CHECK(theDI, aXYZ2 != cPnt, "inequality of const and non-const handle");
266 // CHECK(theDI, aXYZ2 != cXYZ, "inequality of handle and base handle");
267 // CHECK(theDI, aXYZ2 != pPnt, "inequality of handle and pointer");
268 // CHECK(theDI, pPnt != aXYZ2, "inequality of pointer and handle");
269 // CHECK(theDI, aXYZ2 != cpPnt, "inequality of handle and const pointer");
270 // CHECK(theDI, cpPnt != aXYZ2, "inequality of const pointer and handle");
272 // passing handle as reference to base class
279 //=======================================================================
280 //function : QAHandleBool
281 //purpose : Test Handle -> bool conversion
282 //=======================================================================
283 static Standard_Integer QAHandleBool (Draw_Interpretor& theDI,
284 Standard_Integer /*theArgNb*/,
285 const char** /*theArgVec*/)
287 Handle(NCollection_BaseAllocator) aPtr = new NCollection_IncAllocator();
289 Handle(NCollection_IncAllocator) anInc = Handle(NCollection_IncAllocator)::DownCast (aPtr);
290 CHECK (theDI, ! anInc.IsNull(), "cast to NCollection_IncAllocator");
292 Handle(NCollection_BaseAllocator) anAlloc = aPtr;
293 CHECK (theDI, ! anAlloc.IsNull(), "cast to NCollection_BaseAllocator");
295 Handle(NCollection_HeapAllocator) aHAlloc = Handle(NCollection_HeapAllocator)::DownCast (aPtr);
296 CHECK (theDI, aHAlloc.IsNull(), "cast to NCollection_HeapAllocator");
301 // Auxiliary class to define new virtual methods
302 class Transient_Root : public Standard_Transient
305 virtual const char* Name() const { return "Transient_Root"; }
306 virtual Standard_Transient* CreateParent() const { return new Standard_Transient; }
307 virtual Standard_Transient* Clone() const { return new Transient_Root; }
308 DEFINE_STANDARD_RTTI_INLINE(Transient_Root,Standard_Transient)
310 DEFINE_STANDARD_HANDLE(Transient_Root, Standard_Transient)
312 // Auxiliary macros to create hierarchy of 50 classes
313 #define QA_DEFINECLASS(theClass, theParent) \
314 class theClass : public theParent \
317 virtual const char* Name() const Standard_OVERRIDE { return #theClass; } \
318 virtual Standard_Transient* CreateParent() const Standard_OVERRIDE { return new theParent(); } \
319 virtual Standard_Transient* Clone() const Standard_OVERRIDE { return new theClass(); } \
320 DEFINE_STANDARD_RTTI_INLINE(theClass,theParent) \
322 DEFINE_STANDARD_HANDLE (theClass, theParent)
324 #define QA_NAME(theNum) qaclass ## theNum ## _ ## 50
325 #define QA_HANDLE_NAME(theNum) Handle(qaclass ## theNum ## _ ## 50)
327 #define QA_DEFINECLASS10(theParent, theTens) \
328 QA_DEFINECLASS(QA_NAME(theTens ## 0), theParent) \
329 QA_DEFINECLASS(QA_NAME(theTens ## 1), QA_NAME(theTens ## 0)) \
330 QA_DEFINECLASS(QA_NAME(theTens ## 2), QA_NAME(theTens ## 1)) \
331 QA_DEFINECLASS(QA_NAME(theTens ## 3), QA_NAME(theTens ## 2)) \
332 QA_DEFINECLASS(QA_NAME(theTens ## 4), QA_NAME(theTens ## 3)) \
333 QA_DEFINECLASS(QA_NAME(theTens ## 5), QA_NAME(theTens ## 4)) \
334 QA_DEFINECLASS(QA_NAME(theTens ## 6), QA_NAME(theTens ## 5)) \
335 QA_DEFINECLASS(QA_NAME(theTens ## 7), QA_NAME(theTens ## 6)) \
336 QA_DEFINECLASS(QA_NAME(theTens ## 8), QA_NAME(theTens ## 7)) \
337 QA_DEFINECLASS(QA_NAME(theTens ## 9), QA_NAME(theTens ## 8))
339 QA_DEFINECLASS10(Transient_Root, 0)
340 QA_DEFINECLASS10(qaclass09_50, 1)
341 QA_DEFINECLASS10(qaclass19_50, 2)
342 QA_DEFINECLASS10(qaclass29_50, 3)
343 QA_DEFINECLASS10(qaclass39_50, 4)
344 QA_DEFINECLASS (qaclass50_50, qaclass49_50)
348 class qaclass50_50ANON : public qaclass49_50
353 namespace QaNamespace
355 class qaclass50_50 : public qaclass49_50
363 //! Timer sentry. Prints elapsed time information at destruction time.
364 class QATimer : public OSD_Timer
379 //! Main constructor - automatically starts the timer.
380 QATimer (Draw_Interpretor& theDI,
381 Standard_CString theTitle,
382 const TimeFormat theFormat,
383 const Standard_Integer theNbIters = 1,
384 const Standard_Boolean theToPrintFormat = Standard_False)
387 myFormat (theFormat),
388 myNbIters (theNbIters),
389 myToPrintFormat (theToPrintFormat)
394 //! Destructor - stops the timer and prints statistics.
405 (*myDI) << ElapsedTime() / Standard_Real(myNbIters);
412 (*myDI) << (ElapsedTime() / Standard_Real(myNbIters)) * 1000.0;
419 (*myDI) << (ElapsedTime() / Standard_Real(myNbIters)) * 1000000.0;
422 (*myDI) << " microseconds";
426 (*myDI) << (ElapsedTime() / Standard_Real(myNbIters)) * 1000000000.0;
436 Draw_Interpretor* myDI;
437 Standard_CString myTitle; //!< timer description
438 TimeFormat myFormat; //!< time format
439 Standard_Integer myNbIters; //!< iterations number
440 Standard_Boolean myToPrintFormat; //!< add time format
442 } // anonymous namespace
444 //=======================================================================
445 //function : QAHandleInc
446 //purpose : Estimate the smart-pointer counter incrementing time
447 //=======================================================================
448 static Standard_Integer QAHandleInc (Draw_Interpretor& theDI,
449 Standard_Integer theArgNb,
450 const char** theArgVec)
454 std::cout << "Error: wrong syntax! See usage:\n";
455 theDI.PrintHelp (theArgVec[0]);
458 const Standard_Integer aNbIters = (theArgNb > 1) ? Draw::Atoi (theArgVec[1]) : 10000000;
461 std::cout << "Error: number of iterations should be positive!\n";
465 Handle(Standard_Transient) aHandle = new Standard_Transient();
466 opencascade::std::shared_ptr<Standard_Transient> aSharePtr (new Standard_Transient());
467 theDI << "Time of creating and destroying " << aNbIters << " smart pointers to the same object, per item, ns:";
470 QATimer aTimer (theDI, "\nOCCT Handle: ", QATimer::ns, aNbIters);
472 std::vector<Handle(Standard_Transient)> aHandles (aNbIters);
473 for (Standard_Integer anIter = 0; anIter < aNbIters; ++anIter)
475 aHandles[anIter] = aHandle;
480 QATimer aTimer (theDI, "\nC++ shared_ptr: ", QATimer::ns, aNbIters);
482 std::vector< opencascade::std::shared_ptr<Standard_Transient> > aSharePointers (aNbIters);
483 for (Standard_Integer anIter = 0; anIter < aNbIters; ++anIter)
485 aSharePointers[anIter] = aSharePtr;
493 //=======================================================================
494 //function : QAHandleKind
496 //=======================================================================
497 static Standard_Integer QAHandleKind (Draw_Interpretor& /*theDI*/,
498 Standard_Integer /*theArgNb*/,
499 const char** /*theArgVec*/)
501 Handle(Standard_Type) aType00 = STANDARD_TYPE(qaclass00_50);
502 Handle(Standard_Type) aType10 = STANDARD_TYPE(qaclass10_50);
503 Handle(Standard_Type) aType20 = STANDARD_TYPE(qaclass20_50);
504 Handle(Standard_Type) aType30 = STANDARD_TYPE(qaclass30_50);
505 Handle(Standard_Type) aType40 = STANDARD_TYPE(qaclass40_50);
506 Handle(Standard_Type) aType50 = STANDARD_TYPE(qaclass50_50);
508 Handle(qaclass00_50) aHandle = new qaclass40_50();
510 #define QA_CHECK(theDesc, theExpr, theValue) \
512 const bool isTrue = !!(theExpr); \
513 std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is Error\n"); \
516 std::cout << "Check instance of " << aHandle->DynamicType()->Name() << "\n";
517 for (Handle(Standard_Type) aType = aHandle->DynamicType(); ! aType.IsNull(); aType = aType->Parent())
519 std::cout << " - " << aType->Name() << "\n";
522 QA_CHECK ("Name == qaclass40_50 : ", TCollection_AsciiString("qaclass40_50") == aHandle->DynamicType()->Name(), true);
524 QA_CHECK ("IsKind (aType00) : ", aHandle->IsKind (aType00), true);
525 QA_CHECK ("IsKind (aType10) : ", aHandle->IsKind (aType10), true);
526 QA_CHECK ("IsKind (aType20) : ", aHandle->IsKind (aType20), true);
527 QA_CHECK ("IsKind (aType30) : ", aHandle->IsKind (aType30), true);
528 QA_CHECK ("IsKind (aType40) : ", aHandle->IsKind (aType40), true);
529 QA_CHECK ("IsKind (aType50) : ", aHandle->IsKind (aType50), false);
531 QA_CHECK ("IsKind (\"qaclass00_50\"): ", aHandle->IsKind ("qaclass00_50"), true);
532 QA_CHECK ("IsKind (\"qaclass10_50\"): ", aHandle->IsKind ("qaclass10_50"), true);
533 QA_CHECK ("IsKind (\"qaclass20_50\"): ", aHandle->IsKind ("qaclass20_50"), true);
534 QA_CHECK ("IsKind (\"qaclass30_50\"): ", aHandle->IsKind ("qaclass30_50"), true);
535 QA_CHECK ("IsKind (\"qaclass40_50\"): ", aHandle->IsKind ("qaclass40_50"), true);
536 QA_CHECK ("IsKind (\"qaclass50_50\"): ", aHandle->IsKind ("qaclass50_50"), false);
538 QA_CHECK ("IsInstance (aType00) : ", aHandle->IsInstance (aType00), false);
539 QA_CHECK ("IsInstance (aType10) : ", aHandle->IsInstance (aType10), false);
540 QA_CHECK ("IsInstance (aType20) : ", aHandle->IsInstance (aType20), false);
541 QA_CHECK ("IsInstance (aType30) : ", aHandle->IsInstance (aType30), false);
542 QA_CHECK ("IsInstance (aType40) : ", aHandle->IsInstance (aType40), true);
543 QA_CHECK ("IsInstance (aType50) : ", aHandle->IsInstance (aType50), false);
546 std::cout << "\nC++11:\n";
547 std::type_index aCppType = typeid(*aHandle.operator->());
548 std::cout << "typeid().name() = '" << typeid(*aHandle.operator->()).name() << "'\n";
550 std::cout << "typeid().raw_name()= '" << typeid(*aHandle.operator->()).raw_name() << "'\n";
553 std::cout << "[ANON]typeid().name() = '" << typeid(qaclass50_50ANON).name() << "'\n";
555 std::cout << "[ANON]typeid().raw_name()= '" << typeid(qaclass50_50ANON).raw_name() << "'\n";
558 std::cout << "[NS]typeid().name() = '" << typeid(QaNamespace::qaclass50_50).name() << "'\n";
560 std::cout << "[NS]typeid().raw_name()= '" << typeid(QaNamespace::qaclass50_50).raw_name() << "'\n";
563 QA_CHECK ("is typeid (aType00) : ", typeid(*aHandle.operator->()) == typeid(qaclass00_50), false);
564 QA_CHECK ("is typeid (aType10) : ", typeid(*aHandle.operator->()) == typeid(qaclass10_50), false);
565 QA_CHECK ("is typeid (aType20) : ", typeid(*aHandle.operator->()) == typeid(qaclass20_50), false);
566 QA_CHECK ("is typeid (aType30) : ", typeid(*aHandle.operator->()) == typeid(qaclass30_50), false);
567 QA_CHECK ("is typeid (aType40) : ", typeid(*aHandle.operator->()) == typeid(qaclass40_50), true);
568 QA_CHECK ("is typeid (aType50) : ", typeid(*aHandle.operator->()) == typeid(qaclass50_50), false);
570 QA_CHECK ("is type_index (aType00) : ", aCppType == typeid(qaclass00_50), false);
571 QA_CHECK ("is type_index (aType40) : ", aCppType == typeid(qaclass40_50), true);
573 QA_CHECK ("IsClass(Standard_Transient): ", std::is_class<Standard_Transient>::value == !!STANDARD_TYPE(Standard_Transient)->IsClass(), true);
574 //QA_CHECK ("IsEnum (Message_Status) : ", std::is_enum<Message_Status>::value == !!STANDARD_TYPE(Message_Status)->IsEnumeration(), true);
580 void QANCollection::CommandsHandle (Draw_Interpretor& theCommands)
582 const char* THE_GROUP = "QANCollection";
583 theCommands.Add ("QAHandleBool",
584 "Test handle boolean operator",
585 __FILE__, QAHandleBool, THE_GROUP);
586 theCommands.Add ("QAHandleInc",
587 "QAHandleInc nbIter=1000000"
588 "\n\t\t: Test handle increment performance",
589 __FILE__, QAHandleInc, THE_GROUP);
590 theCommands.Add ("QAHandleKind",
591 "Test handle IsKind",
592 __FILE__, QAHandleKind, THE_GROUP);
593 theCommands.Add ("QAHandleOps",
594 "Test handle operations",
595 __FILE__, QAHandleOps, THE_GROUP);