75 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
88 const Array<RCP<T> > a_data = generateArrayRcp<T>(
n);
89 Array<Ptr<const T> > a_in(n);
91 a_in[i] = a_data[i].ptr();
96 T a_out = testArrayViewInput<T>(a_in);
105 const Array<RCP<T> > a_data = generateArrayRcp<T>(
n);
106 Array<Ptr<T> > a_out;
109 *a_data[i] = ST::zero();
110 a_out.push_back( a_data[i].
ptr() );
115 testArrayViewOutput<T>(a_out);
125 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
126 const Array<Ptr<const T> > a_out = arrayPtrConv<const T>(a_in);
137 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
138 const Array<Ptr<T> > a_out = arrayPtrConv<T>(a_in);
149 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
150 const Array<Ptr<T> > a1_out = arrayPtrConv<T>(a_in);
151 const Array<Ptr<T> > a2_out = arrayPtrConv<T>(a1_out());
158 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
159 const Array<Ptr<T> > a1_out = arrayPtrConv<T>(a_in);
160 const Array<Ptr<const T> > a2_out = arrayPtrConv<const T>(a1_out());
167 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
168 const Array<Ptr<const T> > a1_out = arrayPtrConv<const T>(a_in);
169 const Array<Ptr<const T> > a2_out = arrayPtrConv<const T>(a1_out());
176 Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
177 T a = testArrayViewInput<T>(arrayPtrConv<const T>(a_in));
178 T a_exact = as<T>(n*(n-1)/2);
186 Array<RCP<T> > a_out = generateArrayRcp<T>(
n);
188 *a_out[i] = ST::zero();
193 testArrayViewOutput<T>(arrayPtrConv<T>(a_out));
203 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
204 const Array<RCP<T> > a1_out = arrayRcpConv<T>(a_in);
211 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
212 const Array<RCP<const T> > a1_out = arrayRcpConv<const T>(a_in);
219 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
220 const Array<RCP<const T> > a1_out = arrayRcpConv<const T>(a_in);
221 const Array<RCP<const T> > a2_out = arrayRcpConv<const T>(a1_out);
229 Array<RCP<T> > a_rcp = generateArrayRcp<T>(
n);
230 Array<Ptr<T> > a_ptr = arrayPtrConv<T>(a_rcp);
231 const ArrayView<const Ptr<T> > av_ptr_nonconst = a_ptr();
232 const ArrayView<const Ptr<const T> > av_ptr_const =
241 Array<RCP<T> > a_rcp = generateArrayRcp<T>(
n);
242 Array<Ptr<const T> > a_ptr = arrayPtrConv<const T>(a_rcp);
243 const ArrayView<const Ptr<const T> > av_ptr_const1 = a_ptr();
244 const ArrayView<const Ptr<const T> > av_ptr_const2 =
253 Array<RCP<T> > a_rcp = generateArrayRcp<T>(
n);
254 const ArrayView<const RCP<T> > av_rcp_nonconst = a_rcp();
255 const ArrayView<const RCP<const T> > av_rcp_const =
264 Array<RCP<T> > a_rcp_orig = generateArrayRcp<T>(
n);
265 Array<RCP<const T> > a_rcp = arrayRcpConv<const T>(a_rcp_orig);
266 const ArrayView<const RCP<const T> > av_rcp_const1 = a_rcp();
267 const ArrayView<const RCP<const T> > av_rcp_const2 =
273 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
275 # define DEBUG_UNIT_TEST_GROUP( T )
277 #else // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
279 # define DEBUG_UNIT_TEST_GROUP( T )
281 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
283 #define UNIT_TEST_GROUP( T ) \
284 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, generateArrayRcp, T ) \
285 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, testArrayViewInput, T ) \
286 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, testArrayViewOutput, T ) \
287 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrConst, T ) \
288 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrNonconst, T ) \
289 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrNonconst, T ) \
290 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrConst, T ) \
291 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrConst_to_PtrConst, T ) \
292 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpConst_to_RcpConst, T ) \
293 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PassConst, T ) \
294 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PassNonconst, T ) \
295 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpNonconst, T ) \
296 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpConst, T ) \
297 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstPtrConstCast_nonconst_to_const, T ) \
298 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstPtrConstCast_const_to_const, T ) \
299 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstRcpConstCast_nonconst_to_const, T ) \
300 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstRcpConstCast_const_to_const, T ) \
301 DEBUG_UNIT_TEST_GROUP( T )
310 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrNonconstBase)
312 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
313 const Array<Ptr<A> > a_out = arrayPtrConv<A>(a_in);
316 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
321 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrConstBase)
323 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
324 const Array<Ptr<const A> > a_out = arrayPtrConv<const A>(a_in);
327 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
332 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpConstDerived_to_PtrConstBase)
334 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
335 const Array<RCP<const C> > a1_out = arrayRcpConv<const C>(a_in);
336 const Array<Ptr<const A> > a2_out = arrayPtrConv<const A>(a1_out);
339 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
344 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpNonconstBase)
346 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
347 const Array<RCP<A> > a_out = arrayRcpConv<A>(a_in);
350 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
355 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpConstBase)
357 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
358 const Array<RCP<const A> > a_out = arrayRcpConv<const A>(a_in);
361 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
366 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpConstDerived_to_RcpConstBase)
368 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
369 const Array<RCP<const C> > a1_out = arrayRcpConv<const C>(a_in);
370 const Array<RCP<const A> > a2_out = arrayRcpConv<const A>(a1_out);
373 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
378 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrNonconstBase)
380 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
381 Array<Ptr<A> > a_out(n);
385 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
390 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrConstBase)
392 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
393 Array<Ptr<const A> > a_out(n);
397 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
402 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpConstDerived_to_PtrConstBase)
404 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
405 Array<RCP<const C> > a1_out(n);
407 Array<Ptr<const A> > a2_out(n);
411 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
416 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpNonconstBase)
418 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
419 Array<RCP<A> > a_out(n);
423 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
428 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpConstBase)
430 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
431 Array<RCP<const A> > a_out(n);
435 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
440 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpConstDerived_to_RcpConstBase)
442 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
443 Array<RCP<const C> > a1_out(n);
445 Array<RCP<const A> > a2_out(n);
449 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
T testArrayViewInput(const ArrayView< const Ptr< const T > > &a_in)
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
Array< RCP< T_out > > arrayRcpConv(const ArrayPtrT_in &a_in)
Utility function to convert any Array[View,RCP]<[const] RCP<T_in> > object to an Array<RCP<T_out> > o...
#define TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(TEST_GROUP, TEST_NAME, TYPE)
Macro for defining a templated unit test with one template parameter.
#define TEST_EQUALITY(v1, v2)
Assert the equality of v1 and v2.
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
void arrayViewPtrConv(const ArrayPtrT_in &a_in, const ArrayView< Ptr< T_out > > &a_out)
Utility function to convert from an an input Array[View,RCP]<[const] PTR<T_in> > object to an output ...
This structure defines some basic traits for a scalar field type.
TEUCHOS_ORDINAL_TYPE Teuchos_Ordinal
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
void arrayViewRcpConv(const ArrayPtrT_in &a_in, const ArrayView< RCP< T_out > > &a_out)
Utility function to convert from an input Array[View,RCP]<[const] RCP<T_in> > object to an output Arr...
ArrayView< const RCP< const T > > arrayConstRcpConstCast(const ArrayView< const RCP< T > > &a_in)
Utility function that does a reinterpret case to convert an ArrayView<const RCP<T> > object to an Arr...
TypeTo * implicit_ptr_cast(TypeFrom *t)
Perform an implicit cast of pointer types with a pointer being returned.
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
Ptr< T > ptr(T *p)
Create a pointer to an object from a raw pointer.
Templated conversions between Array<RCP<T> > and ArrayView<Ptr<T> >
void testArrayViewOutput(const ArrayView< const Ptr< T > > &a_out)
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
Array< Ptr< T_out > > arrayPtrConv(const ArrayPtrT_in &a_in)
Utility function to convert an Array[View,RCP]<[const] PTR<T_in> > object to an Array<Ptr<T_out> > ob...
Array< RCP< T > > generateArrayRcp(const Teuchos_Ordinal n_in)
Smart reference counting pointer class for automatic garbage collection.
ArrayView< const Ptr< const T > > arrayConstPtrConstCast(const ArrayView< const Ptr< T > > &a_in)
Utility function that does a reinterpret case to convert an ArrayView<const Ptr<T> > object to an Arr...
#define UNIT_TEST_GROUP(T)
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
Array< RCP< T > > generateArrayRcpGen(const Teuchos_Ordinal n_in)
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...