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 // @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 
11 #include "Teuchos_Tuple.hpp"
12 #include "Teuchos_ArrayRCP.hpp"
13 
14 
15 namespace {
16 
17 
20 using Teuchos::null;
21 using Teuchos::tuple;
22 using Teuchos::RCP;
23 using Teuchos::Array;
24 using Teuchos::ArrayView;
25 using Teuchos::ArrayRCP;
26 using Teuchos::arcp;
27 using Teuchos::arcpFromArray;
28 using Teuchos::as;
29 using Teuchos::getConst;
31 using Teuchos::fromStringToArray;
33 
34 
35 TEUCHOS_UNIT_TEST( Utils, trimWhiteSpace_empty )
36 {
38 }
39 
40 
41 
42 TEUCHOS_UNIT_TEST( Array, TypeNameTraits )
43 {
44  TEST_EQUALITY(Teuchos::TypeNameTraits<Array<double> >::name(),
45  std::string("Array(double)"));
46 }
47 
48 
49 TEUCHOS_UNIT_TEST( Array, stringToArray )
50 {
51 
52  {
53  std::string arrayString="{}";
54  std::istringstream arrayStream(arrayString);
55  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
56  Array<std::string> arrayStreamVal;
57  arrayStream >> arrayStreamVal;
58  Array<std::string> arrayVal_exp;
59  TEST_EQUALITY(arrayVal, arrayVal_exp);
60  TEST_EQUALITY(arrayStreamVal, arrayVal_exp);
61  }
62 
63  {
64  std::string arrayString = "{ a, b, c, d }";
65  std::istringstream arrayStream(arrayString);
66  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
67  Array<std::string> arrayStreamVal;
68  arrayStream >> arrayStreamVal;
69  Array<std::string> arrayVal_exp = Teuchos::tuple<std::string>("a", "b", "c", "d" );
70  TEST_EQUALITY(arrayVal, arrayVal_exp);
71  TEST_EQUALITY(arrayStreamVal, arrayVal_exp);
72  }
73 
74  {
75  std::string arrayString = "{ (a), b, c, (d) }";
76  std::istringstream arrayStream(arrayString);
77  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
78  Array<std::string> arrayStreamVal;
79  arrayStream >> arrayStreamVal;
80  Array<std::string> arrayVal_exp = Teuchos::tuple<std::string>("(a)", "b", "c", "(d)" );
81  TEST_EQUALITY(arrayVal, arrayVal_exp);
82  TEST_EQUALITY(arrayStreamVal, arrayVal_exp);
83  }
84 
85  {
86  std::string arrayString = "{ (a ), b, c, (d ) }";
87  std::istringstream arrayStream(arrayString);
88  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
89  Array<std::string> arrayStreamVal;
90  arrayStream >> arrayStreamVal;
91  Array<std::string> arrayVal_exp = Teuchos::tuple<std::string>("(a )", "b", "c", "(d )" );
92  TEST_EQUALITY(arrayVal, arrayVal_exp);
93  TEST_EQUALITY(arrayStreamVal, arrayVal_exp);
94  }
95 
96  // This should work but does not. I should fix this!
97 // {
98 // Array<std::string> arrayVal = fromStringToArray<std::string>("{ {a}, 'b', {c }, d }");
99 // Array<std::string> arrayVal_exp = Teuchos::tuple<std::string>("{a}", "'b'", "{c }", "d" );
100 // TEST_EQUALITY(arrayVal, arrayVal_exp);
101 // }
102 
103 }
104 
105 
106 TEUCHOS_UNIT_TEST( Array, stringToArray_invalid )
107 {
108  TEST_THROW(fromStringToArray<std::string>("{ a, b, c"),
109  InvalidArrayStringRepresentation);
110  TEST_THROW(fromStringToArray<std::string>("a, b, c}"),
111  InvalidArrayStringRepresentation);
112  TEST_THROW(fromStringToArray<std::string>("a, b, c"),
113  InvalidArrayStringRepresentation);
114 }
115 
116 
117 TEUCHOS_UNIT_TEST( Array, stringToArray_string_hyphens )
118 {
119 
120  {
121  std::string arrayString="{-}";
122  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
123  Array<std::string> arrayVal_exp = tuple<std::string>("-");
124  TEST_EQUALITY(arrayVal, arrayVal_exp);
125  }
126 
127  {
128  std::string arrayString="{-,-}";
129  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
130  Array<std::string> arrayVal_exp = tuple<std::string>("-","-");
131  TEST_EQUALITY(arrayVal, arrayVal_exp);
132  }
133 
134  {
135  std::string arrayString="{-,1,-}";
136  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
137  Array<std::string> arrayVal_exp = tuple<std::string>("-","1","-");
138  TEST_EQUALITY(arrayVal, arrayVal_exp);
139  }
140 
141  {
142  std::string arrayString="{}";
143  Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString);
144  Array<std::string> arrayVal_exp;
145  TEST_EQUALITY(arrayVal, arrayVal_exp);
146  }
147 
148  {
149  std::string arrayString="{,}";
150  TEST_THROW(
151  [[maybe_unused]] Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString),
153  }
154 
155 }
156 
157 
158 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, defaultConstruct, T )
159 {
160  Array<T> a2;
161  TEST_EQUALITY_CONST( as<int>(a2.size()), 0 );
162  TEST_EQUALITY_CONST( as<int>(a2.empty()), true );
163  TEST_EQUALITY_CONST( a2.getRawPtr(), 0 );
164  TEST_EQUALITY_CONST( a2.getRawPtr(), a2.data() );
166  TEST_EQUALITY_CONST( getConst(a2).getRawPtr(), getConst(a2).data() );
167 }
168 
169 
170 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, sizedConstruct, T )
171 {
172  typedef typename Array<T>::size_type size_type;
173  Array<T> a(n);
174  TEST_EQUALITY_CONST( a.empty(), false );
175  TEST_EQUALITY( a.length(), n );
176  TEST_EQUALITY( as<int>(a.size()), n );
177  TEST_EQUALITY( a.getRawPtr(), &a[0] );
178  TEST_EQUALITY( a.getRawPtr(), a.data() );
179  TEST_EQUALITY( getConst(a).getRawPtr(), &getConst(a)[0] );
180  TEST_EQUALITY( getConst(a).getRawPtr(), getConst(a).data() );
181  TEST_COMPARE( a.max_size(), >=, as<size_type>(n) );
182  TEST_COMPARE( as<int>(a.capacity()), >=, n );
183 }
184 
185 
186 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, operatorBracket, T )
187 {
188  out << "\nTest that a[i] == i ... ";
189  Array<T> a = generateArray<T>(n);
190  bool local_success = true;
191  for( int i = 0; i < n; ++i ) {
192  TEST_ARRAY_ELE_EQUALITY( a, i, as<T>(i) );
193  }
194  if (local_success) out << "passed\n";
195  else success = false;
196 }
197 
198 
199 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constAt, T )
200 {
201  out << "\nTest that a.at(i) == i ...\n";
202  Array<T> a = generateArray<T>(n);
203  bool local_success = true;
204  for( int i = 0; i < n; ++i ) {
205  TEUCHOS_TEST_EQUALITY( a.at(i), as<T>(i), out, local_success );
206  }
207  if (local_success) out << "passed\n";
208  else success = false;
209 }
210 
211 
212 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayViewIter_before_block_end, T )
213 {
214  typedef typename ArrayView<T>::iterator iter_t;
216  iter_t iter = NIT::getNull();
217  {
218  ECHO(Array<T> a(n, as<T>(0)));
219  ECHO(ArrayView<T> av = a);
220  ECHO(iter = av.begin());
221  ECHO(av = null);
222  TEST_EQUALITY( *iter, a[0] );
223  // Above, the iterator to the ArrayView object is still valid even through
224  // the ArrayView object is was created from is gone now. This is just
225  // fine since the underlying data is still there in the original Array object.
226  iter = NIT::getNull();
227  }
228 }
229 
230 
231 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPArray_to_ArrayRCP_null, T )
232 {
233  const RCP<Array<T> > a_rcp = null;
234  const ArrayRCP<T> a_arcp = arcp(a_rcp);
235  TEST_ASSERT( a_arcp == null );
236 }
237 
238 
239 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPconstArray_to_ArrayRCP_null, T )
240 {
241  const RCP<const Array<T> > a_rcp = null;
242  const ArrayRCP<const T> a_arcp = arcp(a_rcp);
243  TEST_ASSERT( a_arcp == null );
244 }
245 
246 
247 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPArray_to_ArrayRCP, T )
248 {
249  const Array<T> a_const = generateArray<T>(n);
250  const RCP<Array<T> > a_rcp = Teuchos::rcp( new Array<T>(a_const));
251  const ArrayRCP<T> a_arcp = arcp(a_rcp);
252  TEST_COMPARE_ARRAYS( a_const(), a_arcp() );
253 }
254 
255 
256 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPconstArray_to_ArrayRCP, T )
257 {
258  const Array<T> a_const = generateArray<T>(n);
259  const RCP<const Array<T> > a_rcp = Teuchos::rcp( new Array<T>(a_const));
260  const ArrayRCP<const T> a_arcp = arcp(a_rcp);
261  TEST_COMPARE_ARRAYS( a_const(), a_arcp() );
262 }
263 
264 
265 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, Array_to_ArrayRCP_null, T )
266 {
267  Array<T> a;
268  const ArrayRCP<T> a_arcp = arcpFromArray(a);
269  TEST_ASSERT(a_arcp == null);
270 }
271 
272 
273 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constArray_to_ArrayRCP_null, T )
274 {
275  const Array<T> a;
276  const ArrayRCP<const T> a_arcp = arcpFromArray(a);
277  TEST_ASSERT(a_arcp == null);
278 }
279 
280 
281 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, Array_to_ArrayRCP, T )
282 {
283  Array<T> a = generateArray<T>(n);
284  const ArrayRCP<T> a_arcp = arcpFromArray(a);
285  TEST_COMPARE_ARRAYS( a(), a_arcp() );
286 }
287 
288 
289 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constArray_to_ArrayRCP, T )
290 {
291  const Array<T> a = generateArray<T>(n);
292  const ArrayRCP<const T> a_arcp = arcpFromArray(a);
293  TEST_COMPARE_ARRAYS( a(), a_arcp() );
294 }
295 
296 
297 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, Array_to_ArrayRCP_dangling, T )
298 {
299  ArrayRCP<T> a_arcp;
300  {
301  Array<T> a = generateArray<T>(n);
302  a_arcp = arcpFromArray(a);
303  }
304 #ifdef TEUCHOS_DEBUG
305  TEST_THROW(a_arcp[0], DanglingReferenceError);
306 #else
307  (void)out; (void)success;
308 #endif
309 }
310 
311 
312 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constArray_to_ArrayRCP_dangling, T )
313 {
314  ArrayRCP<const T> a_arcp;
315  {
316  const Array<T> a = generateArray<T>(n);
317  a_arcp = arcpFromArray(a);
318  }
319 #ifdef TEUCHOS_DEBUG
320  TEST_THROW(a_arcp[0], DanglingReferenceError);
321 #else
322  (void)out; (void)success;
323 #endif
324 }
325 
326 
327 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, toVector, T )
328 {
329  const Array<T> a = generateArray<T>(n);
330  const std::vector<T> v = a.toVector();
331  TEST_COMPARE_ARRAYS( a, v );
332 }
333 
334 
335 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, toVector_empty, T )
336 {
337  const Array<T> a;
338  const std::vector<T> v = a.toVector();
339  TEST_EQUALITY_CONST( as<int>(v.size()), 0 );
340 }
341 
342 
343 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, view_empty_func, T )
344 {
345  Array<T> a;
346  const ArrayView<T> av = a.view(0, 0);
347  TEST_ASSERT(is_null(av));
348 }
349 
350 
351 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, view_empty_operator, T )
352 {
353  Array<T> a;
354  const ArrayView<T> av = a(0, 0);
355  TEST_ASSERT(is_null(av));
356 }
357 
358 
359 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, view_const_empty, T )
360 {
361  const Array<T> a;
362  const ArrayView<const T> av = a.view(0, 0);
363  TEST_ASSERT(is_null(av));
364 }
365 
366 
367 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, implicit_to_ArrayView_empty, T )
368 {
369  Array<T> a;
370  const ArrayView<T> av = a();
371  TEST_ASSERT(is_null(av));
372 }
373 
374 
375 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, implicit_to_ArrayView_const_empty, T )
376 {
377  const Array<T> a;
378  const ArrayView<const T> av = a();
379  TEST_ASSERT(is_null(av));
380 }
381 
382 
383 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_implicit, T )
384 {
385  ArrayView<T> av;
386  { Array<T> a(n); av = a; }
387 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
388  TEST_THROW( av[0] = 0, DanglingReferenceError );
389 #else
390  (void)out; (void)success;
391 #endif
392 }
393 
394 
395 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_implicit_const, T )
396 {
397  ArrayView<const T> av;
398  { Array<T> a(n); av = getConst(a); }
399 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
400  TEST_THROW( av[0], DanglingReferenceError );
401 #else
402  (void)out; (void)success;
403 #endif
404 }
405 
406 
407 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_explicit, T )
408 {
409  ArrayView<T> av;
410  { Array<T> a(n); av = a(); }
411 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
412  TEST_THROW( av[0] = 0, DanglingReferenceError );
413 #else
414  (void)out; (void)success;
415 #endif
416 }
417 
418 
419 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_explicit_const, T )
420 {
421  ArrayView<const T> av;
422  { Array<T> a(n); av = getConst(a)(); }
423 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
424  TEST_THROW( av[0], DanglingReferenceError );
425 #else
426  (void)out; (void)success;
427 #endif
428 }
429 
430 
431 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_subview, T )
432 {
433  ArrayView<T> av;
434  { Array<T> a(n); av = a(0,1); }
435 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
436  TEST_THROW( av[0] = 0, DanglingReferenceError );
437 #else
438  (void)out; (void)success;
439 #endif
440 }
441 
442 
443 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_subview_const, T )
444 {
445  ArrayView<const T> av;
446  { Array<T> a(n); av = getConst(a)(0,1); }
447 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
448  TEST_THROW( av[0], DanglingReferenceError );
449 #else
450  (void)out; (void)success;
451 #endif
452 }
453 
454 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayViewIter, T )
455 {
456  typedef typename ArrayView<T>::iterator iter_t;
457  ECHO(Array<T> a(n));
458  ECHO(ArrayView<T> av = a);
459  ECHO(iter_t iter = av.begin());
460  ECHO(av = null);
461  ECHO(a.resize(0));
462 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
463  TEST_THROW( *iter = 0, DanglingReferenceError );
464 #else
465  (void)iter; (void)out; (void)success;
466 #endif
467 }
468 
469 
470 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayViewIter_const, T )
471 {
472  typedef typename ArrayView<const T>::iterator iter_t;
473  ECHO(Array<T> a(n));
474  ECHO(ArrayView<T> av = a);
475  ECHO(iter_t iter = av.begin());
476  ECHO(av = null);
477  ECHO(a.resize(0));
478 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
479  TEST_THROW( *iter, DanglingReferenceError );
480 #else
481  (void)iter; (void)out; (void)success;
482 #endif
483 }
484 
485 
486 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, erase_empty, T )
487 {
488  ECHO(std::vector<T> v);
489  TEST_NOTHROW(v.erase(v.begin(), v.end()));
490  ECHO(Array<T> a);
491  TEST_NOTHROW(a.erase(a.begin(), a.end()));
492 }
493 
494 
495 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, structuralChangeArrayView, T )
496 {
497  Array<T> a = generateArray<T>(n);
498  ArrayView<T> av = a;
499  a.push_back(a[0]);
500 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
501  TEST_THROW( av[0] = 0, DanglingReferenceError );
502 #else
503  (void)av; (void)out; (void)success;
504 #endif
505 }
506 
507 
508 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, structuralChangeArrayView_const, T )
509 {
510  Array<T> a = generateArray<T>(n);
511  ArrayView<const T> av = getConst(a);
512  a.push_back(a[0]);
513 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
514  TEST_THROW( av[0], DanglingReferenceError );
515 #else
516  (void)av; (void)out; (void)success;
517 #endif
518 }
519 
520 
521 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, initializerList, T )
522 {
523  const Array<T> a2{as<T>(1),as<T>(2),as<T>(3),as<T>(4)};
524  TEST_EQUALITY( a2.size(), 4);
525  for (typename Array<T>::size_type i=0; i < a2.size(); ++i) {
526  TEST_EQUALITY( a2[i], as<T>(i+1) );
527  }
528 }
529 
530 
531 //
532 // Instantiations
533 //
534 
535 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
536 
537 # define DEBUG_UNIT_TEST_GROUP( T )
538 
539 #else // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
540 
541 # define DEBUG_UNIT_TEST_GROUP( T )
542 
543 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
544 
545 
546 #define UNIT_TEST_GROUP( T ) \
547  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, defaultConstruct, T ) \
548  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, sizedConstruct, T ) \
549  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, operatorBracket, T ) \
550  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constAt, T ) \
551  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter_before_block_end, T ) \
552  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPArray_to_ArrayRCP_null, T ) \
553  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPconstArray_to_ArrayRCP_null, T ) \
554  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPArray_to_ArrayRCP, T ) \
555  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPconstArray_to_ArrayRCP, T ) \
556  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP_null, T ) \
557  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP_null, T ) \
558  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP, T ) \
559  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP, T ) \
560  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP_dangling, T ) \
561  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP_dangling, T ) \
562  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, toVector, T ) \
563  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, toVector_empty, T ) \
564  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, view_empty_func, T ) \
565  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, view_empty_operator, T ) \
566  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, implicit_to_ArrayView_empty, T ) \
567  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_implicit, T ) \
568  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_implicit_const, T ) \
569  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_explicit, T ) \
570  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_explicit_const, T ) \
571  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_subview, T ) \
572  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_subview_const, T ) \
573  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter, T ) \
574  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter_const, T ) \
575  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, erase_empty, T ) \
576  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, structuralChangeArrayView, T ) \
577  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, structuralChangeArrayView_const, T ) \
578  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, initializerList, T ) \
579  DEBUG_UNIT_TEST_GROUP( T )
580 
581 UNIT_TEST_GROUP(int)
582 UNIT_TEST_GROUP(float)
583 UNIT_TEST_GROUP(double)
584 
585 
586 } // 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...