35 #define TEST_EQUALITY_CONST( v1, v2 ) \
36 TEUCHOS_TEST_EQUALITY_CONST( v1, v2, out, success )
38 #define TEST_EQUALITY( v1, v2 ) \
39 TEUCHOS_TEST_EQUALITY( v1, v2, out, success )
41 #define TEST_ITER_EQUALITY( iter1, iter2 ) \
42 TEUCHOS_TEST_ITER_EQUALITY( iter1, iter2, out, success )
44 #define TEST_ARRAY_ELE_EQUALITY( a, i, val ) \
45 TEUCHOS_TEST_ARRAY_ELE_EQUALITY( a, i, val, false, out, local_success )
47 #define TEST_COMPARE( v1, comp, v2 ) \
48 TEUCHOS_TEST_COMPARE( v1, comp, v2, out, success )
50 #define TEST_COMPARE_ARRAYS( a1, a2 ) \
52 const bool result = compareArrays(a1,#a1,a2,#a2,out); \
53 if (!result) success = false; \
56 #define TEST_THROW( code, ExceptType ) \
57 TEUCHOS_TEST_THROW( code, ExceptType, out, success )
59 #define TEST_NOTHROW( code ) \
60 TEUCHOS_TEST_NOTHROW( code, out, success )
68 template<
class T,
int N>
75 using Teuchos::arrayView;
76 using Teuchos::arrayViewFromVector;
77 using Teuchos::outArg;
82 typedef typename ArrayView<T>::size_type size_type;
94 const size_type arbitrarySizeTypeValue = 0;
95 (void) arbitrarySizeTypeValue;
101 <<
"\n*** Testing "<<TypeNameTraits<Tuple<T,N> >::name()<<
" of size = "<<N
107 out <<
"\nA) Initial setup testing ...\n\n";
112 for(
int i = 0; i < N; ++i )
116 out <<
"\nTest that t[i] == i ... ";
117 const ArrayView<const T> cav2 = t;
118 bool local_success =
true;
119 for(
int i = 0; i < N; ++i ) {
122 if (local_success) out <<
"passed\n";
123 else success =
false;
128 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
129 Tuple<T,n> tn = tuple<T>(0);
131 out <<
"Test that tn[i] == i ... ";
132 bool local_success =
true;
133 for(
int i = 0; i <
n; ++i ) {
136 if (local_success) out <<
"passed\n";
137 else success =
false;
142 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
143 Tuple<T,n> tn = tuple<T>(0,1);
145 out <<
"Test that tn[i] == i ... ";
146 bool local_success =
true;
147 for(
int i = 0; i <
n; ++i ) {
150 if (local_success) out <<
"passed\n";
151 else success =
false;
156 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
157 Tuple<T,n> tn = tuple<T>(0,1,2);
159 out <<
"Test that tn[i] == i ... ";
160 bool local_success =
true;
161 for(
int i = 0; i <
n; ++i ) {
164 if (local_success) out <<
"passed\n";
165 else success =
false;
170 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
171 Tuple<T,n> tn = tuple<T>(0,1,2,3);
173 out <<
"Test that tn[i] == i ... ";
174 bool local_success =
true;
175 for(
int i = 0; i <
n; ++i ) {
178 if (local_success) out <<
"passed\n";
179 else success =
false;
184 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
185 Tuple<T,n> tn = tuple<T>(0,1,2,3,4);
187 out <<
"Test that tn[i] == i ... ";
188 bool local_success =
true;
189 for(
int i = 0; i <
n; ++i ) {
192 if (local_success) out <<
"passed\n";
193 else success =
false;
198 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
199 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5);
201 out <<
"Test that tn[i] == i ... ";
202 bool local_success =
true;
203 for(
int i = 0; i <
n; ++i ) {
206 if (local_success) out <<
"passed\n";
207 else success =
false;
212 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
213 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6);
215 out <<
"Test that tn[i] == i ... ";
216 bool local_success =
true;
217 for(
int i = 0; i <
n; ++i ) {
220 if (local_success) out <<
"passed\n";
221 else success =
false;
226 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
227 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7);
229 out <<
"Test that tn[i] == i ... ";
230 bool local_success =
true;
231 for(
int i = 0; i <
n; ++i ) {
234 if (local_success) out <<
"passed\n";
235 else success =
false;
240 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
241 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8);
243 out <<
"Test that tn[i] == i ... ";
244 bool local_success =
true;
245 for(
int i = 0; i <
n; ++i ) {
248 if (local_success) out <<
"passed\n";
249 else success =
false;
254 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
255 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9);
257 out <<
"Test that tn[i] == i ... ";
258 bool local_success =
true;
259 for(
int i = 0; i <
n; ++i ) {
262 if (local_success) out <<
"passed\n";
263 else success =
false;
268 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
269 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10);
271 out <<
"Test that tn[i] == i ... ";
272 bool local_success =
true;
273 for(
int i = 0; i <
n; ++i ) {
276 if (local_success) out <<
"passed\n";
277 else success =
false;
282 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
283 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10,11);
285 out <<
"Test that tn[i] == i ... ";
286 bool local_success =
true;
287 for(
int i = 0; i <
n; ++i ) {
290 if (local_success) out <<
"passed\n";
291 else success =
false;
296 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
297 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10,11,12);
299 out <<
"Test that tn[i] == i ... ";
300 bool local_success =
true;
301 for(
int i = 0; i <
n; ++i ) {
304 if (local_success) out <<
"passed\n";
305 else success =
false;
310 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
311 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10,11,12,13);
313 out <<
"Test that tn[i] == i ... ";
314 bool local_success =
true;
315 for(
int i = 0; i <
n; ++i ) {
318 if (local_success) out <<
"passed\n";
319 else success =
false;
324 out <<
"\nTest Tuple<T,"<<n<<
"> = tuple(...)\n";
325 Tuple<T,n> tn = tuple<T>(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14);
327 out <<
"Test that tn[i] == i ... ";
328 bool local_success =
true;
329 for(
int i = 0; i <
n; ++i ) {
332 if (local_success) out <<
"passed\n";
333 else success =
false;
337 out <<
"\nTest constructing Array<const T> from Tuple<T,N> ...\n";
338 const ArrayView<const T> av2 = t;
353 int main(
int argc,
char* argv[] ) {
371 CommandLineProcessor clp(
false);
373 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
375 if ( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) {
376 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
384 result = testTuple<int,N>(*out);
385 if (!result) success =
false;
387 result = testTuple<float,N>(*out);
388 if (!result) success =
false;
390 result = testTuple<double,N>(*out);
391 if (!result) success =
false;
393 result = testTuple<std::complex<double> ,N>(*out);
394 if (!result) success =
false;
400 *out <<
"\nEnd Result: TEST PASSED" << std::endl;
402 *out <<
"\nEnd Result: TEST FAILED" << std::endl;
404 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.