Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Array_UnitTest_helpers.hpp
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_Array.hpp"
12 #include "Teuchos_getConst.hpp"
13 #include "Teuchos_as.hpp"
14 
15 
16 namespace ArrayUnitTestHelpers {
17 
18 
19 extern int n;
20 
21 
22 template<class T>
24 {
25  using Teuchos::as;
26  Teuchos::Array<T> a(n_in);
27  for( int i = 0; i < n_in; ++i )
28  a[i] = as<T>(i); // tests non-const operator[](i)
29  return a;
30 }
31 
32 
33 } // namespace ArrayUnitTestHelpers
Unit testing support.
Teuchos::Array< T > generateArray(const int n_in)
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
Templated array class derived from the STL std::vector.
Definition of Teuchos::as, for conversions between types.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...