Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArrayConversions_UnitTests.cpp
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Teuchos: Common Tools Package
6 // Copyright (2004) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
44 
49 #include "TestClasses.hpp"
50 
51 namespace {
52 
53 
63 using Teuchos::Array;
64 using Teuchos::ArrayView;
65 using Teuchos::Ptr;
66 using Teuchos::RCP;
67 using Teuchos::rcp;
68 using Teuchos::as;
70 
71 
72 // Verify generateArrayRcp works correctly
74 {
75  const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
76  TEST_EQUALITY_CONST( as<Teuchos_Ordinal>(a_in.size()), n );
77  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
78  TEST_EQUALITY_CONST( Teuchos::is_null(a_in[i]), false );
79  TEST_EQUALITY_CONST( *a_in[i], as<T>(i) );
80  }
81 }
82 
83 
84 // Verify testArrayViewInput works correctly
86 {
87  //typedef Teuchos::ScalarTraits<T> ST; // unused
88  const Array<RCP<T> > a_data = generateArrayRcp<T>(n);
89  Array<Ptr<const T> > a_in(n);
90  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
91  a_in[i] = a_data[i].ptr();
92  }
93  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
94  TEST_EQUALITY_CONST( Teuchos::is_null(a_in[i]), false );
95  }
96  T a_out = testArrayViewInput<T>(a_in);
97  TEST_EQUALITY_CONST( a_out, as<T>(n*(n-1)/2) );
98 }
99 
100 
101 // Verify testArrayViewOutput works correctly
103 {
104  typedef Teuchos::ScalarTraits<T> ST;
105  const Array<RCP<T> > a_data = generateArrayRcp<T>(n);
106  Array<Ptr<T> > a_out;
107  a_out.reserve(n);
108  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
109  *a_data[i] = ST::zero();
110  a_out.push_back( a_data[i].ptr() );
111  }
112  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
113  TEST_EQUALITY_CONST( Teuchos::is_null(a_out[i]), false );
114  }
115  testArrayViewOutput<T>(a_out);
116  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
117  TEST_EQUALITY_CONST( *a_out[i], as<T>(i) );
118  }
119 
120 }
121 
122 
123 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrConst, T )
124 {
125  const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
126  const Array<Ptr<const T> > a_out = arrayPtrConv<const T>(a_in);
127  TEST_EQUALITY( a_out.size(), a_in.size() );
128  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
129  TEST_EQUALITY( a_out[i].get(), a_in[i].get() );
130  TEST_EQUALITY( *a_out[i], *a_in[i] );
131  }
132 }
133 
134 
135 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_RcpNonconst_to_PtrNonconst, T )
136 {
137  const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
138  const Array<Ptr<T> > a_out = arrayPtrConv<T>(a_in);
139  TEST_EQUALITY( a_out.size(), a_in.size() );
140  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
141  TEST_EQUALITY( a_out[i].get(), a_in[i].get() );
142  TEST_EQUALITY( *a_out[i], *a_in[i] );
143  }
144 }
145 
146 
147 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrNonconst, T )
148 {
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());
152  TEST_COMPARE_ARRAYS( a2_out, a1_out );
153 }
154 
155 
156 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PtrNonconst_to_PtrConst, T )
157 {
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());
161  TEST_COMPARE_ARRAYS( a2_out, a1_out );
162 }
163 
164 
165 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PtrConst_to_PtrConst, T )
166 {
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());
170  TEST_COMPARE_ARRAYS( a2_out, a1_out );
171 }
172 
173 
174 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PassConst, T )
175 {
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);
179  TEST_EQUALITY( a, a_exact );
180 }
181 
182 
183 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayPtrConv_PassNonconst, T )
184 {
185  typedef Teuchos::ScalarTraits<T> ST;
186  Array<RCP<T> > a_out = generateArrayRcp<T>(n);
187  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
188  *a_out[i] = ST::zero();
189  }
190  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
191  TEST_EQUALITY_CONST( *a_out[i], ST::zero() );
192  }
193  testArrayViewOutput<T>(arrayPtrConv<T>(a_out));
194  TEST_EQUALITY_CONST( as<Teuchos_Ordinal>(a_out.size()), n );
195  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
196  TEST_EQUALITY_CONST( *a_out[i], as<T>(i) );
197  }
198 }
199 
200 
201 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpNonconst, T )
202 {
203  const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
204  const Array<RCP<T> > a1_out = arrayRcpConv<T>(a_in);
205  TEST_COMPARE_ARRAYS( a1_out, a_in );
206 }
207 
208 
209 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayRcpConv_RcpNonconst_to_RcpConst, T )
210 {
211  const Array<RCP<T> > a_in = generateArrayRcp<T>(n);
212  const Array<RCP<const T> > a1_out = arrayRcpConv<const T>(a_in);
213  TEST_COMPARE_ARRAYS( a1_out, a_in );
214 }
215 
216 
217 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayRcpConv_RcpConst_to_RcpConst, T )
218 {
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);
222  TEST_COMPARE_ARRAYS( a2_out, a1_out );
223 }
224 
225 
226 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstPtrConstCast_nonconst_to_const,
227  T )
228 {
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 =
233  Teuchos::arrayConstPtrConstCast(av_ptr_nonconst);
234  TEST_COMPARE_ARRAYS( av_ptr_nonconst, av_ptr_const );
235 }
236 
237 
238 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstPtrConstCast_const_to_const,
239  T )
240 {
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 =
245  Teuchos::arrayConstPtrConstCast(av_ptr_const1);
246  TEST_COMPARE_ARRAYS( av_ptr_const1, av_ptr_const2 );
247 }
248 
249 
250 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstRcpConstCast_nonconst_to_const,
251  T )
252 {
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 =
256  Teuchos::arrayConstRcpConstCast(av_rcp_nonconst);
257  TEST_COMPARE_ARRAYS( av_rcp_nonconst, av_rcp_const );
258 }
259 
260 
261 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArrayConversions, arrayConstRcpConstCast_const_to_const,
262  T )
263 {
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 =
268  Teuchos::arrayConstRcpConstCast(av_rcp_const1);
269  TEST_COMPARE_ARRAYS( av_rcp_const1, av_rcp_const2 );
270 }
271 
272 
273 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
274 
275 # define DEBUG_UNIT_TEST_GROUP( T )
276 
277 #else // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
278 
279 # define DEBUG_UNIT_TEST_GROUP( T )
280 
281 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
282 
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 )
302 
303 
305 UNIT_TEST_GROUP(float)
306 UNIT_TEST_GROUP(double)
307 
308 
309 
310 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrNonconstBase)
311 {
312  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
313  const Array<Ptr<A> > a_out = arrayPtrConv<A>(a_in);
314  TEST_EQUALITY( a_out.size(), a_in.size() );
315  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
316  TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
317  }
318 }
319 
320 
321 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpNonconstDerived_to_PtrConstBase)
322 {
323  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
324  const Array<Ptr<const A> > a_out = arrayPtrConv<const A>(a_in);
325  TEST_EQUALITY( a_out.size(), a_in.size() );
326  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
327  TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
328  }
329 }
330 
331 
332 TEUCHOS_UNIT_TEST( ArrayConversions, arrayPtrConv_RcpConstDerived_to_PtrConstBase)
333 {
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);
337  TEST_EQUALITY( a2_out.size(), a_in.size() );
338  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
339  TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
340  }
341 }
342 
343 
344 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpNonconstBase)
345 {
346  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
347  const Array<RCP<A> > a_out = arrayRcpConv<A>(a_in);
348  TEST_EQUALITY( a_out.size(), a_in.size() );
349  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
350  TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
351  }
352 }
353 
354 
355 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpNonconstDerived_to_RcpConstBase)
356 {
357  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
358  const Array<RCP<const A> > a_out = arrayRcpConv<const A>(a_in);
359  TEST_EQUALITY( a_out.size(), a_in.size() );
360  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
361  TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
362  }
363 }
364 
365 
366 TEUCHOS_UNIT_TEST( ArrayConversions, arrayRcpConv_RcpConstDerived_to_RcpConstBase)
367 {
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);
371  TEST_EQUALITY( a2_out.size(), a_in.size() );
372  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
373  TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
374  }
375 }
376 
377 
378 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrNonconstBase)
379 {
380  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
381  Array<Ptr<A> > a_out(n);
382  arrayViewPtrConv(a_in, a_out());
383  TEST_EQUALITY( a_out.size(), a_in.size() );
384  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
385  TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
386  }
387 }
388 
389 
390 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpNonconstDerived_to_PtrConstBase)
391 {
392  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
393  Array<Ptr<const A> > a_out(n);
394  arrayViewPtrConv(a_in, a_out());
395  TEST_EQUALITY( a_out.size(), a_in.size() );
396  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
397  TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
398  }
399 }
400 
401 
402 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewPtrConv_RcpConstDerived_to_PtrConstBase)
403 {
404  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
405  Array<RCP<const C> > a1_out(n);
406  arrayViewRcpConv(a_in, a1_out());
407  Array<Ptr<const A> > a2_out(n);
408  arrayViewPtrConv(a1_out, a2_out());
409  TEST_EQUALITY( a2_out.size(), a_in.size() );
410  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
411  TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<const A>(&*a_in[i]) );
412  }
413 }
414 
415 
416 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpNonconstBase)
417 {
418  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
419  Array<RCP<A> > a_out(n);
420  arrayViewRcpConv(a_in, a_out());
421  TEST_EQUALITY( a_out.size(), a_in.size() );
422  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
423  TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
424  }
425 }
426 
427 
428 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpNonconstDerived_to_RcpConstBase)
429 {
430  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
431  Array<RCP<const A> > a_out(n);
432  arrayViewRcpConv(a_in, a_out());
433  TEST_EQUALITY( a_out.size(), a_in.size() );
434  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
435  TEST_EQUALITY( &*a_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
436  }
437 }
438 
439 
440 TEUCHOS_UNIT_TEST( ArrayConversions, arrayViewRcpConv_RcpConstDerived_to_RcpConstBase)
441 {
442  const Array<RCP<C> > a_in = generateArrayRcpGen<C>(n);
443  Array<RCP<const C> > a1_out(n);
444  arrayViewRcpConv(a_in, a1_out());
445  Array<RCP<const A> > a2_out(n);
446  arrayViewRcpConv(a1_out, a2_out());
447  TEST_EQUALITY( a2_out.size(), a_in.size() );
448  for (Teuchos_Ordinal i=0 ; i<n ; ++i) {
449  TEST_EQUALITY( &*a2_out[i], implicit_ptr_cast<A>(&*a_in[i]) );
450  }
451 }
452 
453 
454 } // namespace
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]&lt;[const] RCP&lt;T_in&gt; &gt; object to an Array&lt;RCP&lt;T_out&gt; &gt; 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]&lt;[const] PTR&lt;T_in&gt; &gt; 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]&lt;[const] RCP&lt;T_in&gt; &gt; 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&lt;const RCP&lt;T&gt; &gt; 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&lt;RCP&lt;T&gt; &gt; and ArrayView&lt;Ptr&lt;T&gt; &gt;
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....
Nonowning array view.
Array< Ptr< T_out > > arrayPtrConv(const ArrayPtrT_in &a_in)
Utility function to convert an Array[View,RCP]&lt;[const] PTR&lt;T_in&gt; &gt; object to an Array&lt;Ptr&lt;T_out&gt; &gt; 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&lt;const Ptr&lt;T&gt; &gt; 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...