00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef THYRA_TESTING_TOOLS_DECL_HPP
00030 #define THYRA_TESTING_TOOLS_DECL_HPP
00031
00032 #include "Thyra_OperatorVectorTypes.hpp"
00033 #include "Teuchos_VerbosityLevel.hpp"
00034
00035 namespace Thyra {
00036
00050 inline
00051 const std::string passfail(bool pass) { return ( pass ? "passed" : "failed" ); }
00052
00059 template <class Scalar>
00060 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00061 relErr( const Scalar &s1, const Scalar &s2 );
00062
00069 template <class Scalar>
00070 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00071 relVectorErr( const VectorBase<Scalar> &v1, const VectorBase<Scalar> &v2 );
00072
00079 template<class Scalar>
00080 bool testRelErr(
00081 const std::string &v1_name
00082 ,const Scalar &v1
00083 ,const std::string &v2_name
00084 ,const Scalar &v2
00085 ,const std::string &maxRelErr_error_name
00086 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_error
00087 ,const std::string &maxRelErr_warning_name
00088 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_warning
00089 ,std::ostream *out
00090 ,const std::string &leadingIndent = std::string("")
00091 );
00092
00103 template<class Scalar1, class Scalar2, class ScalarMag>
00104 bool testRelErrors(
00105 const int num_scalars
00106 ,const std::string &v1_name
00107 ,const Scalar1 v1[]
00108 ,const std::string &v2_name
00109 ,const Scalar2 v2[]
00110 ,const std::string &maxRelErr_error_name
00111 ,const ScalarMag &maxRelErr_error
00112 ,const std::string &maxRelErr_warning_name
00113 ,const ScalarMag &maxRelErr_warning
00114 ,std::ostream *out
00115 ,const std::string &leadingIndent = std::string("")
00116 );
00117
00128 template<class Scalar>
00129 bool testRelNormDiffErr(
00130 const std::string &v1_name,
00131 const VectorBase<Scalar> &v1,
00132 const std::string &v2_name,
00133 const VectorBase<Scalar> &v2,
00134 const std::string &maxRelErr_error_name,
00135 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_error,
00136 const std::string &maxRelErr_warning_name,
00137 const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_warning,
00138 std::ostream *out,
00139 const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_LOW,
00140 const std::string &leadingIndent = std::string("")
00141 );
00142
00149 template<class Scalar>
00150 bool testMaxErr(
00151 const std::string &error_name
00152 ,const Scalar &error
00153 ,const std::string &max_error_name
00154 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_error
00155 ,const std::string &max_warning_name
00156 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_warning
00157 ,std::ostream *out
00158 ,const std::string &leadingIndent = std::string("")
00159 );
00160
00169 template<class Scalar>
00170 bool testMaxErrors(
00171 const int num_scalars
00172 ,const std::string &error_name
00173 ,const Scalar error[]
00174 ,const std::string &max_error_name
00175 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_error
00176 ,const std::string &max_warning_name
00177 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_warning
00178 ,std::ostream *out
00179 ,const std::string &leadingIndent = std::string("")
00180 );
00181
00188 bool testBoolExpr(
00189 const std::string &boolExprName
00190 ,const bool &boolExpr
00191 ,const bool &boolExpected
00192 ,std::ostream *out
00193 ,const std::string &leadingIndent = std::string("")
00194 );
00195
00216 void printTestResults(
00217 const bool result
00218 ,const std::string &test_summary
00219 ,const bool show_all_tests
00220 ,bool *success
00221 ,std::ostream *out
00222 );
00223
00230 template<class Scalar>
00231 std::ostream& operator<<( std::ostream& o, const VectorBase<Scalar>& v );
00232
00239 template<class Scalar>
00240 std::ostream& operator<<( std::ostream& o, const LinearOpBase<Scalar>& M );
00241
00242 }
00243
00244
00245
00246
00247 inline
00248 void Thyra::printTestResults(
00249 const bool result
00250 ,const std::string &test_summary
00251 ,const bool show_all_tests
00252 ,bool *success
00253 ,std::ostream *out
00254 )
00255 {
00256 if(!result) *success = false;
00257 if(out) {
00258 if( !result || show_all_tests )
00259 *out << std::endl << test_summary;
00260 else
00261 *out << "passed!\n";
00262 }
00263 }
00264
00265 #endif // THYRA_TESTING_TOOLS_DECL_HPP