67 #define TEST_EQUALITY_CONST( v1, v2 ) \
68 TEUCHOS_TEST_EQUALITY_CONST( v1, v2, out, success )
70 #define TEST_EQUALITY( v1, v2 ) \
71 TEUCHOS_TEST_EQUALITY( v1, v2, out, success )
73 #define TEST_ITER_EQUALITY( iter1, iter2 ) \
74 TEUCHOS_TEST_ITER_EQUALITY( iter1, iter2, out, success )
76 #define TEST_ARRAY_ELE_EQUALITY( a, i, val ) \
77 TEUCHOS_TEST_ARRAY_ELE_EQUALITY( a, i, val, false, out, local_success )
79 #define TEST_COMPARE( v1, comp, v2 ) \
80 TEUCHOS_TEST_COMPARE( v1, comp, v2, out, success )
82 #define TEST_COMPARE_ARRAYS( a1, a2 ) \
84 const bool result = compareArrays(a1,#a1,a2,#a2,out); \
85 if (!result) success = false; \
88 #define TEST_THROW( code, ExceptType ) \
89 TEUCHOS_TEST_THROW( code, ExceptType, out, success )
91 #define TEST_NOTHROW( code ) \
92 TEUCHOS_TEST_NOTHROW( code, out, success )
100 template<
class T,
int N>
105 using Teuchos::tuple;
107 using Teuchos::arrayView;
108 using Teuchos::arrayViewFromVector;
109 using Teuchos::outArg;
114 typedef typename ArrayView<T>::size_type size_type;
126 const size_type arbitrarySizeTypeValue = 0;
127 (void) arbitrarySizeTypeValue;
133 <<
"\n*** Testing "<<TypeNameTraits<Tuple<T,N> >::name()<<
" of size = "<<N
139 out <<
"\nA) Initial setup testing ...\n\n";
144 for(
int i = 0; i < N; ++i )
148 out <<
"\nTest that t[i] == i ... ";
149 const ArrayView<const T> cav2 = t;
150 bool local_success =
true;
151 for(
int i = 0; i < N; ++i ) {
154 if (local_success) out <<
"passed\n";
155 else success =
false;
160 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
161 Tuple<T,n> tn = tuple<T>(0);
163 out <<
"Test that tn[i] == i ... ";
164 bool local_success =
true;
165 for(
int i = 0; i <
n; ++i ) {
168 if (local_success) out <<
"passed\n";
169 else success =
false;
174 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
175 Tuple<T,n> tn = tuple<T>(0,1);
177 out <<
"Test that tn[i] == i ... ";
178 bool local_success =
true;
179 for(
int i = 0; i <
n; ++i ) {
182 if (local_success) out <<
"passed\n";
183 else success =
false;
188 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
189 Tuple<T,n> tn = tuple<T>(0,1,2);
191 out <<
"Test that tn[i] == i ... ";
192 bool local_success =
true;
193 for(
int i = 0; i <
n; ++i ) {
196 if (local_success) out <<
"passed\n";
197 else success =
false;
202 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
203 Tuple<T,n> tn = tuple<T>(0,1,2,3);
205 out <<
"Test that tn[i] == i ... ";
206 bool local_success =
true;
207 for(
int i = 0; i <
n; ++i ) {
210 if (local_success) out <<
"passed\n";
211 else success =
false;
216 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
217 Tuple<T,n> tn = tuple<T>(0,1,2,3,4);
219 out <<
"Test that tn[i] == i ... ";
220 bool local_success =
true;
221 for(
int i = 0; i <
n; ++i ) {
224 if (local_success) out <<
"passed\n";
225 else success =
false;
230 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
231 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5);
233 out <<
"Test that tn[i] == i ... ";
234 bool local_success =
true;
235 for(
int i = 0; i <
n; ++i ) {
238 if (local_success) out <<
"passed\n";
239 else success =
false;
244 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
245 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6);
247 out <<
"Test that tn[i] == i ... ";
248 bool local_success =
true;
249 for(
int i = 0; i <
n; ++i ) {
252 if (local_success) out <<
"passed\n";
253 else success =
false;
258 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
259 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7);
261 out <<
"Test that tn[i] == i ... ";
262 bool local_success =
true;
263 for(
int i = 0; i <
n; ++i ) {
266 if (local_success) out <<
"passed\n";
267 else success =
false;
272 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
273 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8);
275 out <<
"Test that tn[i] == i ... ";
276 bool local_success =
true;
277 for(
int i = 0; i <
n; ++i ) {
280 if (local_success) out <<
"passed\n";
281 else success =
false;
286 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
287 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9);
289 out <<
"Test that tn[i] == i ... ";
290 bool local_success =
true;
291 for(
int i = 0; i <
n; ++i ) {
294 if (local_success) out <<
"passed\n";
295 else success =
false;
300 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
301 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10);
303 out <<
"Test that tn[i] == i ... ";
304 bool local_success =
true;
305 for(
int i = 0; i <
n; ++i ) {
308 if (local_success) out <<
"passed\n";
309 else success =
false;
314 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
315 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10,11);
317 out <<
"Test that tn[i] == i ... ";
318 bool local_success =
true;
319 for(
int i = 0; i <
n; ++i ) {
322 if (local_success) out <<
"passed\n";
323 else success =
false;
328 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
329 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10,11,12);
331 out <<
"Test that tn[i] == i ... ";
332 bool local_success =
true;
333 for(
int i = 0; i <
n; ++i ) {
336 if (local_success) out <<
"passed\n";
337 else success =
false;
342 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
343 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10,11,12,13);
345 out <<
"Test that tn[i] == i ... ";
346 bool local_success =
true;
347 for(
int i = 0; i <
n; ++i ) {
350 if (local_success) out <<
"passed\n";
351 else success =
false;
356 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
357 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14);
359 out <<
"Test that tn[i] == i ... ";
360 bool local_success =
true;
361 for(
int i = 0; i <
n; ++i ) {
364 if (local_success) out <<
"passed\n";
365 else success =
false;
369 out <<
"\nTest constructing Array<const T> from Tuple<T,N> ...\n";
370 const ArrayView<const T> av2 = t;
385 int main(
int argc,
char* argv[] ) {
403 CommandLineProcessor clp(
false);
405 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
407 if ( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) {
408 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
416 result = testTuple<int,N>(*out);
417 if (!result) success =
false;
419 result = testTuple<float,N>(*out);
420 if (!result) success =
false;
422 result = testTuple<double,N>(*out);
423 if (!result) success =
false;
425 result = testTuple<std::complex<double> ,N>(*out);
426 if (!result) success =
false;
432 *out <<
"\nEnd Result: TEST PASSED" << std::endl;
434 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
436 return ( success ? 0 : 1 );
#define TEST_ARRAY_ELE_EQUALITY(a, i, val)
const T & getConst(T &t)
Return a constant reference to an object given a non-const reference.
Tabbing class for helping to create formated, indented output for a basic_FancyOStream object...
Initialize, finalize, and query the global MPI session.
#define TEST_EQUALITY_CONST(v1, v2)
Statically sized simple array (tuple) class.
#define TEST_COMPARE_ARRAYS(a1, a2)
std::ostream subclass that performs the magic of indenting data sent to an std::ostream object among ...
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
std::string Teuchos_Version()
Base traits class for getting a properly initialized null pointer.
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
int main(int argc, char *argv[])
Utilities to make writing tests easier.
Default traits class that just returns typeid(T).name().
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Basic command line parser for input from (argc,argv[])
bool testTuple(Teuchos::FancyOStream &out)
Smart reference counting pointer class for automatic garbage collection.
RCP< basic_FancyOStream< CharT, Traits > > tab(const RCP< basic_FancyOStream< CharT, Traits > > &out, const int tabs=1, const std::basic_string< CharT, Traits > linePrefix="")
Create a tab for an RCP-wrapped basic_FancyOStream object to cause the indentation of all output auto...
Definition of Teuchos::as, for conversions between types.
Class that helps parse command line input arguments from (argc,argv[]) and set options.