Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
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(Array<std::string> arrayVal = fromStringToArray<std::string>(arrayString),
186  }
187 
188 }
189 
190 
191 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, defaultConstruct, T )
192 {
193  Array<T> a2;
194  TEST_EQUALITY_CONST( as<int>(a2.size()), 0 );
195  TEST_EQUALITY_CONST( as<int>(a2.empty()), true );
196  TEST_EQUALITY_CONST( a2.getRawPtr(), 0 );
198 }
199 
200 
201 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, sizedConstruct, T )
202 {
203  typedef typename Array<T>::size_type size_type;
204  Array<T> a(n);
205  TEST_EQUALITY_CONST( a.empty(), false );
206  TEST_EQUALITY( a.length(), n );
207  TEST_EQUALITY( as<int>(a.size()), n );
208  TEST_EQUALITY( a.getRawPtr(), &a[0] );
209  TEST_EQUALITY( getConst(a).getRawPtr(), &getConst(a)[0] );
210  TEST_COMPARE( a.max_size(), >=, as<size_type>(n) );
211  TEST_COMPARE( as<int>(a.capacity()), >=, n );
212 }
213 
214 
215 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, operatorBracket, T )
216 {
217  out << "\nTest that a[i] == i ... ";
218  Array<T> a = generateArray<T>(n);
219  bool local_success = true;
220  for( int i = 0; i < n; ++i ) {
221  TEST_ARRAY_ELE_EQUALITY( a, i, as<T>(i) );
222  }
223  if (local_success) out << "passed\n";
224  else success = false;
225 }
226 
227 
228 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constAt, T )
229 {
230  out << "\nTest that a.at(i) == i ...\n";
231  Array<T> a = generateArray<T>(n);
232  bool local_success = true;
233  for( int i = 0; i < n; ++i ) {
234  TEUCHOS_TEST_EQUALITY( a.at(i), as<T>(i), out, local_success );
235  }
236  if (local_success) out << "passed\n";
237  else success = false;
238 }
239 
240 
241 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayViewIter_before_block_end, T )
242 {
243  typedef typename ArrayView<T>::iterator iter_t;
245  iter_t iter = NIT::getNull();
246  {
247  ECHO(Array<T> a(n, as<T>(0)));
248  ECHO(ArrayView<T> av = a);
249  ECHO(iter = av.begin());
250  ECHO(av = null);
251  TEST_EQUALITY( *iter, a[0] );
252  // Above, the iterator to the ArrayView object is still valid even through
253  // the ArrayView object is was created from is gone now. This is just
254  // fine since the underlying data is still there in the original Array object.
255  iter = NIT::getNull();
256  }
257 }
258 
259 
260 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPArray_to_ArrayRCP_null, T )
261 {
262  const RCP<Array<T> > a_rcp = null;
263  const ArrayRCP<T> a_arcp = arcp(a_rcp);
264  TEST_ASSERT( a_arcp == null );
265 }
266 
267 
268 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPconstArray_to_ArrayRCP_null, T )
269 {
270  const RCP<const Array<T> > a_rcp = null;
271  const ArrayRCP<const T> a_arcp = arcp(a_rcp);
272  TEST_ASSERT( a_arcp == null );
273 }
274 
275 
276 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPArray_to_ArrayRCP, T )
277 {
278  const Array<T> a_const = generateArray<T>(n);
279  const RCP<Array<T> > a_rcp = Teuchos::rcp( new Array<T>(a_const));
280  const ArrayRCP<T> a_arcp = arcp(a_rcp);
281  TEST_COMPARE_ARRAYS( a_const(), a_arcp() );
282 }
283 
284 
285 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, RCPconstArray_to_ArrayRCP, T )
286 {
287  const Array<T> a_const = generateArray<T>(n);
288  const RCP<const Array<T> > a_rcp = Teuchos::rcp( new Array<T>(a_const));
289  const ArrayRCP<const T> a_arcp = arcp(a_rcp);
290  TEST_COMPARE_ARRAYS( a_const(), a_arcp() );
291 }
292 
293 
294 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, Array_to_ArrayRCP_null, T )
295 {
296  Array<T> a;
297  const ArrayRCP<T> a_arcp = arcpFromArray(a);
298  TEST_ASSERT(a_arcp == null);
299 }
300 
301 
302 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constArray_to_ArrayRCP_null, T )
303 {
304  const Array<T> a;
305  const ArrayRCP<const T> a_arcp = arcpFromArray(a);
306  TEST_ASSERT(a_arcp == null);
307 }
308 
309 
310 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, Array_to_ArrayRCP, T )
311 {
312  Array<T> a = generateArray<T>(n);
313  const ArrayRCP<T> a_arcp = arcpFromArray(a);
314  TEST_COMPARE_ARRAYS( a(), a_arcp() );
315 }
316 
317 
318 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constArray_to_ArrayRCP, T )
319 {
320  const Array<T> a = generateArray<T>(n);
321  const ArrayRCP<const T> a_arcp = arcpFromArray(a);
322  TEST_COMPARE_ARRAYS( a(), a_arcp() );
323 }
324 
325 
326 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, Array_to_ArrayRCP_dangling, T )
327 {
328  ArrayRCP<T> a_arcp;
329  {
330  Array<T> a = generateArray<T>(n);
331  a_arcp = arcpFromArray(a);
332  }
333 #ifdef TEUCHOS_DEBUG
334  TEST_THROW(a_arcp[0], DanglingReferenceError);
335 #endif
336 }
337 
338 
339 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, constArray_to_ArrayRCP_dangling, T )
340 {
341  ArrayRCP<const T> a_arcp;
342  {
343  const Array<T> a = generateArray<T>(n);
344  a_arcp = arcpFromArray(a);
345  }
346 #ifdef TEUCHOS_DEBUG
347  TEST_THROW(a_arcp[0], DanglingReferenceError);
348 #endif
349 }
350 
351 
352 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, toVector, T )
353 {
354  const Array<T> a = generateArray<T>(n);
355  const std::vector<T> v = a.toVector();
356  TEST_COMPARE_ARRAYS( a, v );
357 }
358 
359 
360 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, toVector_empty, T )
361 {
362  const Array<T> a;
363  const std::vector<T> v = a.toVector();
364  TEST_EQUALITY_CONST( as<int>(v.size()), 0 );
365 }
366 
367 
368 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, view_empty_func, T )
369 {
370  Array<T> a;
371  const ArrayView<T> av = a.view(0, 0);
372  TEST_ASSERT(is_null(av));
373 }
374 
375 
376 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, view_empty_operator, T )
377 {
378  Array<T> a;
379  const ArrayView<T> av = a(0, 0);
380  TEST_ASSERT(is_null(av));
381 }
382 
383 
384 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, view_const_empty, T )
385 {
386  const Array<T> a;
387  const ArrayView<const T> av = a.view(0, 0);
388  TEST_ASSERT(is_null(av));
389 }
390 
391 
392 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, implicit_to_ArrayView_empty, T )
393 {
394  Array<T> a;
395  const ArrayView<T> av = a();
396  TEST_ASSERT(is_null(av));
397 }
398 
399 
400 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, implicit_to_ArrayView_const_empty, T )
401 {
402  const Array<T> a;
403  const ArrayView<const T> av = a();
404  TEST_ASSERT(is_null(av));
405 }
406 
407 
408 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_implicit, T )
409 {
410  ArrayView<T> av;
411  { Array<T> a(n); av = a; }
412 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
413  TEST_THROW( av[0] = 0, DanglingReferenceError );
414 #endif
415 }
416 
417 
418 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_implicit_const, T )
419 {
420  ArrayView<const T> av;
421  { Array<T> a(n); av = getConst(a); }
422 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
423  TEST_THROW( av[0], DanglingReferenceError );
424 #endif
425 }
426 
427 
428 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_explicit, T )
429 {
430  ArrayView<T> av;
431  { Array<T> a(n); av = a(); }
432 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
433  TEST_THROW( av[0] = 0, DanglingReferenceError );
434 #endif
435 }
436 
437 
438 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_explicit_const, T )
439 {
440  ArrayView<const T> av;
441  { Array<T> a(n); av = getConst(a)(); }
442 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
443  TEST_THROW( av[0], DanglingReferenceError );
444 #endif
445 }
446 
447 
448 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_subview, T )
449 {
450  ArrayView<T> av;
451  { Array<T> a(n); av = a(0,1); }
452 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
453  TEST_THROW( av[0] = 0, DanglingReferenceError );
454 #endif
455 }
456 
457 
458 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayView_subview_const, T )
459 {
460  ArrayView<const T> av;
461  { Array<T> a(n); av = getConst(a)(0,1); }
462 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
463  TEST_THROW( av[0], DanglingReferenceError );
464 #endif
465 }
466 
467 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayViewIter, T )
468 {
469  typedef typename ArrayView<T>::iterator iter_t;
470  ECHO(Array<T> a(n));
471  ECHO(ArrayView<T> av = a);
472  ECHO(iter_t iter = av.begin());
473  ECHO(av = null);
474  ECHO(a.resize(0));
475 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
476  TEST_THROW( *iter = 0, DanglingReferenceError );
477 #else
478  (void)iter;
479 #endif
480 }
481 
482 
483 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, danglingArrayViewIter_const, T )
484 {
485  typedef typename ArrayView<const T>::iterator iter_t;
486  ECHO(Array<T> a(n));
487  ECHO(ArrayView<T> av = a);
488  ECHO(iter_t iter = av.begin());
489  ECHO(av = null);
490  ECHO(a.resize(0));
491 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
492  TEST_THROW( *iter, DanglingReferenceError );
493 #else
494  (void)iter;
495 #endif
496 }
497 
498 
499 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, erase_empty, T )
500 {
501  ECHO(std::vector<T> v);
502  TEST_NOTHROW(v.erase(v.begin(), v.end()));
503  ECHO(Array<T> a);
504  TEST_NOTHROW(a.erase(a.begin(), a.end()));
505 }
506 
507 
508 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, structuralChangeArrayView, T )
509 {
510  Array<T> a = generateArray<T>(n);
511  ArrayView<T> av = a;
512  a.push_back(a[0]);
513 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
514  TEST_THROW( av[0] = 0, DanglingReferenceError );
515 #endif
516 }
517 
518 
519 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( Array, structuralChangeArrayView_const, T )
520 {
521  Array<T> a = generateArray<T>(n);
522  ArrayView<const T> av = getConst(a);
523  a.push_back(a[0]);
524 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
525  TEST_THROW( av[0], DanglingReferenceError );
526 #endif
527 }
528 
529 
530 //
531 // Instantiations
532 //
533 
534 #ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
535 
536 # define DEBUG_UNIT_TEST_GROUP( T )
537 
538 #else // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
539 
540 # define DEBUG_UNIT_TEST_GROUP( T )
541 
542 #endif // HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
543 
544 
545 #define UNIT_TEST_GROUP( T ) \
546  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, defaultConstruct, T ) \
547  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, sizedConstruct, T ) \
548  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, operatorBracket, T ) \
549  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constAt, T ) \
550  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter_before_block_end, T ) \
551  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPArray_to_ArrayRCP_null, T ) \
552  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPconstArray_to_ArrayRCP_null, T ) \
553  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPArray_to_ArrayRCP, T ) \
554  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPconstArray_to_ArrayRCP, T ) \
555  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP_null, T ) \
556  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP_null, T ) \
557  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP, T ) \
558  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP, T ) \
559  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP_dangling, T ) \
560  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP_dangling, T ) \
561  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, toVector, T ) \
562  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, toVector_empty, T ) \
563  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, view_empty_func, T ) \
564  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, view_empty_operator, T ) \
565  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, implicit_to_ArrayView_empty, T ) \
566  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_implicit, T ) \
567  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_implicit_const, T ) \
568  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_explicit, T ) \
569  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_explicit_const, T ) \
570  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_subview, T ) \
571  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_subview_const, T ) \
572  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter, T ) \
573  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter_const, T ) \
574  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, erase_empty, T ) \
575  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, structuralChangeArrayView, T ) \
576  TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, structuralChangeArrayView_const, T ) \
577  DEBUG_UNIT_TEST_GROUP( T )
578 
579 UNIT_TEST_GROUP(int)
580 UNIT_TEST_GROUP(float)
581 UNIT_TEST_GROUP(double)
582 
583 
584 } // 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;>=", "!=", 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<Array<T> > object as an ArrayRCP<T> 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<T> object as a non-owning ArrayRCP<T> 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...