Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Array_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 
45 #include "Teuchos_Tuple.hpp"
46 #include "Teuchos_ArrayRCP.hpp"
47 
48 
49 namespace {
50 
51 
54 using Teuchos::null;
55 using Teuchos::tuple;
56 using Teuchos::RCP;
57 using Teuchos::Array;
58 using Teuchos::ArrayView;
59 using Teuchos::ArrayRCP;
60 using Teuchos::arcp;
61 using Teuchos::arcpFromArray;
62 using Teuchos::as;
63 using Teuchos::getConst;
65 using Teuchos::fromStringToArray;
67 
68 
69 TEUCHOS_UNIT_TEST( Utils, trimWhiteSpace_empty )
70 {
72 }
73 
74 
75 
76 TEUCHOS_UNIT_TEST( Array, TypeNameTraits )
77 {
78  TEST_EQUALITY(Teuchos::TypeNameTraits<Array<double> >::name(),
79  std::string("Array(double)"));
80 }
81 
82 
83 TEUCHOS_UNIT_TEST( Array, stringToArray )
84 {
85 
86  {
87  std::string arrayString="{}";
88  std::istringstream arrayStream(arrayString);
89  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
90  Array<std::string> arrayStreamVal;
91  arrayStream >> arrayStreamVal;
92  Array<std::string> arrayVal_exp;
93  TEST_EQUALITY(arrayVal, arrayVal_exp);
94  TEST_EQUALITY(arrayStreamVal, arrayVal_exp);
95  }
96 
97  {
98  std::string arrayString = "{ a, b, c, d }";
99  std::istringstream arrayStream(arrayString);
100  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
101  Array<std::string> arrayStreamVal;
102  arrayStream >> arrayStreamVal;
103  Array<std::string> arrayVal_exp = Teuchos::tuple<std::string>("a", "b", "c", "d" );
104  TEST_EQUALITY(arrayVal, arrayVal_exp);
105  TEST_EQUALITY(arrayStreamVal, arrayVal_exp);
106  }
107 
108  {
109  std::string arrayString = "{ (a), b, c, (d) }";
110  std::istringstream arrayStream(arrayString);
111  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
112  Array<std::string> arrayStreamVal;
113  arrayStream >> arrayStreamVal;
114  Array<std::string> arrayVal_exp = Teuchos::tuple<std::string>("(a)", "b", "c", "(d)" );
115  TEST_EQUALITY(arrayVal, arrayVal_exp);
116  TEST_EQUALITY(arrayStreamVal, arrayVal_exp);
117  }
118 
119  {
120  std::string arrayString = "{ (a ), b, c, (d ) }";
121  std::istringstream arrayStream(arrayString);
122  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
123  Array<std::string> arrayStreamVal;
124  arrayStream >> arrayStreamVal;
125  Array<std::string> arrayVal_exp = Teuchos::tuple<std::string>("(a )", "b", "c", "(d )" );
126  TEST_EQUALITY(arrayVal, arrayVal_exp);
127  TEST_EQUALITY(arrayStreamVal, arrayVal_exp);
128  }
129 
130  // This should work but does not. I should fix this!
131 // {
132 // Array<std::string> arrayVal = fromStringToArray<std::string>("{ {a}, 'b', {c }, d }");
133 // Array<std::string> arrayVal_exp = Teuchos::tuple<std::string>("{a}", "'b'", "{c }", "d" );
134 // TEST_EQUALITY(arrayVal, arrayVal_exp);
135 // }
136 
137 }
138 
139 
140 TEUCHOS_UNIT_TEST( Array, stringToArray_invalid )
141 {
142  TEST_THROW(fromStringToArray<std::string>("{ a, b, c"),
143  InvalidArrayStringRepresentation);
144  TEST_THROW(fromStringToArray<std::string>("a, b, c}"),
145  InvalidArrayStringRepresentation);
146  TEST_THROW(fromStringToArray<std::string>("a, b, c"),
147  InvalidArrayStringRepresentation);
148 }
149 
150 
151 TEUCHOS_UNIT_TEST( Array, stringToArray_string_hyphens )
152 {
153 
154  {
155  std::string arrayString="{-}";
156  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
157  Array<std::string> arrayVal_exp = tuple<std::string>("-");
158  TEST_EQUALITY(arrayVal, arrayVal_exp);
159  }
160 
161  {
162  std::string arrayString="{-,-}";
163  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
164  Array<std::string> arrayVal_exp = tuple<std::string>("-","-");
165  TEST_EQUALITY(arrayVal, arrayVal_exp);
166  }
167 
168  {
169  std::string arrayString="{-,1,-}";
170  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
171  Array<std::string> arrayVal_exp = tuple<std::string>("-","1","-");
172  TEST_EQUALITY(arrayVal, arrayVal_exp);
173  }
174 
175  {
176  std::string arrayString="{}";
177  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
178  Array<std::string> arrayVal_exp;
179  TEST_EQUALITY(arrayVal, arrayVal_exp);
180  }
181 
182  {
183  std::string arrayString="{,}";
184  TEST_THROW(
185  [[maybe_unused]] Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString),
187  }
188 
189 }
190 
191 
192 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, defaultConstruct, T )
193 {
194  Array<T> a2;
195  TEST_EQUALITY_CONST( as<int>(a2.size()), 0 );
196  TEST_EQUALITY_CONST( as<int>(a2.empty()), true );
197  TEST_EQUALITY_CONST( a2.getRawPtr(), 0 );
198  TEST_EQUALITY_CONST( a2.getRawPtr(), a2.data() );
200  TEST_EQUALITY_CONST( getConst(a2).getRawPtr(), getConst(a2).data() );
201 }
202 
203 
204 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, sizedConstruct, T )
205 {
206  typedef typename Array<T>::size_type size_type;
207  Array<T> a(n);
208  TEST_EQUALITY_CONST( a.empty(), false );
209  TEST_EQUALITY( a.length(), n );
210  TEST_EQUALITY( as<int>(a.size()), n );
211  TEST_EQUALITY( a.getRawPtr(), &a[0] );
212  TEST_EQUALITY( a.getRawPtr(), a.data() );
213  TEST_EQUALITY( getConst(a).getRawPtr(), &getConst(a)[0] );
214  TEST_EQUALITY( getConst(a).getRawPtr(), getConst(a).data() );
215  TEST_COMPARE( a.max_size(), >=, as<size_type>(n) );
216  TEST_COMPARE( as<int>(a.capacity()), >=, n );
217 }
218 
219 
220 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, operatorBracket, T )
221 {
222  out << "\nTest that a[i] == i ... ";
223  Array<T> a = generateArray<T>(n);
224  bool local_success = true;
225  for( int i = 0; i < n; ++i ) {
226  TEST_ARRAY_ELE_EQUALITY( a, i, as<T>(i) );
227  }
228  if (local_success) out << "passed\n";
229  else success = false;
230 }
231 
232 
233 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constAt, T )
234 {
235  out << "\nTest that a.at(i) == i ...\n";
236  Array<T> a = generateArray<T>(n);
237  bool local_success = true;
238  for( int i = 0; i < n; ++i ) {
239  TEUCHOS_TEST_EQUALITY( a.at(i), as<T>(i), out, local_success );
240  }
241  if (local_success) out << "passed\n";
242  else success = false;
243 }
244 
245 
246 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayViewIter_before_block_end, T )
247 {
248  typedef typename ArrayView<T>::iterator iter_t;
250  iter_t iter = NIT::getNull();
251  {
252  ECHO(Array<T> a(n, as<T>(0)));
253  ECHO(ArrayView<T> av = a);
254  ECHO(iter = av.begin());
255  ECHO(av = null);
256  TEST_EQUALITY( *iter, a[0] );
257  // Above, the iterator to the ArrayView object is still valid even through
258  // the ArrayView object is was created from is gone now. This is just
259  // fine since the underlying data is still there in the original Array object.
260  iter = NIT::getNull();
261  }
262 }
263 
264 
265 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPArray_to_ArrayRCP_null, T )
266 {
267  const RCP<Array<T> > a_rcp = null;
268  const ArrayRCP<T> a_arcp = arcp(a_rcp);
269  TEST_ASSERT( a_arcp == null );
270 }
271 
272 
273 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPconstArray_to_ArrayRCP_null, T )
274 {
275  const RCP<const Array<T> > a_rcp = null;
276  const ArrayRCP<const T> a_arcp = arcp(a_rcp);
277  TEST_ASSERT( a_arcp == null );
278 }
279 
280 
281 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPArray_to_ArrayRCP, T )
282 {
283  const Array<T> a_const = generateArray<T>(n);
284  const RCP<Array<T> > a_rcp = Teuchos::rcp( new Array<T>(a_const));
285  const ArrayRCP<T> a_arcp = arcp(a_rcp);
286  TEST_COMPARE_ARRAYS( a_const(), a_arcp() );
287 }
288 
289 
290 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPconstArray_to_ArrayRCP, T )
291 {
292  const Array<T> a_const = generateArray<T>(n);
293  const RCP<const Array<T> > a_rcp = Teuchos::rcp( new Array<T>(a_const));
294  const ArrayRCP<const T> a_arcp = arcp(a_rcp);
295  TEST_COMPARE_ARRAYS( a_const(), a_arcp() );
296 }
297 
298 
299 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, Array_to_ArrayRCP_null, T )
300 {
301  Array<T> a;
302  const ArrayRCP<T> a_arcp = arcpFromArray(a);
303  TEST_ASSERT(a_arcp == null);
304 }
305 
306 
307 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constArray_to_ArrayRCP_null, T )
308 {
309  const Array<T> a;
310  const ArrayRCP<const T> a_arcp = arcpFromArray(a);
311  TEST_ASSERT(a_arcp == null);
312 }
313 
314 
315 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, Array_to_ArrayRCP, T )
316 {
317  Array<T> a = generateArray<T>(n);
318  const ArrayRCP<T> a_arcp = arcpFromArray(a);
319  TEST_COMPARE_ARRAYS( a(), a_arcp() );
320 }
321 
322 
323 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constArray_to_ArrayRCP, T )
324 {
325  const Array<T> a = generateArray<T>(n);
326  const ArrayRCP<const T> a_arcp = arcpFromArray(a);
327  TEST_COMPARE_ARRAYS( a(), a_arcp() );
328 }
329 
330 
331 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, Array_to_ArrayRCP_dangling, T )
332 {
333  ArrayRCP<T> a_arcp;
334  {
335  Array<T> a = generateArray<T>(n);
336  a_arcp = arcpFromArray(a);
337  }
338 #ifdef TEUCHOS_DEBUG
339  TEST_THROW(a_arcp[0], DanglingReferenceError);
340 #else
341  (void)out; (void)success;
342 #endif
343 }
344 
345 
346 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constArray_to_ArrayRCP_dangling, T )
347 {
348  ArrayRCP<const T> a_arcp;
349  {
350  const Array<T> a = generateArray<T>(n);
351  a_arcp = arcpFromArray(a);
352  }
353 #ifdef TEUCHOS_DEBUG
354  TEST_THROW(a_arcp[0], DanglingReferenceError);
355 #else
356  (void)out; (void)success;
357 #endif
358 }
359 
360 
361 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, toVector, T )
362 {
363  const Array<T> a = generateArray<T>(n);
364  const std::vector<T> v = a.toVector();
365  TEST_COMPARE_ARRAYS( a, v );
366 }
367 
368 
369 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, toVector_empty, T )
370 {
371  const Array<T> a;
372  const std::vector<T> v = a.toVector();
373  TEST_EQUALITY_CONST( as<int>(v.size()), 0 );
374 }
375 
376 
377 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, view_empty_func, T )
378 {
379  Array<T> a;
380  const ArrayView<T> av = a.view(0, 0);
381  TEST_ASSERT(is_null(av));
382 }
383 
384 
385 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, view_empty_operator, T )
386 {
387  Array<T> a;
388  const ArrayView<T> av = a(0, 0);
389  TEST_ASSERT(is_null(av));
390 }
391 
392 
393 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, view_const_empty, T )
394 {
395  const Array<T> a;
396  const ArrayView<const T> av = a.view(0, 0);
397  TEST_ASSERT(is_null(av));
398 }
399 
400 
401 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, implicit_to_ArrayView_empty, T )
402 {
403  Array<T> a;
404  const ArrayView<T> av = a();
405  TEST_ASSERT(is_null(av));
406 }
407 
408 
409 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, implicit_to_ArrayView_const_empty, T )
410 {
411  const Array<T> a;
412  const ArrayView<const T> av = a();
413  TEST_ASSERT(is_null(av));
414 }
415 
416 
417 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_implicit, T )
418 {
419  ArrayView<T> av;
420  { Array<T> a(n); av = a; }
421 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
422  TEST_THROW( av[0] = 0, DanglingReferenceError );
423 #else
424  (void)out; (void)success;
425 #endif
426 }
427 
428 
429 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_implicit_const, T )
430 {
431  ArrayView<const T> av;
432  { Array<T> a(n); av = getConst(a); }
433 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
434  TEST_THROW( av[0], DanglingReferenceError );
435 #else
436  (void)out; (void)success;
437 #endif
438 }
439 
440 
441 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_explicit, T )
442 {
443  ArrayView<T> av;
444  { Array<T> a(n); av = a(); }
445 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
446  TEST_THROW( av[0] = 0, DanglingReferenceError );
447 #else
448  (void)out; (void)success;
449 #endif
450 }
451 
452 
453 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_explicit_const, T )
454 {
455  ArrayView<const T> av;
456  { Array<T> a(n); av = getConst(a)(); }
457 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
458  TEST_THROW( av[0], DanglingReferenceError );
459 #else
460  (void)out; (void)success;
461 #endif
462 }
463 
464 
465 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_subview, T )
466 {
467  ArrayView<T> av;
468  { Array<T> a(n); av = a(0,1); }
469 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
470  TEST_THROW( av[0] = 0, DanglingReferenceError );
471 #else
472  (void)out; (void)success;
473 #endif
474 }
475 
476 
477 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_subview_const, T )
478 {
479  ArrayView<const T> av;
480  { Array<T> a(n); av = getConst(a)(0,1); }
481 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
482  TEST_THROW( av[0], DanglingReferenceError );
483 #else
484  (void)out; (void)success;
485 #endif
486 }
487 
488 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayViewIter, T )
489 {
490  typedef typename ArrayView<T>::iterator iter_t;
491  ECHO(Array<T> a(n));
492  ECHO(ArrayView<T> av = a);
493  ECHO(iter_t iter = av.begin());
494  ECHO(av = null);
495  ECHO(a.resize(0));
496 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
497  TEST_THROW( *iter = 0, DanglingReferenceError );
498 #else
499  (void)iter; (void)out; (void)success;
500 #endif
501 }
502 
503 
504 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayViewIter_const, T )
505 {
506  typedef typename ArrayView<const T>::iterator iter_t;
507  ECHO(Array<T> a(n));
508  ECHO(ArrayView<T> av = a);
509  ECHO(iter_t iter = av.begin());
510  ECHO(av = null);
511  ECHO(a.resize(0));
512 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
513  TEST_THROW( *iter, DanglingReferenceError );
514 #else
515  (void)iter; (void)out; (void)success;
516 #endif
517 }
518 
519 
520 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, erase_empty, T )
521 {
522  ECHO(std::vector<T> v);
523  TEST_NOTHROW(v.erase(v.begin(), v.end()));
524  ECHO(Array<T> a);
525  TEST_NOTHROW(a.erase(a.begin(), a.end()));
526 }
527 
528 
529 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, structuralChangeArrayView, T )
530 {
531  Array<T> a = generateArray<T>(n);
532  ArrayView<T> av = a;
533  a.push_back(a[0]);
534 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
535  TEST_THROW( av[0] = 0, DanglingReferenceError );
536 #else
537  (void)av; (void)out; (void)success;
538 #endif
539 }
540 
541 
542 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, structuralChangeArrayView_const, T )
543 {
544  Array<T> a = generateArray<T>(n);
545  ArrayView<const T> av = getConst(a);
546  a.push_back(a[0]);
547 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
548  TEST_THROW( av[0], DanglingReferenceError );
549 #else
550  (void)av; (void)out; (void)success;
551 #endif
552 }
553 
554 
555 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, initializerList, T )
556 {
557  const Array<T> a2{as<T>(1),as<T>(2),as<T>(3),as<T>(4)};
558  TEST_EQUALITY( a2.size(), 4);
559  for (typename Array<T>::size_type i=0; i < a2.size(); ++i) {
560  TEST_EQUALITY( a2[i], as<T>(i+1) );
561  }
562 }
563 
564 
565 //
566 // Instantiations
567 //
568 
569 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
570 
571 # define DEBUG_UNIT_TEST_GROUP( T )
572 
573 #else // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
574 
575 # define DEBUG_UNIT_TEST_GROUP( T )
576 
577 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
578 
579 
580 #define UNIT_TEST_GROUP( T ) \
581  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, defaultConstruct, T ) \
582  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, sizedConstruct, T ) \
583  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, operatorBracket, T ) \
584  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constAt, T ) \
585  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter_before_block_end, T ) \
586  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPArray_to_ArrayRCP_null, T ) \
587  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPconstArray_to_ArrayRCP_null, T ) \
588  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPArray_to_ArrayRCP, T ) \
589  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPconstArray_to_ArrayRCP, T ) \
590  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP_null, T ) \
591  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP_null, T ) \
592  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP, T ) \
593  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP, T ) \
594  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP_dangling, T ) \
595  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP_dangling, T ) \
596  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, toVector, T ) \
597  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, toVector_empty, T ) \
598  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, view_empty_func, T ) \
599  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, view_empty_operator, T ) \
600  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, implicit_to_ArrayView_empty, T ) \
601  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_implicit, T ) \
602  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_implicit_const, T ) \
603  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_explicit, T ) \
604  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_explicit_const, T ) \
605  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_subview, T ) \
606  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_subview_const, T ) \
607  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter, T ) \
608  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter_const, T ) \
609  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, erase_empty, T ) \
610  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, structuralChangeArrayView, T ) \
611  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, structuralChangeArrayView_const, T ) \
612  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, initializerList, T ) \
613  DEBUG_UNIT_TEST_GROUP( T )
614 
615 UNIT_TEST_GROUP(int)
616 UNIT_TEST_GROUP(float)
617 UNIT_TEST_GROUP(double)
618 
619 
620 } // namespace
Dangling reference error exception class.
#define TEST_ASSERT(v1)
Assert the given statement is true.
#define TEST_NOTHROW(code)
Asserr that the statement &#39;code&#39; does not thrown any excpetions.
#define ECHO(statement)
Echo the given statement before it is executed.
#define TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(TEST_GROUP, TEST_NAME, TYPE)
Macro for defining a templated unit test with one template parameter.
RawPointerConversionTraits< Container >::Ptr_t getRawPtr(const Container &c)
#define TEST_EQUALITY(v1, v2)
Assert the equality of v1 and v2.
#define TEST_THROW(code, ExceptType)
Assert that the statement &#39;code&#39; throws the exception &#39;ExceptType&#39; (otherwise the test fails)...
#define TEST_COMPARE(v1, comp, v2)
Assert that v1 comp v2 (where comp = &#39;==&#39;, &#39;&gt;=&quot;, &quot;!=", etc).
const T & getConst(T &t)
Return a constant reference to an object given a non-const reference.
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.
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
ArrayRCP< T > arcpFromArray(Array< T > &a)
Wrap an Array&lt;T&gt; object as a non-owning ArrayRCP&lt;T&gt; object.
bool is_null(const ArrayRCP< T > &p)
Returns true if p.get()==NULL.
static std::string trimWhiteSpace(const std::string &str)
Trim whitespace from beginning and end of std::string.
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.
Teuchos::Array< T > generateArray(const int n_in)
Base traits class for getting a properly initialized null pointer.
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
Test that two values are equal.
Nonowning array view.
Default traits class that just returns typeid(T).name().
#define TEST_ARRAY_ELE_EQUALITY(a, i, val)
Assert that a[i] == val.
#define UNIT_TEST_GROUP(T)
Smart reference counting pointer class for automatic garbage collection.
Reference-counted smart pointer for managing arrays.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...