41 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
54 const Array<RCP<T> > a_data = generateArrayRcp<T>(
n);
55 Array<Ptr<const T> > a_in(n);
57 a_in[i] = a_data[i].ptr();
62 T a_out = testArrayViewInput<T>(a_in);
71 const Array<RCP<T> > a_data = generateArrayRcp<T>(
n);
75 *a_data[i] = ST::zero();
76 a_out.push_back( a_data[i].
ptr() );
81 testArrayViewOutput<T>(a_out);
91 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
92 const Array<Ptr<const T> > a_out = arrayPtrConv<const T>(a_in);
103 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
104 const Array<Ptr<T> > a_out = arrayPtrConv<T>(a_in);
115 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
116 const Array<Ptr<T> > a1_out = arrayPtrConv<T>(a_in);
117 const Array<Ptr<T> > a2_out = arrayPtrConv<T>(a1_out());
124 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
125 const Array<Ptr<T> > a1_out = arrayPtrConv<T>(a_in);
126 const Array<Ptr<const T> > a2_out = arrayPtrConv<const T>(a1_out());
133 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
134 const Array<Ptr<const T> > a1_out = arrayPtrConv<const T>(a_in);
135 const Array<Ptr<const T> > a2_out = arrayPtrConv<const T>(a1_out());
142 Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
143 T a = testArrayViewInput<T>(arrayPtrConv<const T>(a_in));
144 T a_exact = as<T>(n*(n-1)/2);
152 Array<RCP<T> > a_out = generateArrayRcp<T>(
n);
154 *a_out[i] = ST::zero();
159 testArrayViewOutput<T>(arrayPtrConv<T>(a_out));
169 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
170 const Array<RCP<T> > a1_out = arrayRcpConv<T>(a_in);
177 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
178 const Array<RCP<const T> > a1_out = arrayRcpConv<const T>(a_in);
185 const Array<RCP<T> > a_in = generateArrayRcp<T>(
n);
186 const Array<RCP<const T> > a1_out = arrayRcpConv<const T>(a_in);
187 const Array<RCP<const T> > a2_out = arrayRcpConv<const T>(a1_out);
195 Array<RCP<T> > a_rcp = generateArrayRcp<T>(
n);
196 Array<Ptr<T> > a_ptr = arrayPtrConv<T>(a_rcp);
197 const ArrayView<const Ptr<T> > av_ptr_nonconst = a_ptr();
198 const ArrayView<const Ptr<const T> > av_ptr_const =
207 Array<RCP<T> > a_rcp = generateArrayRcp<T>(
n);
208 Array<Ptr<const T> > a_ptr = arrayPtrConv<const T>(a_rcp);
209 const ArrayView<const Ptr<const T> > av_ptr_const1 = a_ptr();
210 const ArrayView<const Ptr<const T> > av_ptr_const2 =
219 Array<RCP<T> > a_rcp = generateArrayRcp<T>(
n);
220 const ArrayView<const RCP<T> > av_rcp_nonconst = a_rcp();
221 const ArrayView<const RCP<const T> > av_rcp_const =
230 Array<RCP<T> > a_rcp_orig = generateArrayRcp<T>(
n);
231 Array<RCP<const T> > a_rcp = arrayRcpConv<const T>(a_rcp_orig);
232 const ArrayView<const RCP<const T> > av_rcp_const1 = a_rcp();
233 const ArrayView<const RCP<const T> > av_rcp_const2 =
239 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
241 # define DEBUG_UNIT_TEST_GROUP( T )
243 #else // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
245 # define DEBUG_UNIT_TEST_GROUP( T )
247 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
249 #define UNIT_TEST_GROUP( T ) \
250 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, generateArrayRcp, T ) \
251 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, testArrayViewInput, T ) \
252 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, testArrayViewOutput, T ) \
253 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrConst, T ) \
254 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrNonconst, T ) \
255 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrNonconst, T ) \
256 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrConst, T ) \
257 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PtrConst_to_PtrConst, T ) \
258 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpConst_to_RcpConst, T ) \
259 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PassConst, T ) \
260 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayPtrConv_PassNonconst, T ) \
261 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpNonconst, T ) \
262 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpConst, T ) \
263 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstPtrConstCast_nonconst_to_const, T ) \
264 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstPtrConstCast_const_to_const, T ) \
265 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstRcpConstCast_nonconst_to_const, T ) \
266 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( ArrayConversions, arrayConstRcpConstCast_const_to_const, T ) \
267 DEBUG_UNIT_TEST_GROUP( T )
276 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrNonconstBase)
278 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
279 const Array<Ptr<A> > a_out = arrayPtrConv<A>(a_in);
282 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
287 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrConstBase)
289 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
290 const Array<Ptr<const A> > a_out = arrayPtrConv<const A>(a_in);
293 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
298 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpConstDerived_to_PtrConstBase)
300 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
301 const Array<RCP<const C> > a1_out = arrayRcpConv<const C>(a_in);
302 const Array<Ptr<const A> > a2_out = arrayPtrConv<const A>(a1_out);
305 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
310 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpNonconstBase)
312 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
313 const Array<RCP<A> > a_out = arrayRcpConv<A>(a_in);
316 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
321 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpConstBase)
323 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
324 const Array<RCP<const A> > a_out = arrayRcpConv<const A>(a_in);
327 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
332 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpConstDerived_to_RcpConstBase)
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<RCP<const A> > a2_out = arrayRcpConv<const A>(a1_out);
339 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
344 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrNonconstBase)
346 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
347 Array<Ptr<A> > a_out(n);
351 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
356 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrConstBase)
358 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
359 Array<Ptr<const A> > a_out(n);
363 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
368 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpConstDerived_to_PtrConstBase)
370 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
371 Array<RCP<const C> > a1_out(n);
373 Array<Ptr<const A> > a2_out(n);
377 TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
382 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpNonconstBase)
384 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
385 Array<RCP<A> > a_out(n);
389 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
394 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpConstBase)
396 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
397 Array<RCP<const A> > a_out(n);
401 TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
406 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpConstDerived_to_RcpConstBase)
408 const Array<RCP<C> > a_in = generateArrayRcpGen<C>(
n);
409 Array<RCP<const C> > a1_out(n);
411 Array<RCP<const A> > a2_out(n);
415 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...