|
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 00032 #include "Teuchos_ArrayConversions.hpp" 00033 #include "Teuchos_implicit_cast.hpp" 00034 #include "Array_UnitTest_helpers.hpp" 00035 #include "ArrayConversions_UnitTest_helpers.hpp" 00036 #include "TestClasses.hpp" 00037 00038 namespace { 00039 00040 00041 using ArrayUnitTestHelpers::n; 00042 using ArrayConversionsUnitTestHelpers::generateArrayRcp; 00043 using ArrayConversionsUnitTestHelpers::generateArrayRcpGen; 00044 using ArrayConversionsUnitTestHelpers::testArrayViewInput; 00045 using ArrayConversionsUnitTestHelpers::testArrayViewOutput; 00046 using Teuchos::arrayPtrConv; 00047 using Teuchos::arrayRcpConv; 00048 using Teuchos::arrayViewPtrConv; 00049 using Teuchos::arrayViewRcpConv; 00050 using Teuchos::Array; 00051 using Teuchos::ArrayView; 00052 using Teuchos::Ptr; 00053 using Teuchos::RCP; 00054 using Teuchos::rcp; 00055 using Teuchos::as; 00056 using Teuchos::implicit_ptr_cast; 00057 00058 00059 // Verify generateArrayRcp works correctly 00060 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, generateArrayRcp, T ) 00061 { 00062 const Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00063 TEST_EQUALITY_CONST( as<Teuchos_Ordinal>(a_in.size()), n ); 00064 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00065 TEST_EQUALITY_CONST( Teuchos::is_null(a_in[i]), false ); 00066 TEST_EQUALITY_CONST( *a_in[i], as<T>(i) ); 00067 } 00068 } 00069 00070 00071 // Verify testArrayViewInput works correctly 00072 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, testArrayViewInput, T ) 00073 { 00074 typedef Teuchos::ScalarTraits<T> ST; 00075 const Array<RCP<T> > a_data = generateArrayRcp<T>(n); 00076 Array<Ptr<const T> > a_in(n); 00077 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00078 a_in[i] = a_data[i].ptr(); 00079 } 00080 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00081 TEST_EQUALITY_CONST( Teuchos::is_null(a_in[i]), false ); 00082 } 00083 T a_out = testArrayViewInput<T>(a_in); 00084 TEST_EQUALITY_CONST( a_out, as<T>(n*(n-1)/2) ); 00085 } 00086 00087 00088 // Verify testArrayViewOutput works correctly 00089 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, testArrayViewOutput, T ) 00090 { 00091 typedef Teuchos::ScalarTraits<T> ST; 00092 const Array<RCP<T> > a_data = generateArrayRcp<T>(n); 00093 Array<Ptr<T> > a_out; 00094 a_out.reserve(n); 00095 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00096 *a_data[i] = ST::zero(); 00097 a_out.push_back( a_data[i].ptr() ); 00098 } 00099 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00100 TEST_EQUALITY_CONST( Teuchos::is_null(a_out[i]), false ); 00101 } 00102 testArrayViewOutput<T>(a_out); 00103 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00104 TEST_EQUALITY_CONST( *a_out[i], as<T>(i) ); 00105 } 00106 00107 } 00108 00109 00110 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrConst, T ) 00111 { 00112 const Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00113 const Array<Ptr<const T> > a_out = arrayPtrConv<const T>(a_in); 00114 TEST_EQUALITY( a_out.size(), a_in.size() ); 00115 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00116 TEST_EQUALITY( a_out[i].get(), a_in[i].get() ); 00117 TEST_EQUALITY( *a_out[i], *a_in[i] ); 00118 } 00119 } 00120 00121 00122 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrNonconst, T ) 00123 { 00124 const Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00125 const Array<Ptr<T> > a_out = arrayPtrConv<T>(a_in); 00126 TEST_EQUALITY( a_out.size(), a_in.size() ); 00127 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00128 TEST_EQUALITY( a_out[i].get(), a_in[i].get() ); 00129 TEST_EQUALITY( *a_out[i], *a_in[i] ); 00130 } 00131 } 00132 00133 00134 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrNonconst, T ) 00135 { 00136 const Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00137 const Array<Ptr<T> > a1_out = arrayPtrConv<T>(a_in); 00138 const Array<Ptr<T> > a2_out = arrayPtrConv<T>(a1_out()); 00139 TEST_COMPARE_ARRAYS( a2_out, a1_out ); 00140 } 00141 00142 00143 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrConst, T ) 00144 { 00145 const Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00146 const Array<Ptr<T> > a1_out = arrayPtrConv<T>(a_in); 00147 const Array<Ptr<const T> > a2_out = arrayPtrConv<const T>(a1_out()); 00148 TEST_COMPARE_ARRAYS( a2_out, a1_out ); 00149 } 00150 00151 00152 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PtrConst_to_PtrConst, T ) 00153 { 00154 const Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00155 const Array<Ptr<const T> > a1_out = arrayPtrConv<const T>(a_in); 00156 const Array<Ptr<const T> > a2_out = arrayPtrConv<const T>(a1_out()); 00157 TEST_COMPARE_ARRAYS( a2_out, a1_out ); 00158 } 00159 00160 00161 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PassConst, T ) 00162 { 00163 Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00164 T a = testArrayViewInput<T>(arrayPtrConv<const T>(a_in)); 00165 T a_exact = as<T>(n*(n-1)/2); 00166 TEST_EQUALITY( a, a_exact ); 00167 } 00168 00169 00170 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PassNonconst, T ) 00171 { 00172 typedef Teuchos::ScalarTraits<T> ST; 00173 Array<RCP<T> > a_out = generateArrayRcp<T>(n); 00174 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00175 *a_out[i] = ST::zero(); 00176 } 00177 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00178 TEST_EQUALITY_CONST( *a_out[i], ST::zero() ); 00179 } 00180 testArrayViewOutput<T>(arrayPtrConv<T>(a_out)); 00181 TEST_EQUALITY_CONST( as<Teuchos_Ordinal>(a_out.size()), n ); 00182 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00183 TEST_EQUALITY_CONST( *a_out[i], as<T>(i) ); 00184 } 00185 } 00186 00187 00188 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpNonconst, T ) 00189 { 00190 const Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00191 const Array<RCP<T> > a1_out = arrayRcpConv<T>(a_in); 00192 TEST_COMPARE_ARRAYS( a1_out, a_in ); 00193 } 00194 00195 00196 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpConst, T ) 00197 { 00198 const Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00199 const Array<RCP<const T> > a1_out = arrayRcpConv<const T>(a_in); 00200 TEST_COMPARE_ARRAYS( a1_out, a_in ); 00201 } 00202 00203 00204 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayRcpConv_RcpConst_to_RcpConst, T ) 00205 { 00206 const Array<RCP<T> > a_in = generateArrayRcp<T>(n); 00207 const Array<RCP<const T> > a1_out = arrayRcpConv<const T>(a_in); 00208 const Array<RCP<const T> > a2_out = arrayRcpConv<const T>(a1_out); 00209 TEST_COMPARE_ARRAYS( a2_out, a1_out ); 00210 } 00211 00212 00213 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstPtrConstCast_nonconst_to_const, 00214 T ) 00215 { 00216 Array<RCP<T> > a_rcp = generateArrayRcp<T>(n); 00217 Array<Ptr<T> > a_ptr = arrayPtrConv<T>(a_rcp); 00218 const ArrayView<const Ptr<T> > av_ptr_nonconst = a_ptr(); 00219 const ArrayView<const Ptr<const T> > av_ptr_const = 00220 Teuchos::arrayConstPtrConstCast(av_ptr_nonconst); 00221 TEST_COMPARE_ARRAYS( av_ptr_nonconst, av_ptr_const ); 00222 } 00223 00224 00225 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstPtrConstCast_const_to_const, 00226 T ) 00227 { 00228 Array<RCP<T> > a_rcp = generateArrayRcp<T>(n); 00229 Array<Ptr<const T> > a_ptr = arrayPtrConv<const T>(a_rcp); 00230 const ArrayView<const Ptr<const T> > av_ptr_const1 = a_ptr(); 00231 const ArrayView<const Ptr<const T> > av_ptr_const2 = 00232 Teuchos::arrayConstPtrConstCast(av_ptr_const1); 00233 TEST_COMPARE_ARRAYS( av_ptr_const1, av_ptr_const2 ); 00234 } 00235 00236 00237 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstRcpConstCast_nonconst_to_const, 00238 T ) 00239 { 00240 Array<RCP<T> > a_rcp = generateArrayRcp<T>(n); 00241 const ArrayView<const RCP<T> > av_rcp_nonconst = a_rcp(); 00242 const ArrayView<const RCP<const T> > av_rcp_const = 00243 Teuchos::arrayConstRcpConstCast(av_rcp_nonconst); 00244 TEST_COMPARE_ARRAYS( av_rcp_nonconst, av_rcp_const ); 00245 } 00246 00247 00248 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstRcpConstCast_const_to_const, 00249 T ) 00250 { 00251 Array<RCP<T> > a_rcp_orig = generateArrayRcp<T>(n); 00252 Array<RCP<const T> > a_rcp = arrayRcpConv<const T>(a_rcp_orig); 00253 const ArrayView<const RCP<const T> > av_rcp_const1 = a_rcp(); 00254 const ArrayView<const RCP<const T> > av_rcp_const2 = 00255 Teuchos::arrayConstRcpConstCast(av_rcp_const1); 00256 TEST_COMPARE_ARRAYS( av_rcp_const1, av_rcp_const2 ); 00257 } 00258 00259 00260 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 00261 00262 # define DEBUG_UNIT_TEST_GROUP( T ) 00263 00264 #else // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 00265 00266 # define DEBUG_UNIT_TEST_GROUP( T ) 00267 00268 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK 00269 00270 #define UNIT_TEST_GROUP( T ) \ 00271 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, generateArrayRcp, T ) \ 00272 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, testArrayViewInput, T ) \ 00273 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, testArrayViewOutput, T ) \ 00274 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrConst, T ) \ 00275 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrNonconst, T ) \ 00276 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrNonconst, T ) \ 00277 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrConst, T ) \ 00278 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrConst_to_PtrConst, T ) \ 00279 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpConst_to_RcpConst, T ) \ 00280 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PassConst, T ) \ 00281 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PassNonconst, T ) \ 00282 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpNonconst, T ) \ 00283 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpConst, T ) \ 00284 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstPtrConstCast_nonconst_to_const, T ) \ 00285 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstPtrConstCast_const_to_const, T ) \ 00286 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstRcpConstCast_nonconst_to_const, T ) \ 00287 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstRcpConstCast_const_to_const, T ) \ 00288 DEBUG_UNIT_TEST_GROUP( T ) 00289 00290 00291 UNIT_TEST_GROUP(Teuchos_Ordinal) 00292 UNIT_TEST_GROUP(float) 00293 UNIT_TEST_GROUP(double) 00294 00295 00296 00297 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrNonconstBase) 00298 { 00299 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00300 const Array<Ptr<A> > a_out = arrayPtrConv<A>(a_in); 00301 TEST_EQUALITY( a_out.size(), a_in.size() ); 00302 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00303 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) ); 00304 } 00305 } 00306 00307 00308 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrConstBase) 00309 { 00310 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00311 const Array<Ptr<const A> > a_out = arrayPtrConv<const A>(a_in); 00312 TEST_EQUALITY( a_out.size(), a_in.size() ); 00313 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00314 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) ); 00315 } 00316 } 00317 00318 00319 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpConstDerived_to_PtrConstBase) 00320 { 00321 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00322 const Array<RCP<const C> > a1_out = arrayRcpConv<const C>(a_in); 00323 const Array<Ptr<const A> > a2_out = arrayPtrConv<const A>(a1_out); 00324 TEST_EQUALITY( a2_out.size(), a_in.size() ); 00325 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00326 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) ); 00327 } 00328 } 00329 00330 00331 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpNonconstBase) 00332 { 00333 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00334 const Array<RCP<A> > a_out = arrayRcpConv<A>(a_in); 00335 TEST_EQUALITY( a_out.size(), a_in.size() ); 00336 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00337 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) ); 00338 } 00339 } 00340 00341 00342 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpConstBase) 00343 { 00344 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00345 const Array<RCP<const A> > a_out = arrayRcpConv<const A>(a_in); 00346 TEST_EQUALITY( a_out.size(), a_in.size() ); 00347 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00348 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) ); 00349 } 00350 } 00351 00352 00353 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpConstDerived_to_RcpConstBase) 00354 { 00355 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00356 const Array<RCP<const C> > a1_out = arrayRcpConv<const C>(a_in); 00357 const Array<RCP<const A> > a2_out = arrayRcpConv<const A>(a1_out); 00358 TEST_EQUALITY( a2_out.size(), a_in.size() ); 00359 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00360 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<A>(&*a_in[i]) ); 00361 } 00362 } 00363 00364 00365 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrNonconstBase) 00366 { 00367 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00368 Array<Ptr<A> > a_out(n); 00369 arrayViewPtrConv(a_in, a_out()); 00370 TEST_EQUALITY( a_out.size(), a_in.size() ); 00371 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00372 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) ); 00373 } 00374 } 00375 00376 00377 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrConstBase) 00378 { 00379 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00380 Array<Ptr<const A> > a_out(n); 00381 arrayViewPtrConv(a_in, a_out()); 00382 TEST_EQUALITY( a_out.size(), a_in.size() ); 00383 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00384 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) ); 00385 } 00386 } 00387 00388 00389 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpConstDerived_to_PtrConstBase) 00390 { 00391 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00392 Array<RCP<const C> > a1_out(n); 00393 arrayViewRcpConv(a_in, a1_out()); 00394 Array<Ptr<const A> > a2_out(n); 00395 arrayViewPtrConv(a1_out, a2_out()); 00396 TEST_EQUALITY( a2_out.size(), a_in.size() ); 00397 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00398 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) ); 00399 } 00400 } 00401 00402 00403 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpNonconstBase) 00404 { 00405 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00406 Array<RCP<A> > a_out(n); 00407 arrayViewRcpConv(a_in, a_out()); 00408 TEST_EQUALITY( a_out.size(), a_in.size() ); 00409 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00410 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) ); 00411 } 00412 } 00413 00414 00415 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpConstBase) 00416 { 00417 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00418 Array<RCP<const A> > a_out(n); 00419 arrayViewRcpConv(a_in, a_out()); 00420 TEST_EQUALITY( a_out.size(), a_in.size() ); 00421 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00422 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) ); 00423 } 00424 } 00425 00426 00427 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpConstDerived_to_RcpConstBase) 00428 { 00429 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n); 00430 Array<RCP<const C> > a1_out(n); 00431 arrayViewRcpConv(a_in, a1_out()); 00432 Array<RCP<const A> > a2_out(n); 00433 arrayViewRcpConv(a1_out, a2_out()); 00434 TEST_EQUALITY( a2_out.size(), a_in.size() ); 00435 for (Teuchos_Ordinal i=0 ; i<n ; ++i) { 00436 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<A>(&*a_in[i]) ); 00437 } 00438 } 00439 00440 00441 } // namespace
1.7.4