Teuchos Package Browser (Single Doxygen Collection) Version of the Day
ArrayConversions_UnitTests.cpp
Go to the documentation of this file.
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 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00039 //
00040 // ***********************************************************************
00041 // @HEADER
00042 */
00043 
00044 
00045 #include "Teuchos_ArrayConversions.hpp"
00046 #include "Teuchos_implicit_cast.hpp"
00047 #include "Array_UnitTest_helpers.hpp"
00048 #include "ArrayConversions_UnitTest_helpers.hpp"
00049 #include "TestClasses.hpp"
00050 
00051 namespace {
00052 
00053 
00054 using ArrayUnitTestHelpers::n;
00055 using ArrayConversionsUnitTestHelpers::generateArrayRcp;
00056 using ArrayConversionsUnitTestHelpers::generateArrayRcpGen;
00057 using ArrayConversionsUnitTestHelpers::testArrayViewInput;
00058 using ArrayConversionsUnitTestHelpers::testArrayViewOutput;
00059 using Teuchos::arrayPtrConv;
00060 using Teuchos::arrayRcpConv;
00061 using Teuchos::arrayViewPtrConv;
00062 using Teuchos::arrayViewRcpConv;
00063 using Teuchos::Array;
00064 using Teuchos::ArrayView;
00065 using Teuchos::Ptr;
00066 using Teuchos::RCP;
00067 using Teuchos::rcp;
00068 using Teuchos::as;
00069 using Teuchos::implicit_ptr_cast;
00070 
00071 
00072 // Verify generateArrayRcp works correctly
00073 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, generateArrayRcp, T )
00074 {
00075   const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00076   TEST_EQUALITY_CONST( as<Teuchos_Ordinal>(a_in.size()), n );
00077   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00078     TEST_EQUALITY_CONST( Teuchos::is_null(a_in[i]), false );
00079     TEST_EQUALITY_CONST( *a_in[i], as<T>(i) );
00080   }
00081 }
00082 
00083 
00084 // Verify testArrayViewInput works correctly
00085 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, testArrayViewInput, T )
00086 {
00087   //typedef Teuchos::ScalarTraits<T> ST; // unused
00088   const Array<RCP<T> > a_data = generateArrayRcp<T>(n);
00089   Array<Ptr<const T> > a_in(n);
00090   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00091     a_in[i] = a_data[i].ptr();
00092   }
00093   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00094     TEST_EQUALITY_CONST( Teuchos::is_null(a_in[i]), false );
00095   }
00096   T a_out = testArrayViewInput<T>(a_in);
00097   TEST_EQUALITY_CONST( a_out, as<T>(n*(n-1)/2) );
00098 }
00099 
00100 
00101 // Verify testArrayViewOutput works correctly
00102 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, testArrayViewOutput, T )
00103 {
00104   typedef Teuchos::ScalarTraits<T> ST;
00105   const Array<RCP<T> > a_data = generateArrayRcp<T>(n);
00106   Array<Ptr<T> > a_out;
00107   a_out.reserve(n);
00108   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00109     *a_data[i] = ST::zero();
00110     a_out.push_back( a_data[i].ptr() );
00111   }
00112   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00113     TEST_EQUALITY_CONST( Teuchos::is_null(a_out[i]), false );
00114   }
00115   testArrayViewOutput<T>(a_out);
00116   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00117     TEST_EQUALITY_CONST( *a_out[i], as<T>(i) );
00118   }
00119 
00120 }
00121 
00122 
00123 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrConst, T )
00124 {
00125   const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00126   const Array<Ptr<const T> > a_out = arrayPtrConv<const T>(a_in);
00127   TEST_EQUALITY( a_out.size(), a_in.size() );
00128   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00129     TEST_EQUALITY( a_out[i].get(), a_in[i].get() );
00130     TEST_EQUALITY( *a_out[i], *a_in[i] );
00131   }
00132 }
00133 
00134 
00135 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrNonconst, T )
00136 {
00137   const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00138   const Array<Ptr<T> > a_out = arrayPtrConv<T>(a_in);
00139   TEST_EQUALITY( a_out.size(), a_in.size() );
00140   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00141     TEST_EQUALITY( a_out[i].get(), a_in[i].get() );
00142     TEST_EQUALITY( *a_out[i], *a_in[i] );
00143   }
00144 }
00145 
00146 
00147 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrNonconst, T )
00148 {
00149   const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00150   const Array<Ptr<T> > a1_out = arrayPtrConv<T>(a_in);
00151   const Array<Ptr<T> > a2_out = arrayPtrConv<T>(a1_out());
00152   TEST_COMPARE_ARRAYS( a2_out, a1_out );
00153 }
00154 
00155 
00156 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrConst, T )
00157 {
00158   const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00159   const Array<Ptr<T> > a1_out = arrayPtrConv<T>(a_in);
00160   const Array<Ptr<const T> > a2_out = arrayPtrConv<const T>(a1_out());
00161   TEST_COMPARE_ARRAYS( a2_out, a1_out );
00162 }
00163 
00164 
00165 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PtrConst_to_PtrConst, T )
00166 {
00167   const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00168   const Array<Ptr<const T> > a1_out = arrayPtrConv<const T>(a_in);
00169   const Array<Ptr<const T> > a2_out = arrayPtrConv<const T>(a1_out());
00170   TEST_COMPARE_ARRAYS( a2_out, a1_out );
00171 }
00172 
00173 
00174 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PassConst, T )
00175 {
00176   Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00177   T a = testArrayViewInput<T>(arrayPtrConv<const T>(a_in));
00178   T a_exact = as<T>(n*(n-1)/2);
00179   TEST_EQUALITY( a, a_exact );
00180 }
00181 
00182 
00183 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PassNonconst, T )
00184 {
00185   typedef Teuchos::ScalarTraits<T> ST;
00186   Array<RCP<T> > a_out = generateArrayRcp<T>(n);
00187   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00188     *a_out[i] = ST::zero();
00189   }
00190   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00191     TEST_EQUALITY_CONST( *a_out[i], ST::zero() );
00192   }
00193   testArrayViewOutput<T>(arrayPtrConv<T>(a_out));
00194   TEST_EQUALITY_CONST( as<Teuchos_Ordinal>(a_out.size()), n );
00195   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00196     TEST_EQUALITY_CONST( *a_out[i], as<T>(i) );
00197   }
00198 }
00199 
00200 
00201 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpNonconst, T )
00202 {
00203   const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00204   const Array<RCP<T> > a1_out = arrayRcpConv<T>(a_in);
00205   TEST_COMPARE_ARRAYS( a1_out, a_in );
00206 }
00207 
00208 
00209 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpConst, T )
00210 {
00211   const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00212   const Array<RCP<const T> > a1_out = arrayRcpConv<const T>(a_in);
00213   TEST_COMPARE_ARRAYS( a1_out, a_in );
00214 }
00215 
00216 
00217 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayRcpConv_RcpConst_to_RcpConst, T )
00218 {
00219   const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
00220   const Array<RCP<const T> > a1_out = arrayRcpConv<const T>(a_in);
00221   const Array<RCP<const T> > a2_out = arrayRcpConv<const T>(a1_out);
00222   TEST_COMPARE_ARRAYS( a2_out, a1_out );
00223 }
00224 
00225 
00226 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstPtrConstCast_nonconst_to_const,
00227   T )
00228 {
00229   Array<RCP<T> > a_rcp = generateArrayRcp<T>(n);
00230   Array<Ptr<T> > a_ptr = arrayPtrConv<T>(a_rcp);
00231   const ArrayView<const Ptr<T> > av_ptr_nonconst = a_ptr();
00232   const ArrayView<const Ptr<const T> > av_ptr_const =
00233     Teuchos::arrayConstPtrConstCast(av_ptr_nonconst);
00234   TEST_COMPARE_ARRAYS( av_ptr_nonconst, av_ptr_const );
00235 }
00236 
00237 
00238 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstPtrConstCast_const_to_const,
00239   T )
00240 {
00241   Array<RCP<T> > a_rcp = generateArrayRcp<T>(n);
00242   Array<Ptr<const T> > a_ptr = arrayPtrConv<const T>(a_rcp);
00243   const ArrayView<const Ptr<const T> > av_ptr_const1 = a_ptr();
00244   const ArrayView<const Ptr<const T> > av_ptr_const2 =
00245     Teuchos::arrayConstPtrConstCast(av_ptr_const1);
00246   TEST_COMPARE_ARRAYS( av_ptr_const1, av_ptr_const2 );
00247 }
00248 
00249 
00250 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstRcpConstCast_nonconst_to_const,
00251   T )
00252 {
00253   Array<RCP<T> > a_rcp = generateArrayRcp<T>(n);
00254   const ArrayView<const RCP<T> > av_rcp_nonconst = a_rcp();
00255   const ArrayView<const RCP<const T> > av_rcp_const =
00256     Teuchos::arrayConstRcpConstCast(av_rcp_nonconst);
00257   TEST_COMPARE_ARRAYS( av_rcp_nonconst, av_rcp_const );
00258 }
00259 
00260 
00261 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstRcpConstCast_const_to_const,
00262   T )
00263 {
00264   Array<RCP<T> > a_rcp_orig = generateArrayRcp<T>(n);
00265   Array<RCP<const T> > a_rcp = arrayRcpConv<const T>(a_rcp_orig);
00266   const ArrayView<const RCP<const T> > av_rcp_const1 = a_rcp();
00267   const ArrayView<const RCP<const T> > av_rcp_const2 =
00268     Teuchos::arrayConstRcpConstCast(av_rcp_const1);
00269   TEST_COMPARE_ARRAYS( av_rcp_const1, av_rcp_const2 );
00270 }
00271 
00272 
00273 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
00274 
00275 #  define DEBUG_UNIT_TEST_GROUP( T )
00276 
00277 #else // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
00278 
00279 #  define DEBUG_UNIT_TEST_GROUP( T )
00280 
00281 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
00282 
00283 #define UNIT_TEST_GROUP( T ) \
00284   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, generateArrayRcp, T ) \
00285   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, testArrayViewInput, T ) \
00286   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, testArrayViewOutput, T ) \
00287   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrConst, T ) \
00288   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrNonconst, T ) \
00289   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrNonconst, T ) \
00290   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrConst, T ) \
00291   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrConst_to_PtrConst, T ) \
00292   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpConst_to_RcpConst, T ) \
00293   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PassConst, T ) \
00294   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PassNonconst, T ) \
00295   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpNonconst, T ) \
00296   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpConst, T ) \
00297   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstPtrConstCast_nonconst_to_const, T ) \
00298   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstPtrConstCast_const_to_const, T ) \
00299   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstRcpConstCast_nonconst_to_const, T ) \
00300   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstRcpConstCast_const_to_const, T ) \
00301   DEBUG_UNIT_TEST_GROUP( T )
00302 
00303 
00304 UNIT_TEST_GROUP(Teuchos_Ordinal)
00305 UNIT_TEST_GROUP(float)
00306 UNIT_TEST_GROUP(double)
00307 
00308 
00309 
00310 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrNonconstBase)
00311 {
00312   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00313   const Array<Ptr<A> > a_out = arrayPtrConv<A>(a_in);
00314   TEST_EQUALITY( a_out.size(), a_in.size() );
00315   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00316     TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
00317   }
00318 }
00319 
00320 
00321 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrConstBase)
00322 {
00323   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00324   const Array<Ptr<const A> > a_out = arrayPtrConv<const A>(a_in);
00325   TEST_EQUALITY( a_out.size(), a_in.size() );
00326   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00327     TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
00328   }
00329 }
00330 
00331 
00332 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpConstDerived_to_PtrConstBase)
00333 {
00334   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00335   const Array<RCP<const C> > a1_out = arrayRcpConv<const C>(a_in);
00336   const Array<Ptr<const A> > a2_out = arrayPtrConv<const A>(a1_out);
00337   TEST_EQUALITY( a2_out.size(), a_in.size() );
00338   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00339     TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
00340   }
00341 }
00342 
00343 
00344 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpNonconstBase)
00345 {
00346   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00347   const Array<RCP<A> > a_out = arrayRcpConv<A>(a_in);
00348   TEST_EQUALITY( a_out.size(), a_in.size() );
00349   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00350     TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
00351   }
00352 }
00353 
00354 
00355 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpConstBase)
00356 {
00357   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00358   const Array<RCP<const A> > a_out = arrayRcpConv<const A>(a_in);
00359   TEST_EQUALITY( a_out.size(), a_in.size() );
00360   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00361     TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
00362   }
00363 }
00364 
00365 
00366 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpConstDerived_to_RcpConstBase)
00367 {
00368   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00369   const Array<RCP<const C> > a1_out = arrayRcpConv<const C>(a_in);
00370   const Array<RCP<const A> > a2_out = arrayRcpConv<const A>(a1_out);
00371   TEST_EQUALITY( a2_out.size(), a_in.size() );
00372   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00373     TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
00374   }
00375 }
00376 
00377 
00378 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrNonconstBase)
00379 {
00380   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00381   Array<Ptr<A> > a_out(n);
00382   arrayViewPtrConv(a_in, a_out());
00383   TEST_EQUALITY( a_out.size(), a_in.size() );
00384   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00385     TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
00386   }
00387 }
00388 
00389 
00390 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrConstBase)
00391 {
00392   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00393   Array<Ptr<const A> > a_out(n);
00394   arrayViewPtrConv(a_in, a_out());
00395   TEST_EQUALITY( a_out.size(), a_in.size() );
00396   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00397     TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
00398   }
00399 }
00400 
00401 
00402 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpConstDerived_to_PtrConstBase)
00403 {
00404   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00405   Array<RCP<const C> > a1_out(n);
00406   arrayViewRcpConv(a_in, a1_out());
00407   Array<Ptr<const A> > a2_out(n);
00408   arrayViewPtrConv(a1_out, a2_out());
00409   TEST_EQUALITY( a2_out.size(), a_in.size() );
00410   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00411     TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
00412   }
00413 }
00414 
00415 
00416 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpNonconstBase)
00417 {
00418   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00419   Array<RCP<A> > a_out(n);
00420   arrayViewRcpConv(a_in, a_out());
00421   TEST_EQUALITY( a_out.size(), a_in.size() );
00422   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00423     TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
00424   }
00425 }
00426 
00427 
00428 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpConstBase)
00429 {
00430   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00431   Array<RCP<const A> > a_out(n);
00432   arrayViewRcpConv(a_in, a_out());
00433   TEST_EQUALITY( a_out.size(), a_in.size() );
00434   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00435     TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
00436   }
00437 }
00438 
00439 
00440 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpConstDerived_to_RcpConstBase)
00441 {
00442   const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
00443   Array<RCP<const C> > a1_out(n);
00444   arrayViewRcpConv(a_in, a1_out());
00445   Array<RCP<const A> > a2_out(n);
00446   arrayViewRcpConv(a1_out, a2_out());
00447   TEST_EQUALITY( a2_out.size(), a_in.size() );
00448   for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
00449     TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
00450   }
00451 }
00452 
00453 
00454 } // namespace
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines