46 int main(
int argc,
char* argv[] )
52 bool parse_successful =
true;
59 CommandLineProcessor clp(
false,
false);
61 double rel_proc_speed = 1e-5;
62 clp.setOption(
"rel-proc-speed", &rel_proc_speed,
"Relative processor speed (try around 1.0 for timing)." );
65 clp.setOption(
"size", &
size,
"Size of memory blocks created." );
67 size_t sizetOption = 10;
68 clp.setOption(
"sizeTOption", &sizetOption,
"An option of type size_t.");
70 #ifdef HAVE_TEUCHOS_LONG_LONG_INT 71 long long longLongOption = 42;
72 clp.setOption(
"longLongOption", &longLongOption,
"An option of type long long." );
73 #endif // HAVE_TEUCHOS_LONG_LONG_INT 76 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
78 std::cout <<
"Test 1: CommandLineProcessor - No exceptions - All extra options ignored: ";
79 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
81 parse_successful =
false;
82 if (verbose) std::cout <<
"FAILED" << std::endl;
85 if (verbose) std::cout <<
"PASSED" << std::endl;
89 clp.setOption(
"num", &num,
"Number of memory blocks created (required option).",
true );
92 parse_return = clp.parse(argc,argv);
94 std::cout <<
"Test 2: CommandLineProcessor - No exceptions - All extra options ignored - 1 required: ";
95 if( parse_return != CommandLineProcessor::PARSE_ERROR )
97 parse_successful =
false;
98 if (verbose) std::cout <<
"FAILED" << std::endl;
101 if (verbose) std::cout <<
"PASSED" << std::endl;
106 std::cerr <<
"*** Caught UNEXPECTED unknown exception\n";
107 parse_successful =
false;
113 CommandLineProcessor clp2(
true,
false);
115 clp2.setOption(
"verbose",
"quiet", &verbose,
"Set if output is printed or not." );
117 double rel_proc_speed = 1e-5;
118 clp2.setOption(
"rel-proc-speed", &rel_proc_speed,
"Relative processor speed (try around 1.0 for timing)." );
121 clp2.setOption(
"size", &
size,
"Size of memory blocks created." );
125 clp2.setOption(
"num", &num,
"Number of memory blocks created (required option).",
true );
128 clp2.parse(argc,argv);
130 catch( CommandLineProcessor::ParseError &excpt ) {
132 std::cout <<
"*** Caught EXPECTED standard exception : " << excpt.what() << std::endl
133 <<
"Test 3: CommandLineProcessor - Throw exceptions - All extra options ignored - 1 required: PASSED" << std::endl;
137 std::cout <<
"*** Caught UNEXPECTED unknown exception" << std::endl
138 <<
"Test 3: CommandLineProcessor - Throw exceptions - All extra options ignored - 1 required: FAILED" << std::endl;
139 parse_successful =
false;
144 CommandLineProcessor clp3(
false,
true);
147 CommandLineProcessor::EParseCommandLineReturn parse_return = clp3.parse(argc,argv);
149 std::cout <<
"Test 4 : CommandLineProcessor - No exceptions - Extra options not recognized: ";
150 if( parse_return != CommandLineProcessor::PARSE_UNRECOGNIZED_OPTION )
152 parse_successful =
false;
153 if (verbose) std::cout <<
"FAILED" << std::endl;
156 if (verbose) std::cout <<
"PASSED" << std::endl;
159 clp3.setOption(
"verbose",
"quiet", &verbose,
"Set if output is printed or not." );
162 clp3.setOption(
"num", &num,
"Number of memory blocks created (required option).",
true );
164 parse_return = clp3.parse(argc,argv);
166 std::cout <<
"Test 5 : CommandLineProcessor - No exceptions - Extra options not recognized - 1 required: ";
167 if( parse_return != CommandLineProcessor::PARSE_ERROR )
169 parse_successful =
false;
170 if (verbose) std::cout <<
"FAILED" << std::endl;
173 if (verbose) std::cout <<
"PASSED" << std::endl;
177 std::cerr <<
"*** Caught UNEXPECTED unknown exception" << std::endl;
178 parse_successful =
false;
184 std::cout <<
"Test 6 : CommandLineProcessor - Throw exceptions - Extra options not recognized: ";
186 CommandLineProcessor clp4(
true,
true);
189 clp4.parse(argc,argv);
191 catch( CommandLineProcessor::UnrecognizedOption &excpt ) {
193 std::cout <<
"*** Caught EXPECTED standard exception : " << excpt.what() << std::endl
194 <<
"Test 6: CommandLineProcessor - Throw exceptions - Extra options not recognized: PASSED" << std::endl;
198 std::cout <<
"*** Caught UNEXPECTED unknown exception" << std::endl
199 <<
"Test 5: CommandLineProcessor - Throw exceptions - Extra options not recognized: FAILED" << std::endl;
200 parse_successful =
false;
204 if (parse_successful) {
205 std::cout <<
"End Result: TEST PASSED" << std::endl;
209 std::cout <<
"End Result: TEST FAILED" << std::endl;
int main(int argc, char *argv[])
Initialize, finalize, and query the global MPI session.
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Basic command line parser for input from (argc,argv[])
Class that helps parse command line input arguments from (argc,argv[]) and set options.