51int main(
int argc,
char* argv[] )
63 CommandLineProcessor clp(
false);
64 clp.setOption(
"verbose",
"quiet", &verbose,
"Set if output is printed or not." );
65 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
66 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
return parse_return;
71 <<
"\n*******************************************"
72 <<
"\n*** Basic test of Teuchos::dyn_cast<>() ***"
73 <<
"\n*******************************************\n";
77 if(verbose) std::cout <<
"\nTrying: dynamic_cast<C&>(a); [Should throw a std::bad_cast std::exception with very bad error message]\n";
78 C& c_from_an_a =
dynamic_cast<C&
>(a);
81 catch(
const std::bad_cast &e ) {
82 if(verbose) std::cout <<
"\nCaught std::bad_cast std::exception e where e.what() = \"" << e.what() <<
"\"\n";
85 if(verbose) std::cout <<
"\nTrying: Teuchos::dyn_cast<C>(a); [Should throw a std::bad_cast std::exception with a very good error message]\n";
88 catch(
const std::bad_cast &e ) {
89 if(verbose) std::cout <<
"\nCaught std::bad_cast std::exception e where e.what() = \"" << e.what() <<
"\"\n";
91 if(verbose) std::cout <<
"\nTrying: Teuchos::dyn_cast<B>(a).f(); [Should succeed and print \"B::f() called\"]\n";
93 if(verbose) std::cout <<
"\nAll tests check out!\n";
95 catch(
const std::exception &excpt ) {
97 std::cerr <<
"*** Caught standard std::exception : " << excpt.what() << std::endl;
102 std::cerr <<
"*** Caught an unknown std::exception\n";