59 return (T*)(0x777777);
79 RCPNode *rcpNode = basicRCPNodeNoAlloc<T>(p, has_ownership);
88 (*node)->delete_obj();
145 #endif // TEUCHOS_DEBUG
155 typedef RCPNodeTracer::RCPNodeStatistics RCPNodeStatistics;
159 RCPNode *node = basicRCPNode<A>(
true);
173 rcpNodeStatisticsBefore.maxNumRCPNodes);
175 rcpNodeStatisticsBefore.totalNumRCPNodeAllocations+1);
177 rcpNodeStatisticsBefore.totalNumRCPNodeDeletions);
188 rcpNodeStatisticsBefore.maxNumRCPNodes);
190 rcpNodeStatisticsBefore.totalNumRCPNodeAllocations+1);
192 rcpNodeStatisticsBefore.totalNumRCPNodeDeletions+1);
195 std::ostringstream statsOut_oss;
197 std::ostringstream expectedStatsOut_oss;
200 <<
"\n*** RCPNode Tracing statistics:"
202 <<
"\n maxNumRCPNodes = "<<rcpNodeStatistics2.maxNumRCPNodes
203 <<
"\n totalNumRCPNodeAllocations = "<<rcpNodeStatistics2.totalNumRCPNodeAllocations
204 <<
"\n totalNumRCPNodeDeletions = "<<rcpNodeStatistics2.totalNumRCPNodeDeletions
206 TEST_EQUALITY(statsOut_oss.str(), expectedStatsOut_oss.str());
216 #ifdef HAVE_TEUCHOS_STACKTRACE
218 Teuchos::store_stacktrace();
221 RCPNode *node1 = basicRCPNodeNoAlloc<A>(a_ptr,
true);
225 RCPNode *node2 = basicRCPNodeNoAlloc<A>(a_ptr,
true);
230 node2->has_ownership(
false);
239 RCPNode *node1 = basicRCPNodeNoAlloc<A>(a_ptr,
true);
243 RCPNode *node2 = basicRCPNodeNoAlloc<A>(a_ptr,
false);
260 RCPNode *node1 = basicRCPNodeNoAlloc<A>(a_ptr,
false);
264 RCPNode *node2 = basicRCPNodeNoAlloc<A>(a_ptr,
true);
281 ECHO(RCPNode *node_c = basicRCPNodeNoAlloc<C>(c_ptr,
true));
282 ECHO(RCPNode *node_b1 = basicRCPNodeNoAlloc<B1>(c_ptr,
true));
286 #ifdef HAS_TEUCHOS_GET_BASE_OBJ_VOID_PTR
298 ECHO(node_b1->has_ownership(
false));
304 #ifdef HAVE_TEUCHOS_DEBUG_RCP_NODE_TRACING
308 RCPNode *node = basicRCPNode<A>(
true);
312 #endif // HAVE_TEUCHOS_DEBUG_RCP_NODE_TRACING
315 #endif // TEUCHOS_DEBUG
333 TEST_EQUALITY( nodeRef.get_base_obj_map_key_void_ptr(), static_cast<void*>(p) );
335 std::invalid_argument);
337 std::invalid_argument);
338 #endif // TEUCHOS_DEBUG
378 ECHO(nodeRef2.debug_assert_valid_ptr(mockRCP));
381 ECHO(nodeRef1 =
null);
382 ECHO(nodeRef3 =
null);
393 TEST_THROW( nodeRef2.debug_assert_valid_ptr(mockRCP),
397 ECHO(nodeRef2 =
null);
417 ECHO(nodeRef2.debug_assert_valid_ptr(mockRCP));
419 ECHO(nodeRef2 =
null);
429 nodeRef1.debug_assert_valid_ptr(mockRCP);
440 #if defined(TEUCHOS_DEBUG) && !defined(HAVE_TEUCHOS_DEBUG_RCP_NODE_TRACING)
441 # define DO_RCPNODE_TRACING_TESTS 1
445 #ifdef DO_RCPNODE_TRACING_TESTS
452 RCPNodeTracer::setTracingActiveRCPNodes(
true);
458 const std::string T_name =
"T_name";
459 const std::string concreateT_name =
"concreateT_name";
460 const bool has_ownership =
true;
461 RCPNode *node =
new RCPNodeTmpl<T,DeallocDelete<T> >(
462 p, DeallocDelete<T>(), has_ownership);
464 RCPNodeHandle nodeRef(node, p, T_name, concreateT_name, has_ownership);
468 out <<
"\nMake sure output is printed when there is an active node with tracing ...\n";
472 std::ostringstream expendedOutput_oss;
476 <<
" 0: RCPNode (map_key_void_ptr=" << rcpNodeKey <<
")\n"
477 <<
" Information = {T="<<T_name<<
", ConcreteT="<<concreateT_name<<
", p="<<p<<
", has_ownership="<<has_ownership<<
"}\n"
478 <<
" RCPNode address = " << node <<
"\n"
479 <<
" insertionNumber = " << node->insertion_number()
483 std::ostringstream printActiveRCPNodes_out;
485 TEST_EQUALITY( printActiveRCPNodes_out.str(), expendedOutput_oss.str() );
501 out <<
"\nMake sure no output is printed when there are no active nodes ...\n";
502 const std::string expendedOutput =
"";
503 std::ostringstream printActiveRCPNodes_out;
505 TEST_EQUALITY( printActiveRCPNodes_out.str(), expendedOutput );
507 RCPNodeTracer::setTracingActiveRCPNodes(
false);
517 RCPNodeTracer::setTracingActiveRCPNodes(
false);
521 const std::string T_name =
"T_name";
522 const std::string concreateT_name =
"concreateT_name";
523 const bool has_ownership =
true;
524 RCPNode *node =
new RCPNodeTmpl<T,DeallocDelete<T> >(
525 p, DeallocDelete<T>(), has_ownership);
527 RCPNodeHandle nodeRef(node, p, T_name, concreateT_name, has_ownership);
531 out <<
"\nMake sure no output is printed when there are no active nodes without tracing ...\n";
532 const std::string expendedOutput =
"";
533 std::ostringstream printActiveRCPNodes_out;
535 TEST_EQUALITY( printActiveRCPNodes_out.str(), expendedOutput );
540 #endif // DO_RCPNODE_TRACING_TESTS
591 any &a4 = nodeRef2.get_extra_data(a1.
typeName(),
"a1");
634 std::invalid_argument);
637 std::invalid_argument);
639 #endif // TEUCHOS_DEBUG
664 std::invalid_argument);
667 std::invalid_argument);
669 #endif // TEUCHOS_DEBUG
685 #ifdef DO_RCPNODE_TRACING_TESTS
687 # define DEBUG_UNIT_TEST_GROUP( T ) \
688 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, debugWithNodeTracingPrint, T ) \
689 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, debugWithoutNodeTracingPrint, T )
693 # define DEBUG_UNIT_TEST_GROUP( T )
698 #define UNIT_TEST_GROUP( T ) \
699 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, basicConstruct_owns_mem, T ) \
700 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, basicConstruct_no_owns_mem, T ) \
701 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, weakPtr_basic_1, T ) \
702 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, weakPtr_basic_2, T ) \
703 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, copyConstruct, T ) \
704 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, assignmentOperator, T ) \
705 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, extraData_basic, T ) \
706 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, extraData_basic_const, T ) \
707 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, extraData_failed, T ) \
708 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( RCPNodeHandle, extraData_failed_const, T ) \
709 DEBUG_UNIT_TEST_GROUP(T)