Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArrayRCP_test.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Teuchos_ArrayRCP.hpp"
11 #include "Teuchos_Array.hpp"
16 #include "Teuchos_Version.hpp"
17 #include "Teuchos_Assert.hpp"
19 
20 
21 // Temporarily uncomment any or all of these macros to see compilation
22 // failures for code that is rightfully not supposed to compile (which is a
23 // wonderful thing)! The fact that this code does not compile show that the
24 // design of the Teuchos::ArrayRCP class supports full support of
25 // const projection in all of its forms when dealing with arrays of objects.
26 //#define SHOW_COMPILE_FAILURE_1
27 //#define SHOW_COMPILE_FAILURE_2
28 //#define SHOW_COMPILE_FAILURE_3
29 
30 
31 //
32 // Iterator testing function
33 //
34 
35 template<class T>
39  )
40 {
41 
42  using Teuchos::ArrayRCP;
43  using Teuchos::null;
44  using Teuchos::arcp;
45 
46  bool success = true;
47 
48  out
49  << "\n***"
50  << "\n*** Testing iterators and accessors for ptr = " << ptr
51  << "\n***\n";
52 
53  Teuchos::OSTab tab(out);
54 
55  const int size = ptr.size();
56 
57  // Pointer ++
58 
59  {
60  out << "\nChecking ++itr and < ...\n";
61  ArrayRCP<T> itr = ptr;
62  for( int i = 0; itr < ptr+size; ++i, ++itr )
63  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
64  }
65 
66  {
67  out << "\nChecking itr++ and <= ...\n";
68  ArrayRCP<T> itr = ptr;
69  for( int i = 0; itr <= ptr+size-1; ++i, itr++ )
70  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
71  }
72 
73  {
74  out << "\nChecking itr+=1 and != ...\n";
75  ArrayRCP<T> itr = ptr;
76  for( int i = 0; itr != ptr+size; ++i, itr+=1 )
77  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
78  }
79 
80  {
81  out << "\nChecking itr=itr+1 and == ...\n";
82  ArrayRCP<T> itr = ptr;
83  for( int i = 0; !( itr == ptr+size ); ++i, itr=itr+1 )
84  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
85  }
86 
87  // Pointer --
88 
89  {
90  out << "\nChecking --itr and >= ...\n";
91  ArrayRCP<T> itr = ptr+size-1;
92  for( int i = size-1; itr >= ptr; --i, --itr )
93  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
94  }
95 
96  {
97  out << "\nChecking itr-- and > ...\n";
98  ArrayRCP<T> itr = ptr+size-1;
99  for( int i = size-1; itr+1 > ptr; i--, itr-- )
100  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
101  }
102 
103  {
104  out << "\nChecking itr-=1 and != ...\n";
105  ArrayRCP<T> itr = ptr+size-1;
106  for( int i = size-1; itr+1 != ptr; i--, itr-=1 )
107  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
108  }
109 
110  {
111  out << "\nChecking itr=itr-1 and == ...\n";
112  ArrayRCP<T> itr = ptr+size-1;
113  for( int i = size-1; !( itr+1 == ptr ); i--, itr=itr-1 )
114  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
115  }
116 
117  // Iterator - Iterator
118 
119  {
120  out << "\nChecking ptr.end() - ptr.begin() == ptr.size() ...\n";
121  TEUCHOS_ASSERT_EQUALITY( ptr.end() - ptr.begin(), ptr.size() );
122  }
123 
124  // Iterator ++
125 
126  {
127  out << "\nChecking iterator ++itr and < ...\n";
128  typename ArrayRCP<T>::const_iterator itr = ptr.begin();
129  for( int i = 0; itr < ptr.end(); ++i, ++itr )
130  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
131  }
132 
133  {
134  out << "\nChecking iterator itr++ and <= ...\n";
135  typename ArrayRCP<T>::const_iterator itr = ptr.begin();
136  for( int i = 0; itr <= ptr.end()-1; ++i, itr++ )
137  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
138  }
139 
140  {
141  out << "\nChecking iterator itr+=1 and != ...\n";
142  typename ArrayRCP<T>::const_iterator itr = ptr.begin();
143  for( int i = 0; itr != ptr.end(); ++i, itr+=1 )
144  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
145  }
146 
147  {
148  out << "\nChecking iterator itr=itr+1 and == ...\n";
149  typename ArrayRCP<T>::const_iterator itr = ptr.begin();
150  for( int i = 0; !( itr == ptr.end() ); ++i, itr=itr+1 )
151  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
152  }
153 
154  // Iterator --
155 
156  {
157  out << "\nChecking iterator --itr and >= ...\n";
158  typename ArrayRCP<T>::const_iterator itr = ptr.begin()+size-1;
159  for( int i = size-1; itr >= ptr.begin(); --i, --itr )
160  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
161  }
162 
163  {
164  out << "\nChecking iterator itr-- and > ...\n";
165  typename ArrayRCP<T>::const_iterator itr = ptr.begin()+size-1;
166  for( int i = size-1; itr+1 > ptr.begin(); i--, itr-- )
167  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
168  }
169 
170  {
171  out << "\nChecking iterator itr-=1 and != ...\n";
172  typename ArrayRCP<T>::const_iterator itr = ptr.begin()+size-1;
173  for( int i = size-1; itr+1 != ptr.begin(); i--, itr-=1 )
174  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
175  }
176 
177  {
178  out << "\nChecking iterator itr=itr-1 and == ...\n";
179  typename ArrayRCP<T>::const_iterator itr = ptr.begin()+size-1;
180  for( int i = size-1; !( itr+1 == ptr.begin() ); i--, itr=itr-1 )
181  TEUCHOS_TEST_FOR_EXCEPT( !(*itr == ptr[i]) );
182  }
183 
184  return success;
185 
186 }
187 
188 
189 //
190 // Main testing function for a specific ArrayRCP
191 //
192 
193 
194 template<class T>
196  const Teuchos::ArrayRCP<T> &ptr,
198  )
199 {
200 
201  using Teuchos::ArrayView;
202  using Teuchos::ArrayRCP;
203  using Teuchos::arcp;
204  using Teuchos::arcp_const_cast;
205  using Teuchos::as;
206 
207  bool success = true, result;
208 
209  out
210  << "\n***"
211  << "\n*** Testing ptr = " << ptr
212  << "\n***\n";
213 
214  Teuchos::OSTab tab(out);
215 
216  const int n = ptr.size();
217 
218  {
219  out << "\nInitializing data ...\n";
220  for( int i = 0; i < n; ++i )
221  ptr[i] = i;
222  }
223 
224  TEUCHOS_TEST_FOR_EXCEPT( !(&*ptr == ptr.get()) );
225  TEUCHOS_TEST_FOR_EXCEPT( !(&*ptr == ptr.getRawPtr()) );
226 
227  result = test_ArrayRCP_iterators(ptr,out);
228  if (!result) success = false;
229 
230  //
231  out << "\nTest const casting ...\n";
232  //
233 
234  {
235  const ArrayRCP<const T> cptr2 = ptr;
236  const ArrayRCP<T> ptr3 = arcp_const_cast<T>(cptr2);
237  TEST_COMPARE_ARRAYS( ptr3, ptr );
238  }
239 
240  //
241  out << "\nTest views ...\n";
242  //
243 
244  {
245  out << "\nTest full non-const subview ...\n";
246  const ArrayView<T> av2 = ptr(0,n);
247  TEST_COMPARE_ARRAYS( av2, ptr );
248  }
249 
250  {
251  out << "\nTest full shorthand non-const subview ...\n";
252  const ArrayView<T> av2 = ptr();
253  TEST_COMPARE_ARRAYS( av2, ptr );
254  }
255 
256  {
257  out << "\nTest full const subview ...\n";
258  const ArrayView<const T> cav2 = ptr.getConst()(0,n);
259  TEST_COMPARE_ARRAYS( cav2, ptr );
260  }
261 
262  {
263  out << "\nTest full non-const to const subview ...\n";
264  const ArrayView<const T> cav2 = ptr(0,n);
265  TEST_COMPARE_ARRAYS( cav2, ptr );
266  }
267 
268  {
269  out << "\nTest full short-hand const subview ...\n";
270  const ArrayView<const T> cav2 = ptr.getConst()();
271  TEST_COMPARE_ARRAYS( cav2, ptr );
272  }
273 
274  {
275  out << "\nTest implicit conversion from ArrayRCP<T> to ArrayView<T> ...\n";
276  const ArrayView<T> av2 = ptr();
277  TEST_COMPARE_ARRAYS( av2, ptr );
278  }
279 
280  {
281  out << "\nTest implicit conversion from ArrayRCP<const T> to ArrayView<const T> ...\n";
282  const ArrayView<const T> av2 = ptr.getConst()();
283  TEST_COMPARE_ARRAYS( av2, ptr );
284  }
285 
286  {
287  out << "\nTest almost implicit conversion from ArrayRCP<T> to ArrayView<const T> ...\n";
288  const ArrayView<const T> av2 = ptr();
289  TEST_COMPARE_ARRAYS( av2, ptr );
290  }
291 
292  {
293  out << "\nTest implicit conversion from ArrayRCP<T> to ArrayRCP<const T> ...\n";
294  const ArrayRCP<const T> ptr2 = ptr;
295  TEST_COMPARE_ARRAYS( ptr2, ptr );
296  }
297 
298  {
299  out << "\nTest clone of ArrayView<T> to ArrayRCP<T> ...\n";
300  const ArrayRCP<T> ptr2 = Teuchos::arcpClone<T>(ptr());
301  TEST_COMPARE_ARRAYS( ptr2, ptr );
302  }
303 
304  {
305  out << "\nTest clone of ArrayPtr<const T> to ArrayRCP<T> ...\n";
306  const ArrayRCP<T> ptr2 = Teuchos::arcpClone<T>(ptr.getConst()());
307  TEST_COMPARE_ARRAYS( ptr2, ptr );
308  }
309  {
310  out << "\nTest extra data ...\n";
311  ArrayRCP<T> ptr2 = arcp<T>(n);
312  Teuchos::set_extra_data( as<int>(1), "int", Teuchos::inOutArg(ptr2) );
313  TEST_EQUALITY_CONST( Teuchos::get_extra_data<int>(ptr2, "int"), 1);
314  }
315 
316  return success;
317 
318 }
319 
320 
321 //
322 // Main driver program
323 //
324 
325 
326 int main( int argc, char* argv[] )
327 {
328 
329  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
330 
332  using Teuchos::null;
333  using Teuchos::RCP;
334  using Teuchos::rcp;
335  using Teuchos::ArrayRCP;
336  using Teuchos::arcp;
337  using Teuchos::arcp_reinterpret_cast;
338 
339  bool success = true, result;
340 
343 
344  try {
345 
346  // Read options from the commandline
347  int num_ints = 10;
348  int num_doubles = 10;
349  CommandLineProcessor clp(false); // Don't throw exceptions
350  clp.setOption( "num-ints", &num_ints, "Number of ints to allocate space for" );
351  clp.setOption( "num-doubles", &num_doubles, "Number of doubles to allocate space for" );
352  CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
353  if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) {
354  *out << "\nEnd Result: TEST FAILED" << std::endl;
355  return parse_return;
356  }
357 
358  const int sizeOfDouble = sizeof(double);
359  const int sizeOfInt = sizeof(int);
360 
361  const int total_bytes = num_doubles*sizeOfDouble + num_ints*sizeOfInt;
362 
363  *out << std::endl << Teuchos::Teuchos_Version() << std::endl;
364 
365  *out << "\nTesting basic ArrayRCP functionality ...\n";
366 
367  ArrayRCP<char>
368  char_ptr1 = arcp<char>(total_bytes);
369 
370  *out << "\nchar_ptr1 = " << char_ptr1 << "\n";
371 
372  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.size() == total_bytes) );
373  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.lowerOffset() == 0) );
374  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.upperOffset() == total_bytes-1) );
375  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.strong_count() == 1) );
376  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.weak_count() == 0) );
377  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.total_count() == 1) );
378  result = test_ArrayRCP(char_ptr1,*out);
379  if (!result) success = false;
380 
381  ArrayRCP<char>
382  char_ptr2 = null;
383 
384  *out << "\nchar_ptr2 = " << char_ptr2 << "\n";
385 
386  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2.size() == 0) );
387  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2.get() == NULL) );
388  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2.strong_count() == 0) );
389  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2.weak_count() == 0) );
390  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2.total_count() == 0) );
391 
392  ArrayRCP<char>
393  char_ptr2b(char_ptr1); // excplicitly test copy constructor
394 
395  *out << "\nchar_ptr2b = " << char_ptr2b << "\n";
396 
397  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2b.size() == total_bytes) );
398  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2b.lowerOffset() == 0) );
399  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2b.upperOffset() == total_bytes-1) );
400  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2b.strong_count() == 2) );
401  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2b.weak_count() == 0) );
402  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2b.total_count() == 2) );
403  result = test_ArrayRCP(char_ptr2b,*out);
404  if (!result) success = false;
405 
406  char_ptr2b = null;
407 
408  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2b.size() == 0) );
409  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2.get() == NULL) );
410  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr2b.strong_count() == 0) );
411  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.strong_count() == 1) );
412 
413  ArrayRCP<char>
414  char_ptr3 = char_ptr1.persistingView(total_bytes/2,total_bytes/2);
415 
416  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.strong_count() == 2) );
417  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr3.strong_count() == 2) );
418  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr3.lowerOffset() == 0) );
419  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr3.upperOffset() == total_bytes/2-1) );
420  result = test_ArrayRCP(char_ptr3,*out);
421  if (!result) success = false;
422 
423  *out << "\nchar_ptr3 = " << char_ptr3 << "\n";
424 
425  *out << "\nBreak up char_ptr1 into views of double and int data\n";
426 
427  int offset = 0;
428 
429  ArrayRCP<double> double_ptr1 = arcp_reinterpret_cast<double>(
430  char_ptr1.persistingView(offset,sizeOfDouble*num_doubles)
431  );
432 
433  *out << "\ndouble_ptr1 = " << double_ptr1 << "\n";
434 
435  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.strong_count() == 3) );
436  TEUCHOS_TEST_FOR_EXCEPT( !(double_ptr1.strong_count() == 3) );
437  TEUCHOS_TEST_FOR_EXCEPT( !(double_ptr1.size() == num_doubles) );
438 
439  result = test_ArrayRCP(double_ptr1,*out);
440  if (!result) success = false;
441 
442  offset += sizeOfDouble*num_doubles;
443 
444  ArrayRCP<int> int_ptr1 = arcp_reinterpret_cast<int>(
445  char_ptr1.persistingView(offset,sizeOfInt*num_ints)
446  );
447 
448  *out << "\nint_ptr1 = " << int_ptr1 << "\n";
449 
450  TEUCHOS_TEST_FOR_EXCEPT( !(char_ptr1.strong_count() == 4) );
451  TEUCHOS_TEST_FOR_EXCEPT( !(int_ptr1.strong_count() == 4) );
452  TEUCHOS_TEST_FOR_EXCEPT( !(int_ptr1.size() == num_ints) );
453 
454  result = test_ArrayRCP(int_ptr1,*out);
455  if (!result) success = false;
456 
457  *out << "\nCreating a constant view of double_ptr1\n";
458 
459  ArrayRCP<const double>
460  double_ptr2 = double_ptr1.getConst();
461 
462  result = test_ArrayRCP_iterators(double_ptr2,*out);
463  if (!result) success = false;
464 
465 #ifdef SHOW_COMPILE_FAILURE_1
466  // This will not compile since this function tries to use operator[] to
467  // change data but it can't since it returns a reference to a const
468  // double!
469  for( int i = 0; i < double_ptr2.size(); ++i ) {
470  double_ptr2[i] = 1.0; // Error, you can change the value!
471  }
472 #endif
473 
474  *out << "\nCreating an array of RCP objects!\n";
475 
476  ArrayRCP<RCP<double> >
477  rcp_ptr1 = arcp<RCP<double> >(num_doubles);
478 
479  for( int i = 0; i < num_doubles; ++i )
480  rcp_ptr1[i] = rcp(new double(i));
481 
482  result = test_ArrayRCP_iterators(rcp_ptr1,*out);
483  if (!result) success = false;
484 
485  *out << "\nCreating a const view of rcp_ptr1\n";
486 
487  ArrayRCP<const RCP<double> >
488  rcp_ptr2 = rcp_ptr1.getConst();
489 
490  result = test_ArrayRCP_iterators(rcp_ptr2,*out);
491  if (!result) success = false;
492 
493  *out << "\nCreating an ARCP<double*> object doubleptr_ptr1 and dynamically allocation each element\n";
494 
495  ArrayRCP<double*>
496  doubleptr_ptr1 = arcp<double*>(total_bytes);
497 
498  for( int i = 0; i < doubleptr_ptr1.size(); ++i )
499  doubleptr_ptr1[i] = new double(i);
500 
501  result = test_ArrayRCP_iterators(doubleptr_ptr1,*out);
502  if (!result) success = false;
503 
504  *out << "\nCreating an ARCP<double*const> view of a doubleptr_ptr1\n";
505 
506  ArrayRCP<double*const>
507  doubleptr_ptr2 = doubleptr_ptr1.getConst();
508 
509  result = test_ArrayRCP_iterators(doubleptr_ptr2,*out);
510  if (!result) success = false;
511 
512 #ifdef SHOW_COMPILE_FAILURE_2
513  // This will not compile since this function tries to use operator[] to
514  // change data but it can't since it returns a reference to a double*const
515  // object!
516  for( int i = 0; i < doubleptr_ptr2.size(); ++i ) {
517  *doubleptr_ptr2[i] = 1.0; // Fine, you can change the value that is being pointed to for this entry!
518  doubleptr_ptr2[i] = NULL; // Error, you can't change the pointer entry!
519  }
520 #endif
521 
522  *out << "\nCreating an ARCP<const double * const> view of a doubleptr_ptr1\n";
523 
524  ArrayRCP<const double*const>
525  doubleptr_ptr3 = Teuchos::arcp_implicit_cast<const double*const>(doubleptr_ptr1);
526 
527  result = test_ArrayRCP_iterators(doubleptr_ptr3,*out);
528  if (!result) success = false;
529 
530 #ifdef SHOW_COMPILE_FAILURE_3
531  // This will not compile since this function tries to use operator[] to
532  // change data but it can't since it returns a reference to a double*const
533  // object!
534  for( int i = 0; i < doubleptr_ptr3.size(); ++i ) {
535  *doubleptr_ptr3[i] = 1.0; // Error, you can't change the value that is being pointed to!
536  doubleptr_ptr3[i] = NULL; // Error, you can't change the pointer either!
537  }
538 #endif
539 
540  for( int i = 0; i < doubleptr_ptr1.size(); ++i )
541  delete doubleptr_ptr1[i];
542 
543  *out << "\nWrapping RCP<std::vector<T> > objects as ArrayRCP objects ...\n";
544 
545  {
546 
547  ArrayRCP<char>
548  vchar_ptr1 = arcp(rcp(new std::vector<char>(total_bytes)));
549 
550  *out << "\nvchar_ptr1 = " << vchar_ptr1 << "\n";
551 
552  result = test_ArrayRCP(vchar_ptr1,*out);
553  if (!result) success = false;
554 
555  ArrayRCP<const char> vchar_ptr2 = vchar_ptr1;
556 
557  *out << "\nvchar_ptr2 = " << vchar_ptr2 << "\n";
558 
559  result = test_ArrayRCP_iterators(vchar_ptr2, *out);
560  if (!result) success = false;
561 
562 #ifndef __sun
563  // RAB: 2006/07/12: The sun compiler declares this call to
564  // get_std_vector(...) to be ambiguous (which is nonsense based on
565  // everything I know about C++)!
566  TEUCHOS_TEST_FOR_EXCEPT( Teuchos::get_std_vector(vchar_ptr1)->size() != static_cast<size_t>(total_bytes) );
567 #endif
568  TEUCHOS_TEST_FOR_EXCEPT( vchar_ptr1.size() != static_cast<Teuchos_Ordinal>(total_bytes) );
569  TEUCHOS_TEST_FOR_EXCEPT( vchar_ptr2.size() != static_cast<Teuchos_Ordinal>(total_bytes) );
570 
571  }
572 
573  *out << "\nWrapping RCP<ARray<T> > objects as ArrayRCP objects ...\n";
574 
575  {
576 
577  ArrayRCP<char>
578  vchar_ptr1 = arcp(rcp(new Teuchos::Array<char>(total_bytes)));
579 
580  *out << "\nvchar_ptr1 = " << vchar_ptr1 << "\n";
581 
582  result = test_ArrayRCP(vchar_ptr1,*out);
583  if (!result) success = false;
584 
585 /*
586  ArrayRCP<const char> vchar_ptr2 =
587  arcp(
588  Teuchos::rcp_implicit_cast<const std::vector<char> >(
589  Teuchos::get_std_vector(vchar_ptr1)
590  )
591  );
592 */
593 
594  }
595 
596  // ToDo: Fill in the rest of the tests!
597 
598  *out << "\nAll tests for ArrayRCP seem to check out!\n";
599 
600  }
601  TEUCHOS_STANDARD_CATCH_STATEMENTS(true,std::cerr,success);
602 
603  if(success)
604  *out << "\nEnd Result: TEST PASSED" << std::endl;
605 
606  return ( success ? 0 : 1 );
607 
608 }
bool test_ArrayRCP(const Teuchos::ArrayRCP< T > &ptr, Teuchos::FancyOStream &out)
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object...
RCP< const T > getConst() const
Return an RCP&lt;const T&gt; version of *this.
ArrayRCP< T > arcp(const RCP< Array< T > > &v)
Wrap an RCP&lt;Array&lt;T&gt; &gt; object as an ArrayRCP&lt;T&gt; object.
Tabbing class for helping to create formated, indented output for a basic_FancyOStream object...
Initialize, finalize, and query the global MPI session.
ArrayRCP< T2 > arcp_reinterpret_cast(const ArrayRCP< T1 > &p1)
Reinterpret cast of underlying ArrayRCP type from T1* to T2*.
TEUCHOS_ORDINAL_TYPE Teuchos_Ordinal
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Utilities to make writing tests easier.
std::ostream subclass that performs the magic of indenting data sent to an std::ostream object among ...
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
std::string Teuchos_Version()
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
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.
int main(int argc, char *argv[])
Templated array class derived from the STL std::vector.
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
Nonowning array view.
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Basic command line parser for input from (argc,argv[])
ArrayRCP< T2 > arcp_const_cast(const ArrayRCP< T1 > &p1)
Const cast of underlying ArrayRCP type from const T* to T*.
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
This macro is checks that to numbers are equal and if not then throws an exception with a good error ...
RCP< basic_FancyOStream< CharT, Traits > > tab(const RCP< basic_FancyOStream< CharT, Traits > > &out, const int tabs=1, const std::basic_string< CharT, Traits > linePrefix="")
Create a tab for an RCP-wrapped basic_FancyOStream object to cause the indentation of all output auto...
bool test_ArrayRCP_iterators(const Teuchos::ArrayRCP< T > &ptr, Teuchos::FancyOStream &out)
Class that helps parse command line input arguments from (argc,argv[]) and set options.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call...
Reference-counted smart pointer for managing arrays.