79 std::string(
"Array(double)"));
87 std::string arrayString=
"{}";
88 std::istringstream arrayStream(arrayString);
91 arrayStream >> arrayStreamVal;
98 std::string arrayString =
"{ a, b, c, d }";
99 std::istringstream arrayStream(arrayString);
102 arrayStream >> arrayStreamVal;
109 std::string arrayString =
"{ (a), b, c, (d) }";
110 std::istringstream arrayStream(arrayString);
113 arrayStream >> arrayStreamVal;
120 std::string arrayString =
"{ (a ), b, c, (d ) }";
121 std::istringstream arrayStream(arrayString);
124 arrayStream >> arrayStreamVal;
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);
155 std::string arrayString=
"{-}";
162 std::string arrayString=
"{-,-}";
169 std::string arrayString=
"{-,1,-}";
176 std::string arrayString=
"{}";
183 std::string arrayString=
"{,}";
221 out <<
"\nTest that a[i] == i ... ";
223 bool local_success =
true;
224 for(
int i = 0; i <
n; ++i ) {
227 if (local_success) out <<
"passed\n";
228 else success =
false;
234 out <<
"\nTest that a.at(i) == i ...\n";
236 bool local_success =
true;
237 for(
int i = 0; i <
n; ++i ) {
240 if (local_success) out <<
"passed\n";
241 else success =
false;
247 typedef typename ArrayView<T>::iterator iter_t;
249 iter_t iter = NIT::getNull();
252 ECHO(ArrayView<T> av = a);
253 ECHO(iter = av.begin());
259 iter = NIT::getNull();
267 const ArrayRCP<T> a_arcp =
arcp(a_rcp);
275 const ArrayRCP<const T> a_arcp =
arcp(a_rcp);
282 const Array<T> a_const = generateArray<T>(n);
284 const ArrayRCP<T> a_arcp =
arcp(a_rcp);
291 const Array<T> a_const = generateArray<T>(n);
293 const ArrayRCP<const T> a_arcp =
arcp(a_rcp);
324 const Array<T> a = generateArray<T>(n);
338 TEST_THROW(a_arcp[0], DanglingReferenceError);
345 ArrayRCP<const T> a_arcp;
347 const Array<T> a = generateArray<T>(n);
351 TEST_THROW(a_arcp[0], DanglingReferenceError);
358 const Array<T> a = generateArray<T>(n);
359 const std::vector<T> v = a.
toVector();
367 const std::vector<T> v = a.
toVector();
375 const ArrayView<T> av = a.
view(0, 0);
383 const ArrayView<T> av = a(0, 0);
391 const ArrayView<const T> av = a.
view(0, 0);
399 const ArrayView<T> av = a();
407 const ArrayView<const T> av = a();
416#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
417 TEST_THROW( av[0] = 0, DanglingReferenceError );
424 ArrayView<const T> av;
426#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
436#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
437 TEST_THROW( av[0] = 0, DanglingReferenceError );
444 ArrayView<const T> av;
446#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
456#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
457 TEST_THROW( av[0] = 0, DanglingReferenceError );
464 ArrayView<const T> av;
466#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
473 typedef typename ArrayView<T>::iterator iter_t;
475 ECHO(ArrayView<T> av = a);
476 ECHO(iter_t iter = av.begin());
479#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
480 TEST_THROW( *iter = 0, DanglingReferenceError );
489 typedef typename ArrayView<const T>::iterator iter_t;
491 ECHO(ArrayView<T> av = a);
492 ECHO(iter_t iter = av.begin());
495#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
505 ECHO(std::vector<T> v);
517#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
518 TEST_THROW( av[0] = 0, DanglingReferenceError );
526 ArrayView<const T> av =
getConst(a);
528#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
538#ifdef HAVE_TEUCHOS_ARRAY_BOUNDSCHECK
540# define DEBUG_UNIT_TEST_GROUP( T )
544# define DEBUG_UNIT_TEST_GROUP( T )
549#define UNIT_TEST_GROUP( T ) \
550 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, defaultConstruct, T ) \
551 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, sizedConstruct, T ) \
552 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, operatorBracket, T ) \
553 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constAt, T ) \
554 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter_before_block_end, T ) \
555 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPArray_to_ArrayRCP_null, T ) \
556 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPconstArray_to_ArrayRCP_null, T ) \
557 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPArray_to_ArrayRCP, T ) \
558 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, RCPconstArray_to_ArrayRCP, T ) \
559 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP_null, T ) \
560 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP_null, T ) \
561 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP, T ) \
562 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP, T ) \
563 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, Array_to_ArrayRCP_dangling, T ) \
564 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, constArray_to_ArrayRCP_dangling, T ) \
565 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, toVector, T ) \
566 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, toVector_empty, T ) \
567 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, view_empty_func, T ) \
568 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, view_empty_operator, T ) \
569 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, implicit_to_ArrayView_empty, T ) \
570 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_implicit, T ) \
571 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_implicit_const, T ) \
572 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_explicit, T ) \
573 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_explicit_const, T ) \
574 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_subview, T ) \
575 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayView_subview_const, T ) \
576 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter, T ) \
577 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, danglingArrayViewIter_const, T ) \
578 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, erase_empty, T ) \
579 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, structuralChangeArrayView, T ) \
580 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( Array, structuralChangeArrayView_const, T ) \
581 DEBUG_UNIT_TEST_GROUP( T )
#define UNIT_TEST_GROUP(T)
#define TEST_ASSERT(v1)
Assert the given statement is true.
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
#define TEST_EQUALITY(v1, v2)
Assert the equality of v1 and v2.
#define TEST_NOTHROW(code)
Asserr that the statement 'code' does not thrown any excpetions.
#define TEST_ARRAY_ELE_EQUALITY(a, i, val)
Assert that a[i] == val.
#define TEST_THROW(code, ExceptType)
Assert that the statement 'code' throws the exception 'ExceptType' (otherwise the test fails).
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
#define TEST_COMPARE(v1, comp, v2)
Assert that v1 comp v2 (where comp = '==', '>=", "!=", etc).
#define ECHO(statement)
Echo the given statement before it is executed.
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
Test that two values are equal.
#define TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(TEST_GROUP, TEST_NAME, TYPE)
Macro for defining a templated unit test with one template parameter.
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
T * getRawPtr()
Return a raw pointer to beginning of array or NULL if unsized.
Ordinal size_type
The type of Array sizes and capacities.
reference at(size_type i)
ArrayView< T > view(size_type offset, size_type size)
Return non-const view of a contiguous range of elements.
void push_back(const value_type &x)
std::vector< T > toVector() const
Explicit copy conversion to an std::vector.
T * data()
Return a raw pointer to beginning of array.
void resize(size_type new_size, const value_type &x=value_type())
iterator erase(iterator position)
Smart reference counting pointer class for automatic garbage collection.
Reference-counted smart pointer for managing arrays.
ArrayRCP< T > arcpFromArray(Array< T > &a)
Wrap an Array<T> object as a non-owning ArrayRCP<T> object.
ArrayRCP< T > arcp(const RCP< Array< T > > &v)
Wrap an RCP<Array<T> > object as an ArrayRCP<T> object.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
Array< T > fromStringToArray(const std::string &arrayStr)
Converts from std::string representation (as created by toString()) back into the array object.
Dangling reference error exception class.
Base traits class for getting a properly initialized null pointer.
Smart reference counting pointer class for automatic garbage collection.
Tuple< T, 1 > tuple(const T &a)
Create a Tuple<T,1>.
Default traits class that just returns typeid(T).name().
static std::string trimWhiteSpace(const std::string &str)
Trim whitespace from beginning and end of std::string.
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
bool is_null(const boost::shared_ptr< T > &p)
Returns true if p.get()==NULL.
Teuchos::Array< T > generateArray(const int n_in)
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
RawPointerConversionTraits< Container >::Ptr_t getRawPtr(const Container &c)
const T & getConst(T &t)
Return a constant reference to an object given a non-const reference.