|
Teuchos Package Browser (Single Doxygen Collection) Version of the Day
|
00001 /* 00002 // @HEADER 00003 // *********************************************************************** 00004 // 00005 // Teuchos: Common Tools Package 00006 // Copyright (2004) Sandia Corporation 00007 // 00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00009 // license for use of this work by or on behalf of the U.S. Government. 00010 // 00011 // This library is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Lesser General Public License as 00013 // published by the Free Software Foundation; either version 2.1 of the 00014 // License, or (at your option) any later version. 00015 // 00016 // This library is distributed in the hope that it will be useful, but 00017 // WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 // Lesser General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Lesser General Public 00022 // License along with this library; if not, write to the Free Software 00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00024 // USA 00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00026 // 00027 // *********************************************************************** 00028 // @HEADER 00029 */ 00030 00031 #include "Teuchos_UnitTestHarness.hpp" 00032 #include "Array_UnitTest_helpers.hpp" 00033 #include "TestClasses.hpp" 00034 #include "Teuchos_ArrayRCP.hpp" 00035 #include "Teuchos_RCP.hpp" 00036 #include "Teuchos_implicit_cast.hpp" 00037 #include "Teuchos_as.hpp" 00038 #include "Teuchos_getRawPtr.hpp" 00039 00040 namespace { 00041 00042 using ArrayUnitTestHelpers::n; 00043 using ArrayUnitTestHelpers::generateArray; 00044 00045 typedef Teuchos_Ordinal Ordinal; 00046 using Teuchos::getRawPtr; 00047 using Teuchos::as; 00048 using Teuchos::null; 00049 using Teuchos::rcp; 00050 using Teuchos::RCP; 00051 using Teuchos::ArrayRCP; 00052 using Teuchos::Array; 00053 using Teuchos::arcp; 00054 using Teuchos::arcpCloneNode; 00055 using Teuchos::arcp_reinterpret_cast; 00056 using Teuchos::arcp_reinterpret_cast_nonpod; 00057 using Teuchos::ArrayView; 00058 using Teuchos::getConst; 00059 using Teuchos::DuplicateOwningRCPError; 00060 using Teuchos::NullReferenceError; 00061 using Teuchos::DanglingReferenceError; 00062 using Teuchos::RangeError; 00063 using Teuchos::RCP_STRONG; 00064 using Teuchos::RCP_WEAK; 00065 using Teuchos::RCP_STRENGTH_INVALID; 00066 using Teuchos::implicit_ptr_cast; 00067 using Teuchos::getRawPtr; 00068 00069 00070 // 00071 // Non templated unit tests 00072 // 00073 00074 00075 TEUCHOS_UNIT_TEST( ArrayRCP, memberPointer ) 00076 { 00077 ArrayRCP<A> a_arcp = arcp<A>(1); 00078 TEST_EQUALITY_CONST( a_arcp->A_f(), A_f_return ); 00079 } 00080 00081 00082 TEUCHOS_UNIT_TEST( ArrayRCP, getConst_null ) 00083 { 00084 const ArrayRCP<A> a1_arcp; 00085 const ArrayRCP<const A> a2_arcp = a1_arcp.getConst(); 00086 TEST_ASSERT(is_null(a2_arcp)); 00087 } 00088 00089 00090 TEUCHOS_UNIT_TEST( ArrayRCP, operator_parenth_ArrayView_null ) 00091 { 00092 const ArrayRCP<A> a_arcp; 00093 const ArrayView<A> av = a_arcp(); 00094 TEST_ASSERT(is_null(av)); 00095 } 00096 00097 00098 TEUCHOS_UNIT_TEST( ArrayRCP, operator_parenth_ArrayView_const_null ) 00099 { 00100 const ArrayRCP<const A> a_arcp; 00101 const ArrayView<const A> av = a_arcp(); 00102 TEST_ASSERT(is_null(av)); 00103 } 00104 00105 00106 TEUCHOS_UNIT_TEST( ArrayRCP, implicit_ArrayRCP_const ) 00107 { 00108 const ArrayRCP<A> a_arcp; 00109 const ArrayRCP<const A> ac_arcp = a_arcp; 00110 TEST_ASSERT(is_null(ac_arcp)); 00111 } 00112 00113 00114 TEUCHOS_UNIT_TEST( ArrayRCP, ArrayRCP_void_throws ) 00115 { 00116 TEST_THROW( const ArrayRCP< void> v_arcp, std::logic_error ); 00117 TEST_THROW( const ArrayRCP<const void> cv_arcp, std::logic_error ); 00118 } 00119 00120 00121 TEUCHOS_UNIT_TEST( ArrayRCP, release ) 00122 { 00123 ArrayRCP<A> a_arcp = arcp<A>(1); 00124 delete [] a_arcp.release(); 00125 } 00126 00127 00128 TEUCHOS_UNIT_TEST( ArrayRCP, arcp_null ) 00129 { 00130 ArrayRCP<A> a_arcp = arcp<A>(0, 0, -1, false); 00131 TEST_ASSERT(is_null(a_arcp)); 00132 } 00133 00134 00135 TEUCHOS_UNIT_TEST( ArrayRCP, arcp_dealloc_null ) 00136 { 00137 ArrayRCP<A> a_arcp = arcp<A, Teuchos::DeallocNull<A> >(0, 0, -1, 00138 Teuchos::DeallocNull<A>(), false); 00139 TEST_ASSERT(is_null(a_arcp)); 00140 } 00141 00142 00143 TEUCHOS_UNIT_TEST( ArrayRCP, convert_from_vector_null ) 00144 { 00145 const RCP<std::vector<int> > v_rcp; 00146 const ArrayRCP<int> a_arcp = arcp(v_rcp); 00147 TEST_ASSERT(is_null(a_arcp)); 00148 } 00149 00150 00151 TEUCHOS_UNIT_TEST( ArrayRCP, convert_from_const_vector_null ) 00152 { 00153 const RCP<const std::vector<int> > v_rcp; 00154 const ArrayRCP<const int> a_arcp = arcp(v_rcp); 00155 TEST_ASSERT(is_null(a_arcp)); 00156 } 00157 00158 00159 TEUCHOS_UNIT_TEST( ArrayRCP, convert_from_vector_unsized ) 00160 { 00161 const RCP<std::vector<int> > v_rcp = rcp(new std::vector<int>); 00162 const ArrayRCP<int> a_arcp = arcp(v_rcp); 00163 TEST_ASSERT(is_null(a_arcp)); 00164 } 00165 00166 00167 TEUCHOS_UNIT_TEST( ArrayRCP, convert_from_const_vector_unsized ) 00168 { 00169 const RCP<const std::vector<int> > v_rcp = rcp(new std::vector<int>); 00170 const ArrayRCP<const int> a_arcp = arcp(v_rcp); 00171 TEST_ASSERT(is_null(a_arcp)); 00172 } 00173 00174 00175 TEUCHOS_UNIT_TEST( ArrayRCP, arcpWithEmbeddedObj ) 00176 { 00177 const ArrayRCP<const int> a_arcp = 00178 Teuchos::arcpWithEmbeddedObj<int>(new int[1], 0, 1, as<int>(1), true); 00179 const int embeddedObj = Teuchos::getEmbeddedObj<int,int>(a_arcp); 00180 TEST_EQUALITY_CONST( embeddedObj, as<int>(1) ); 00181 } 00182 00183 00184 TEUCHOS_UNIT_TEST( ArrayRCP, nonnull ) 00185 { 00186 ECHO(ArrayRCP<int> a_arcp = arcp<int>(10)); 00187 TEST_EQUALITY_CONST(is_null(a_arcp), false); 00188 TEST_EQUALITY_CONST(nonnull(a_arcp), true); 00189 ECHO(a_arcp = null); 00190 TEST_EQUALITY_CONST(is_null(a_arcp), true); 00191 TEST_EQUALITY_CONST(nonnull(a_arcp), false); 00192 } 00193 00194 00195 TEUCHOS_UNIT_TEST( ArrayRCP, weak_strong ) 00196 { 00197 00198 ECHO(ArrayRCP<int> arcp1 = arcp<int>(10)); 00199 TEST_EQUALITY_CONST( arcp1.strength(), RCP_STRONG ); 00200 00201 ECHO(ArrayRCP<int> arcp2 = arcp1.create_weak()); 00202 00203 TEST_EQUALITY_CONST( arcp2.strength(), RCP_WEAK ); 00204 TEST_EQUALITY_CONST( arcp1.strong_count(), 1 ); 00205 TEST_EQUALITY_CONST( arcp1.weak_count(), 1 ); 00206 TEST_EQUALITY_CONST( arcp2.strong_count(), 1 ); 00207 TEST_EQUALITY_CONST( arcp2.weak_count(), 1 ); 00208 00209 ECHO(ArrayRCP<int> arcp3 = arcp2.create_strong()); 00210 00211 TEST_EQUALITY_CONST( arcp3.strength(), RCP_STRONG ); 00212 TEST_EQUALITY_CONST( arcp1.strong_count(), 2 ); 00213 TEST_EQUALITY_CONST( arcp1.weak_count(), 1 ); 00214 TEST_EQUALITY_CONST( arcp2.strong_count(), 2 ); 00215 TEST_EQUALITY_CONST( arcp2.weak_count(), 1 ); 00216 00217 // This will make the underlying object A gets deleted! 00218 ECHO(arcp1 = null); 00219 ECHO(arcp3 = null); 00220 00221 ECHO(arcp2 = null); // Should make the underlying node go away 00222 00223 } 00224 00225 00226 TEUCHOS_UNIT_TEST( ArrayRCP, arcp_reinterpret_cast_null ) 00227 { 00228 ECHO(ArrayRCP<char> arcp_char = null); 00229 ECHO(ArrayRCP<int> arcp_int = arcp_reinterpret_cast<int>(arcp_char)); 00230 TEST_EQUALITY_CONST(arcp_int, null); 00231 } 00232 00233 00234 TEUCHOS_UNIT_TEST( ArrayRCP, arcp_reinterpret_cast_char_to_int ) 00235 { 00236 00237 const int sizeOfInt = sizeof(int); 00238 const int sizeOfChar = sizeof(char); 00239 const int num_ints = n; 00240 const int num_chars = (num_ints*sizeOfInt)/sizeOfChar; 00241 out << "num_ints = " << num_ints << "\n"; 00242 out << "num_chars = " << num_chars << "\n"; 00243 00244 ECHO(ArrayRCP<char> arcp_char = arcp<char>(num_chars)); 00245 ECHO(ArrayRCP<int> arcp_int = arcp_reinterpret_cast<int>(arcp_char)); 00246 TEST_EQUALITY(arcp_int.size(), num_ints); 00247 TEST_EQUALITY(implicit_ptr_cast<void>(&arcp_int[0]), 00248 implicit_ptr_cast<void>(&arcp_char[0])); 00249 TEST_EQUALITY(implicit_ptr_cast<void>((&arcp_int[num_ints-1])+1), 00250 implicit_ptr_cast<void>((&arcp_char[num_chars-1])+1)); 00251 00252 ECHO(arcp_char+=sizeOfInt); 00253 ECHO(arcp_int = arcp_reinterpret_cast<int>(arcp_char)); 00254 TEST_EQUALITY(arcp_int.size(), num_ints); 00255 TEST_EQUALITY_CONST( arcp_int.lowerOffset(), -1); 00256 TEST_EQUALITY( arcp_int.upperOffset(), num_ints-2); 00257 TEST_EQUALITY( implicit_ptr_cast<void>(&arcp_int[-1]), 00258 implicit_ptr_cast<void>(&arcp_char[-sizeOfInt]) 00259 ); 00260 TEST_EQUALITY( implicit_ptr_cast<void>((&arcp_int[num_ints-2])+1), 00261 implicit_ptr_cast<void>((&arcp_char[num_chars-1-sizeOfInt])+1)); 00262 00263 } 00264 00265 00266 TEUCHOS_UNIT_TEST( ArrayRCP, arcp_reinterpret_cast_int_to_char ) 00267 { 00268 00269 const int sizeOfInt = sizeof(int); 00270 const int sizeOfChar = sizeof(char); 00271 const int num_ints = n; 00272 const int num_chars = (num_ints*sizeOfInt)/sizeOfChar; 00273 out << "num_ints = " << num_ints << "\n"; 00274 out << "num_chars = " << num_chars << "\n"; 00275 00276 ECHO(ArrayRCP<int> arcp_int = arcp<int>(num_ints)); 00277 ECHO(ArrayRCP<char> arcp_char = arcp_reinterpret_cast<char>(arcp_int)); 00278 TEST_EQUALITY(arcp_char.size(), num_chars); 00279 TEST_EQUALITY(implicit_ptr_cast<void>(&arcp_int[0]), 00280 implicit_ptr_cast<void>(&arcp_char[0])); 00281 TEST_EQUALITY(implicit_ptr_cast<void>((&arcp_int[num_ints-1])+1), 00282 implicit_ptr_cast<void>((&arcp_char[num_chars-1])+1)); 00283 TEST_EQUALITY(implicit_ptr_cast<void>((&arcp_int[num_ints-1])+1), 00284 implicit_ptr_cast<void>((&arcp_char[num_chars-1])+1)); 00285 00286 ECHO(++arcp_int); 00287 ECHO(arcp_char = arcp_reinterpret_cast<char>(arcp_int)); 00288 TEST_EQUALITY(as<int>(arcp_char.lowerOffset()), as<int>(-sizeOfInt)); 00289 TEST_EQUALITY(as<int>(arcp_char.upperOffset()), as<int>(num_chars-1-sizeOfInt)); 00290 TEST_EQUALITY(implicit_ptr_cast<void>(&arcp_int[-1]), 00291 implicit_ptr_cast<void>(&arcp_char[-sizeOfInt])); 00292 TEST_EQUALITY(implicit_ptr_cast<void>((&arcp_int[num_ints-2])+1), 00293 implicit_ptr_cast<void>((&arcp_char[num_chars-1-sizeOfInt])+1)); 00294 00295 } 00296 00297 00298 TEUCHOS_UNIT_TEST( ArrayRCP, evil_reinterpret_cast ) 00299 { 00300 ECHO(ArrayRCP<ArrayRCP<int> > arcp1 = arcp<ArrayRCP<int> >(n)); 00301 ECHO(ArrayRCP<ArrayRCP<const int> > arcp2 = 00302 arcp_reinterpret_cast<ArrayRCP<const int> >(arcp1)); 00303 TEST_EQUALITY(arcp2.size(), arcp1.size()); 00304 TEST_EQUALITY(implicit_ptr_cast<const void>(&arcp1[0]), 00305 implicit_ptr_cast<const void>(&arcp2[0])); 00306 ECHO(ArrayRCP<const ArrayRCP<const int> > arcp3 = arcp2); 00307 TEST_EQUALITY(arcp3.size(), arcp1.size()); 00308 TEST_EQUALITY(implicit_ptr_cast<const void>(&arcp1[0]), 00309 implicit_ptr_cast<const void>(&arcp3[0])); 00310 out << "arcp3 = " << arcp3 << "\n"; 00311 } 00312 00313 00314 // 00315 // Test arcpCloneNode(...) 00316 // 00317 00318 00319 TEUCHOS_UNIT_TEST( ArrayRCP, arcpCloneNode_null ) 00320 { 00321 ECHO(ArrayRCP<ArrayRCP<int> > arcp1 = null); 00322 ECHO(ArrayRCP<ArrayRCP<int> > arcp2 = arcpCloneNode(arcp1)); 00323 TEST_EQUALITY(arcp2, null); 00324 } 00325 00326 00327 TEUCHOS_UNIT_TEST( ArrayRCP, arcpCloneNode_basic ) 00328 { 00329 00330 ECHO(ArrayRCP<int> arcp1 = arcp<int>(n)); 00331 00332 ECHO(ArrayRCP<int> arcp2 = arcpCloneNode(arcp1)); 00333 TEST_ASSERT(nonnull(arcp2)); 00334 TEST_EQUALITY(arcp1.count(), 2); 00335 TEST_EQUALITY(arcp2.count(), 1); 00336 00337 ECHO(ArrayRCP<int> arcp3 = arcp2); 00338 TEST_EQUALITY(arcp1.count(), 2); 00339 TEST_EQUALITY(arcp2.count(), 2); 00340 TEST_EQUALITY(arcp3.count(), 2); 00341 00342 ECHO(ArrayRCP<int> arcp4 = arcp1); 00343 TEST_EQUALITY(arcp1.count(), 3); 00344 TEST_EQUALITY(arcp2.count(), 2); 00345 TEST_EQUALITY(arcp3.count(), 2); 00346 00347 ECHO(arcp4 = null); 00348 TEST_EQUALITY(arcp1.count(), 2); 00349 TEST_EQUALITY(arcp2.count(), 2); 00350 TEST_EQUALITY(arcp3.count(), 2); 00351 TEST_EQUALITY(arcp4.count(), 0); 00352 00353 ECHO(arcp1 = null); 00354 TEST_EQUALITY(arcp1.count(), 0); 00355 TEST_EQUALITY(arcp2.count(), 2); 00356 TEST_EQUALITY(arcp3.count(), 2); 00357 TEST_EQUALITY(arcp4.count(), 0); 00358 00359 ECHO(arcp2 = null); 00360 TEST_EQUALITY(arcp2.count(), 0); 00361 TEST_EQUALITY(arcp3.count(), 1); 00362 00363 ECHO(arcp3 = null); 00364 TEST_EQUALITY(arcp3.count(), 0); 00365 00366 } 00367 00368 00369 // 00370 // Test arcp_reinterpret_cast_nonpod(...) 00371 // 00372 00373 00374 class MockObject { 00375 int member_; 00376 public: 00377 00378 MockObject(int member_in = -1) : member_(member_in) { ++(numConstructorsCalled()); } 00379 MockObject(const MockObject &mo) : member_(mo.member_) { ++(numCopyConstructorsCalled()); } 00380 ~MockObject() { ++(numDestructorsCalled()); } 00381 int member() const { return member_; } 00382 00383 static int & numConstructorsCalled() 00384 { static int s_numConstructorsCalled = 0; return s_numConstructorsCalled; } 00385 static int & numCopyConstructorsCalled() 00386 { static int s_numCopyConstructorsCalled = 0; return s_numCopyConstructorsCalled; } 00387 static int & numDestructorsCalled() 00388 { static int s_numDestructorsCalled = 0; return s_numDestructorsCalled; } 00389 static void reset() { numConstructorsCalled() = numCopyConstructorsCalled() = numDestructorsCalled() = 0; } 00390 00391 }; 00392 00393 00394 TEUCHOS_UNIT_TEST( ArrayRCP, arcp_reinterpret_cast_nonpod_default_construct ) 00395 { 00396 00397 const int sizeOfMockObject = sizeof(MockObject); 00398 const int sizeOfChar = sizeof(char); 00399 const int num_objs = n; 00400 const int num_chars = (num_objs*sizeOfMockObject)/sizeOfChar; 00401 out << "num_objs = " << num_objs << "\n"; 00402 out << "num_chars = " << num_chars << "\n"; 00403 00404 ECHO(ArrayRCP<char> arcp_chars = arcp<char>(num_chars)); 00405 00406 ECHO(MockObject::reset()); 00407 TEST_EQUALITY(MockObject::numConstructorsCalled(), 0); 00408 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), 0); 00409 TEST_EQUALITY(MockObject::numDestructorsCalled(), 0); 00410 ECHO(ArrayRCP<MockObject> arcp_objs = 00411 arcp_reinterpret_cast_nonpod<MockObject>(arcp_chars)); 00412 TEST_EQUALITY(arcp_objs.size(), num_objs); 00413 TEST_EQUALITY(MockObject::numConstructorsCalled(), 1); 00414 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), num_objs); 00415 TEST_EQUALITY(MockObject::numDestructorsCalled(), 1); 00416 { 00417 int sum = 0; for (int i=0; i < num_objs; ++i) sum += arcp_objs[i].member(); 00418 TEST_EQUALITY(sum, -num_objs); 00419 } 00420 00421 ECHO(ArrayRCP<MockObject> arcp_objs2 = arcp_objs); 00422 TEST_EQUALITY(arcp_objs.size(), num_objs); 00423 TEST_EQUALITY(MockObject::numConstructorsCalled(), 1); 00424 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), num_objs); 00425 TEST_EQUALITY(MockObject::numDestructorsCalled(), 1); 00426 { 00427 int sum = 0; for (int i=0; i < num_objs; ++i) sum += arcp_objs[i].member(); 00428 TEST_EQUALITY(sum, -num_objs); 00429 } 00430 00431 ECHO(arcp_objs = null); 00432 TEST_EQUALITY(MockObject::numConstructorsCalled(), 1); 00433 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), num_objs); 00434 TEST_EQUALITY(MockObject::numDestructorsCalled(), 1); 00435 00436 ECHO(arcp_objs2 = null); 00437 TEST_EQUALITY(MockObject::numConstructorsCalled(), 1); 00438 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), num_objs); 00439 TEST_EQUALITY(MockObject::numDestructorsCalled(), num_objs + 1); 00440 00441 } 00442 00443 00444 TEUCHOS_UNIT_TEST( ArrayRCP, arcp_reinterpret_cast_nonpod_copy_construct ) 00445 { 00446 00447 const int sizeOfMockObject = sizeof(MockObject); 00448 const int sizeOfChar = sizeof(char); 00449 const int num_objs = n; 00450 const int num_chars = (num_objs*sizeOfMockObject)/sizeOfChar; 00451 out << "num_objs = " << num_objs << "\n"; 00452 out << "num_chars = " << num_chars << "\n"; 00453 00454 ECHO(ArrayRCP<char> arcp_chars = arcp<char>(num_chars)); 00455 00456 ECHO(MockObject::reset()); 00457 TEST_EQUALITY(MockObject::numConstructorsCalled(), 0); 00458 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), 0); 00459 TEST_EQUALITY(MockObject::numDestructorsCalled(), 0); 00460 ECHO(const MockObject mockObj(1)); 00461 TEST_EQUALITY(MockObject::numConstructorsCalled(), 1); 00462 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), 0); 00463 TEST_EQUALITY(MockObject::numDestructorsCalled(), 0); 00464 00465 ECHO(MockObject::reset()); 00466 TEST_EQUALITY(MockObject::numConstructorsCalled(), 0); 00467 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), 0); 00468 TEST_EQUALITY(MockObject::numDestructorsCalled(), 0); 00469 ECHO(ArrayRCP<MockObject> arcp_objs = 00470 arcp_reinterpret_cast_nonpod(arcp_chars, mockObj)); 00471 TEST_EQUALITY(arcp_objs.size(), num_objs); 00472 TEST_EQUALITY(MockObject::numConstructorsCalled(), 0); 00473 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), num_objs); 00474 TEST_EQUALITY(MockObject::numDestructorsCalled(), 0); 00475 { 00476 int sum = 0; for (int i=0; i < num_objs; ++i) sum += arcp_objs[i].member(); 00477 TEST_EQUALITY(sum, num_objs); 00478 } 00479 00480 ECHO(ArrayRCP<MockObject> arcp_objs2 = arcp_objs); 00481 TEST_EQUALITY(arcp_objs.size(), num_objs); 00482 TEST_EQUALITY(MockObject::numConstructorsCalled(), 0); 00483 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), num_objs); 00484 TEST_EQUALITY(MockObject::numDestructorsCalled(), 0); 00485 { 00486 int sum = 0; for (int i=0; i < num_objs; ++i) sum += arcp_objs[i].member(); 00487 TEST_EQUALITY(sum, num_objs); 00488 } 00489 00490 ECHO(arcp_objs = null); 00491 TEST_EQUALITY(MockObject::numConstructorsCalled(), 0); 00492 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), num_objs); 00493 TEST_EQUALITY(MockObject::numDestructorsCalled(), 0); 00494 00495 ECHO(arcp_objs2 = null); 00496 TEST_EQUALITY(MockObject::numConstructorsCalled(), 0); 00497 TEST_EQUALITY(MockObject::numCopyConstructorsCalled(), num_objs); 00498 TEST_EQUALITY(MockObject::numDestructorsCalled(), num_objs); 00499 00500 } 00501 00502 00503 // 00504 // Test catching of duplicate owning ArrayRCP objects 00505 // 00506 00507 00508 TEUCHOS_UNIT_TEST( ArrayRCP, duplicate_arcp_owning ) 00509 { 00510 SET_RCPNODE_TRACING(); 00511 ECHO(A *a_ptr = new A[n]); 00512 ECHO(ArrayRCP<A> a_arcp1 = arcp(a_ptr, 0, n)); // Okay 00513 #if defined(TEUCHOS_DEBUG) 00514 // With node tracing turned on, the implementation knows that an RCPNode 00515 // already exists pointing to this same underlying array and will therefore 00516 // throw. 00517 TEST_THROW(ArrayRCP<A> a_arcp2 = arcp(a_ptr, 0, n), DuplicateOwningRCPError); 00518 #else 00519 // Will not determine they are point to the same object! 00520 ECHO(ArrayRCP<A> a_arcp2 = arcp(a_ptr, 0, n)); 00521 TEST_EQUALITY(a_arcp2.getRawPtr(), a_ptr); 00522 ECHO(a_arcp2.release()); // Better or we will get a segfault! 00523 #endif 00524 } 00525 00526 00527 TEUCHOS_UNIT_TEST( ArrayRCP, dangling_nonowning ) 00528 { 00529 SET_RCPNODE_TRACING(); 00530 ECHO(A *a_ptr = new A[n]); 00531 ECHO(ArrayRCP<A> a_arcp1 = arcp(a_ptr, 0, n)); // Okay 00532 ECHO(ArrayRCP<A> a_arcp2 = arcp(a_ptr, 0, n, false)); // Okay 00533 a_arcp1 = null; 00534 #if defined(TEUCHOS_DEBUG) 00535 // With node tracing turned on, the implementation knows that the original 00536 // array is deleted and this is a dangling reference! 00537 TEST_THROW(a_arcp2.getRawPtr(), DanglingReferenceError); 00538 #else 00539 // With node tracing turned off, the implemetation does not know the 00540 // original array is deleted and therefore it will return a now invalid 00541 // pointer. 00542 TEST_NOTHROW(a_arcp2.getRawPtr()); 00543 #endif 00544 } 00545 00546 00547 class WeirdDealloc { 00548 int size_; 00549 RCP<std::ostream > out_; 00550 public: 00551 WeirdDealloc(int size, const RCP<std::ostream> &out) : size_(size), out_(out) {} 00552 void free(void *ptr) const 00553 { 00554 int * const int_ptr = reinterpret_cast<int*>(ptr); 00555 { 00556 // Create an ArrayView that points to the same memory that is being 00557 // deallocated by the owning ArrayRCP. Here, if RCPNode tracing is 00558 // enabled, this will thrown and there is really no way around it. 00559 ArrayView<const int> tmpav(int_ptr, size_, Teuchos::RCP_DISABLE_NODE_LOOKUP); 00560 assert(tmpav[0] == int_ptr[0]); 00561 *out_ << tmpav << std::endl; 00562 // Create a copy of the ArrayView and make sure that it does not do 00563 // node tracing either. 00564 ArrayView<const int> tmpav2(tmpav); 00565 assert(tmpav2[0] == int_ptr[0]); 00566 *out_ << tmpav2 << std::endl; 00567 // Assign the ArrayView and make sure that it does not do node tracing 00568 // either. 00569 ArrayView<const int> tmpav3; 00570 tmpav3 = tmpav; 00571 assert(tmpav3[0] == int_ptr[0]); 00572 *out_ << tmpav2 << std::endl; 00573 } 00574 delete [] int_ptr; 00575 } 00576 }; 00577 00578 00579 TEUCHOS_UNIT_TEST( ArrayRCP, weirdDealloc ) 00580 { 00581 using Teuchos::rcpFromRef; 00582 const int size = 4; 00583 const bool ownsMem = true; 00584 int *int_ptr = new int[size]; 00585 std::fill_n(int_ptr, size, 0); 00586 ArrayRCP<int> a = arcp<int>( int_ptr , 0, size, 00587 WeirdDealloc(size, rcpFromRef(out)), ownsMem ); 00588 a = Teuchos::null; 00589 } 00590 00591 00592 // 00593 // Templated unit tests 00594 // 00595 00596 00597 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, construct_n, T ) 00598 { 00599 std::vector<T> a(n, as<T>(1)); 00600 ArrayRCP<T> a_arcp(n, as<T>(1)); 00601 TEST_COMPARE_ARRAYS(a, a_arcp); 00602 } 00603 00604 00605 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, assignSelf, T ) 00606 { 00607 ArrayRCP<T> a_arcp; 00608 a_arcp = a_arcp; 00609 } 00610 00611 00612 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, assign_n_val, T ) 00613 { 00614 const T val = as<T>(1); 00615 std::vector<T> a; 00616 a.assign(n, val); 00617 ArrayRCP<T> a_arcp; 00618 a_arcp.assign(as<Ordinal>(n), val); 00619 TEST_COMPARE_ARRAYS(a, a_arcp); 00620 } 00621 00622 00623 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, assign_begin_end, T ) 00624 { 00625 const T val = as<T>(1); 00626 std::vector<T> a; 00627 a.assign(n, val); 00628 ArrayRCP<T> a_arcp; 00629 a_arcp.assign(a.begin(), a.end()); 00630 TEST_COMPARE_ARRAYS(a, a_arcp); 00631 } 00632 00633 00634 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, deepCopy, T ) 00635 { 00636 const T val = as<T>(1); 00637 std::vector<T> a; 00638 a.assign(n, val); 00639 ArrayRCP<T> a_arcp = arcp<T>(n); 00640 ArrayRCP<T> a_arcp_cpy = a_arcp; 00641 a_arcp.deepCopy(Teuchos::arrayViewFromVector(a)); 00642 TEST_COMPARE_ARRAYS(a, a_arcp); 00643 TEST_EQUALITY(a_arcp.getRawPtr(), a_arcp_cpy.getRawPtr()); 00644 } 00645 00646 00647 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, resize, T ) 00648 { 00649 const T val1 = as<T>(1); 00650 const T val2 = as<T>(2); 00651 00652 std::vector<T> a; 00653 ArrayRCP<T> a_arcp; 00654 00655 out << "\nChecking resize(n, val1) ...\n"; 00656 a.resize(n, val1); 00657 a_arcp.resize(n, val1); 00658 TEST_COMPARE_ARRAYS(a, a_arcp); 00659 00660 out << "\nChecking resize(2*n, val2) ...\n"; 00661 a.resize(2*n, val2); 00662 a_arcp.resize(2*n, val2); 00663 TEST_COMPARE_ARRAYS(a, a_arcp); 00664 00665 out << "\nChecking resize(n/2) ...\n"; 00666 a.resize(n/2); 00667 a_arcp.resize(n/2); 00668 TEST_COMPARE_ARRAYS(a, a_arcp); 00669 00670 out << "\nChecking resize(0) ...\n"; 00671 a.resize(0); 00672 a_arcp.resize(0); 00673 TEST_COMPARE_ARRAYS(a, a_arcp); 00674 00675 #ifdef TEUCHOS_DEBUG 00676 a_arcp = arcp<T>(n); 00677 ++a_arcp; 00678 TEST_THROW(a_arcp.resize(1), std::out_of_range); 00679 #endif 00680 } 00681 00682 00683 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, clear, T ) 00684 { 00685 ArrayRCP<T> a_arcp = arcp<T>(n); 00686 TEST_EQUALITY( a_arcp.size(), n ); 00687 a_arcp.clear(); 00688 TEST_EQUALITY( a_arcp.size(), 0 ); 00689 } 00690 00691 00692 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, nullIterator, T ) 00693 { 00694 typedef ArrayRCP<T> iter_t; 00695 ArrayRCP<T> arcp1 = Teuchos::NullIteratorTraits<iter_t>::getNull(); 00696 TEST_EQUALITY_CONST(arcp1, Teuchos::null); 00697 } 00698 00699 00700 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, implicitConversions, T ) 00701 { 00702 00703 ECHO(ArrayRCP<T> arcp1 = arcp<T>(n)); 00704 ECHO(ArrayRCP<const T> arcp2 = arcp1); 00705 TEST_ASSERT(arcp1.shares_resource(arcp2)); 00706 00707 } 00708 00709 00710 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, weakDelete, T ) 00711 { 00712 00713 ECHO(ArrayRCP<T> arcp_strong = arcp<T>(n)); 00714 00715 TEST_EQUALITY_CONST( arcp_strong.strength(), RCP_STRONG ); 00716 TEST_EQUALITY_CONST( arcp_strong.is_null(), false ); 00717 TEST_EQUALITY_CONST( arcp_strong.strong_count(), 1 ); 00718 TEST_EQUALITY_CONST( arcp_strong.weak_count(), 0 ); 00719 TEST_EQUALITY_CONST( arcp_strong.total_count(), 1 ); 00720 00721 ECHO(ArrayRCP<T> arcp_weak1 = arcp_strong.create_weak()); 00722 00723 TEST_EQUALITY_CONST( arcp_weak1.strength(), RCP_WEAK ); 00724 TEST_EQUALITY_CONST( arcp_weak1.is_null(), false ); 00725 TEST_EQUALITY_CONST( arcp_weak1.strong_count(), 1 ); 00726 TEST_EQUALITY_CONST( arcp_weak1.weak_count(), 1 ); 00727 TEST_EQUALITY_CONST( arcp_weak1.total_count(), 2 ); 00728 00729 TEST_EQUALITY_CONST( arcp_strong.strong_count(), 1 ); 00730 TEST_EQUALITY_CONST( arcp_strong.is_null(), false ); 00731 TEST_EQUALITY_CONST( arcp_strong.weak_count(), 1 ); 00732 TEST_EQUALITY_CONST( arcp_strong.total_count(), 2 ); 00733 00734 TEST_EQUALITY_CONST( arcp_weak1.shares_resource(arcp_strong), true ); 00735 00736 TEST_EQUALITY( arcp_weak1.get(), arcp_weak1.getRawPtr() ); 00737 TEST_EQUALITY( arcp_weak1.get(), arcp_strong.get() ); 00738 TEST_EQUALITY( arcp_weak1.getRawPtr(), arcp_strong.getRawPtr() ); 00739 00740 ECHO(ArrayRCP<T> arcp_weak2 = arcp_weak1); 00741 00742 TEST_EQUALITY_CONST( arcp_weak2.strength(), RCP_WEAK ); 00743 TEST_EQUALITY_CONST( arcp_weak2.is_null(), false ); 00744 TEST_EQUALITY_CONST( arcp_weak2.strong_count(), 1 ); 00745 TEST_EQUALITY_CONST( arcp_weak2.weak_count(), 2 ); 00746 TEST_EQUALITY_CONST( arcp_weak2.total_count(), 3 ); 00747 00748 TEST_EQUALITY_CONST( arcp_strong.strong_count(), 1 ); 00749 TEST_EQUALITY_CONST( arcp_strong.is_null(), false ); 00750 TEST_EQUALITY_CONST( arcp_strong.weak_count(), 2 ); 00751 TEST_EQUALITY_CONST( arcp_strong.total_count(), 3 ); 00752 00753 TEST_EQUALITY_CONST( arcp_weak1.shares_resource(arcp_strong), true ); 00754 TEST_EQUALITY_CONST( arcp_weak1.shares_resource(arcp_weak2), true ); 00755 TEST_EQUALITY_CONST( arcp_weak2.shares_resource(arcp_strong), true ); 00756 00757 TEST_EQUALITY( arcp_weak2.get(), arcp_strong.get() ); 00758 TEST_EQUALITY( arcp_weak2.getRawPtr(), arcp_strong.getRawPtr() ); 00759 00760 ECHO(arcp_strong = null); // This deletes the underlying object of type T! 00761 00762 TEST_EQUALITY_CONST( arcp_strong.strength(), RCP_STRENGTH_INVALID ); 00763 TEST_EQUALITY_CONST( arcp_strong.is_null(), true ); 00764 TEST_EQUALITY_CONST( arcp_strong.count(), 0 ); 00765 TEST_EQUALITY_CONST( arcp_strong.strong_count(), 0 ); 00766 TEST_EQUALITY_CONST( arcp_strong.weak_count(), 0 ); 00767 TEST_EQUALITY_CONST( arcp_strong.total_count(), 0 ); 00768 TEST_EQUALITY_CONST( arcp_strong.is_valid_ptr(), true ); 00769 00770 TEST_EQUALITY_CONST( arcp_strong.shares_resource(arcp_weak1), false ); 00771 TEST_EQUALITY_CONST( arcp_strong.shares_resource(arcp_weak2), false ); 00772 00773 TEST_EQUALITY_CONST( arcp_weak1.has_ownership(), true ); 00774 TEST_EQUALITY_CONST( arcp_weak1.count(), 0 ); 00775 TEST_EQUALITY_CONST( arcp_weak1.strong_count(), 0 ); 00776 TEST_EQUALITY_CONST( arcp_weak1.weak_count(), 2 ); 00777 TEST_EQUALITY_CONST( arcp_weak1.total_count(), 2 ); 00778 TEST_EQUALITY_CONST( arcp_weak1.is_valid_ptr(), false ); 00779 00780 TEST_EQUALITY_CONST( arcp_weak2.has_ownership(), true ); 00781 TEST_EQUALITY_CONST( arcp_weak2.count(), 0 ); 00782 TEST_EQUALITY_CONST( arcp_weak2.strong_count(), 0 ); 00783 TEST_EQUALITY_CONST( arcp_weak2.weak_count(), 2 ); 00784 TEST_EQUALITY_CONST( arcp_weak2.total_count(), 2 ); 00785 TEST_EQUALITY_CONST( arcp_weak2.is_valid_ptr(), false ); 00786 00787 TEST_EQUALITY_CONST( arcp_weak1.shares_resource(arcp_weak2), true ); 00788 00789 ECHO(arcp_weak1.assert_not_null()); // Does not throw! 00790 ECHO(arcp_weak2.assert_not_null()); // Does not throw! 00791 00792 TEST_THROW( arcp_weak1.assert_valid_ptr(), DanglingReferenceError ); 00793 #ifdef TEUCHOS_DEBUG 00794 TEST_THROW( arcp_weak1.operator->(), DanglingReferenceError ); 00795 TEST_THROW( *arcp_weak1, DanglingReferenceError ); 00796 TEST_THROW( arcp_weak1.create_weak(), DanglingReferenceError ); 00797 TEST_THROW( arcp_weak1.get(), DanglingReferenceError ); 00798 TEST_THROW( arcp_weak1.getRawPtr(), DanglingReferenceError ); 00799 TEST_THROW( arcp_weak1[0], DanglingReferenceError ); 00800 TEST_THROW( ++arcp_weak1, DanglingReferenceError ); 00801 TEST_THROW( arcp_weak1++, DanglingReferenceError ); 00802 TEST_THROW( --arcp_weak1, DanglingReferenceError ); 00803 TEST_THROW( arcp_weak1--, DanglingReferenceError ); 00804 TEST_THROW( arcp_weak1+=1, DanglingReferenceError ); 00805 TEST_THROW( arcp_weak1-=1, DanglingReferenceError ); 00806 TEST_THROW( arcp_weak1+1, DanglingReferenceError ); 00807 TEST_THROW( arcp_weak1-1, DanglingReferenceError ); 00808 TEST_THROW( arcp_weak1.getConst(), DanglingReferenceError ); 00809 TEST_THROW( arcp_weak1.persistingView(0,n), DanglingReferenceError ); 00810 TEST_THROW( arcp_weak1.lowerOffset(), DanglingReferenceError ); 00811 TEST_THROW( arcp_weak1.upperOffset(), DanglingReferenceError ); 00812 TEST_THROW( arcp_weak1.size(), DanglingReferenceError ); 00813 TEST_THROW( arcp_weak1.begin(), DanglingReferenceError ); 00814 TEST_THROW( arcp_weak1.end(), DanglingReferenceError ); 00815 TEST_THROW( arcp_weak1.view(0,n), DanglingReferenceError ); 00816 TEST_THROW( arcp_weak1(0,n), DanglingReferenceError ); 00817 TEST_THROW( arcp_weak1(), DanglingReferenceError ); 00818 TEST_THROW( {ArrayView<T> av = arcp_weak1();}, DanglingReferenceError ); 00819 TEST_THROW( {ArrayRCP<const T> ap = getConst(arcp_weak1);}, 00820 DanglingReferenceError ); 00821 TEST_THROW( arcp_weak1.release(), DanglingReferenceError ); 00822 #endif // TEUCHOS_DEBUG 00823 00824 ECHO(arcp_weak1 = null); // Just deicrements weak count! 00825 00826 TEST_EQUALITY_CONST( arcp_weak1.strength(), RCP_STRENGTH_INVALID ); 00827 TEST_EQUALITY_CONST( arcp_weak1.is_null(), true ); 00828 TEST_EQUALITY_CONST( arcp_weak1.count(), 0 ); 00829 TEST_EQUALITY_CONST( arcp_weak1.strong_count(), 0 ); 00830 TEST_EQUALITY_CONST( arcp_weak1.weak_count(), 0 ); 00831 TEST_EQUALITY_CONST( arcp_weak1.total_count(), 0 ); 00832 TEST_EQUALITY_CONST( arcp_weak1.is_valid_ptr(), true ); 00833 00834 TEST_EQUALITY_CONST( arcp_weak2.has_ownership(), true ); 00835 TEST_EQUALITY_CONST( arcp_weak2.count(), 0 ); 00836 TEST_EQUALITY_CONST( arcp_weak2.strong_count(), 0 ); 00837 TEST_EQUALITY_CONST( arcp_weak2.weak_count(), 1 ); 00838 TEST_EQUALITY_CONST( arcp_weak2.total_count(), 1 ); 00839 TEST_EQUALITY_CONST( arcp_weak2.is_valid_ptr(), false ); 00840 00841 TEST_EQUALITY_CONST( arcp_weak1.shares_resource(arcp_weak2), false ); 00842 00843 TEST_THROW( arcp_weak2.assert_valid_ptr(), DanglingReferenceError ); 00844 #ifdef TEUCHOS_DEBUG 00845 // ToDo: Fill in 00846 #endif // TEUCHOS_DEBUG 00847 00848 } 00849 00850 00851 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, danglingArrayView, T ) 00852 { 00853 ArrayView<T> av; 00854 { 00855 ArrayRCP<T> arcp1 = arcp<T>(n); 00856 av = arcp1(); 00857 } 00858 #ifdef TEUCHOS_DEBUG 00859 TEST_THROW( av.size(), DanglingReferenceError ); 00860 TEST_THROW( av.toString(), DanglingReferenceError ); 00861 TEST_THROW( av.getRawPtr(), DanglingReferenceError ); 00862 TEST_THROW( av[0], DanglingReferenceError ); 00863 TEST_THROW( av.front(), DanglingReferenceError ); 00864 TEST_THROW( av.back(), DanglingReferenceError ); 00865 TEST_THROW( av.view(0, n), DanglingReferenceError ); 00866 TEST_THROW( av(0, n), DanglingReferenceError ); 00867 TEST_THROW( av(), DanglingReferenceError ); 00868 TEST_THROW( av.getConst(), DanglingReferenceError ); 00869 TEST_THROW( av.begin(), DanglingReferenceError ); 00870 TEST_THROW( av.end(), DanglingReferenceError ); 00871 #endif 00872 } 00873 00874 00875 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, getRawPtr, T ) 00876 { 00877 ArrayRCP<const T> cptr; 00878 ArrayRCP<T> ptr; 00879 TEST_EQUALITY_CONST( getRawPtr(cptr), (const T*)NULL ); 00880 TEST_EQUALITY_CONST( getRawPtr(ptr), (T*)NULL ); 00881 cptr = arcp<T>(n); 00882 ptr = arcp<T>(n); 00883 TEST_EQUALITY( getRawPtr(cptr), &cptr[0]); 00884 TEST_EQUALITY( getRawPtr(ptr), &ptr[0] ); 00885 } 00886 00887 00888 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( CPtr, getRawPtr, T ) 00889 { 00890 const T *cptr = NULL; 00891 T *ptr = NULL; 00892 TEST_EQUALITY_CONST( getRawPtr(cptr), (const T*)NULL ); 00893 TEST_EQUALITY_CONST( getRawPtr(ptr), (T*)NULL ); 00894 cptr = new T[n]; 00895 ptr = new T[n]; 00896 TEST_EQUALITY( getRawPtr(cptr), &cptr[0]); 00897 TEST_EQUALITY( getRawPtr(ptr), &ptr[0] ); 00898 delete [] cptr; 00899 delete [] ptr; 00900 } 00901 00902 00903 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, arcp_zero, T ) 00904 { 00905 ArrayRCP<T> arcp_strong = arcp<T>(0); 00906 TEST_EQUALITY(arcp_strong.size(), as<Ordinal>(0)); 00907 } 00908 00909 00910 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, arcpFromArrayView, T ) 00911 { 00912 Array<T> a = generateArray<T>(n); 00913 ArrayView<T> av = a; 00914 ArrayRCP<T> arcp1 = Teuchos::arcpFromArrayView(av); 00915 TEST_COMPARE_ARRAYS(arcp1, av); 00916 } 00917 00918 00919 #ifdef TEUCHOS_DEBUG 00920 00921 00922 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, arcp_neg, T ) 00923 { 00924 TEST_THROW(ArrayRCP<T> arcp_strong = arcp<T>(-1), 00925 std::out_of_range); 00926 } 00927 00928 00929 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayRCP, outOfBounds, T ) 00930 { 00931 ECHO(ArrayRCP<T> arcp1 = arcp<T>(n)); 00932 TEST_THROW(arcp1(-1,n), RangeError); 00933 TEST_THROW(arcp1(0,n+1), RangeError); 00934 TEST_THROW(arcp1(0,-1), RangeError); 00935 TEST_THROW(arcp1.view(-1,n), RangeError); 00936 TEST_THROW(arcp1.view(0,n+1), RangeError); 00937 TEST_THROW(arcp1.view(0,-1), RangeError); 00938 TEST_THROW(arcp1.persistingView(-1,n), RangeError); 00939 TEST_THROW(arcp1.persistingView(0,n+1), RangeError); 00940 TEST_THROW(arcp1.persistingView(0,-1), RangeError); 00941 } 00942 00943 00944 #endif // TEUCHOS_DEBUG 00945 00946 00947 // 00948 // Template Instantiations 00949 // 00950 00951 00952 #ifdef TEUCHOS_DEBUG 00953 00954 # define DEBUG_UNIT_TEST_GROUP( T ) \ 00955 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, arcp_neg, T ) \ 00956 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, outOfBounds, T ) \ 00957 00958 #else 00959 00960 # define DEBUG_UNIT_TEST_GROUP( T ) 00961 00962 #endif 00963 00964 00965 #define UNIT_TEST_GROUP( T ) \ 00966 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, construct_n, T ) \ 00967 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, assignSelf, T ) \ 00968 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, assign_n_val, T ) \ 00969 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, assign_begin_end, T ) \ 00970 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, deepCopy, T ) \ 00971 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, resize, T ) \ 00972 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, clear, T ) \ 00973 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, nullIterator, T ) \ 00974 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, implicitConversions, T ) \ 00975 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, weakDelete, T ) \ 00976 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, danglingArrayView, T ) \ 00977 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, getRawPtr, T) \ 00978 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( CPtr, getRawPtr, T) \ 00979 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, arcp_zero, T ) \ 00980 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayRCP, arcpFromArrayView, T ) \ 00981 DEBUG_UNIT_TEST_GROUP(T) 00982 00983 00984 UNIT_TEST_GROUP(int) 00985 UNIT_TEST_GROUP(double) 00986 UNIT_TEST_GROUP(float) 00987 00988 00989 } // namespace
1.7.4