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
00034 namespace Thyra {
00035
00049 inline
00050 const char* passfail(bool pass) { return pass ? "passed" : "failed"; }
00051
00058 template <class Scalar>
00059 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00060 relErr( const Scalar &s1, const Scalar &s2 );
00061
00068 template<class Scalar>
00069 bool testRelErr(
00070 const std::string &v1_name
00071 ,const Scalar &v1
00072 ,const std::string &v2_name
00073 ,const Scalar &v2
00074 ,const std::string &maxRelErr_error_name
00075 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_error
00076 ,const std::string &maxRelErr_warning_name
00077 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &maxRelErr_warning
00078 ,std::ostream *out
00079 ,const std::string &leadingIndent = std::string("")
00080 );
00081
00092 template<class Scalar1, class Scalar2, class ScalarMag>
00093 bool testRelErrors(
00094 const int num_scalars
00095 ,const std::string &v1_name
00096 ,const Scalar1 v1[]
00097 ,const std::string &v2_name
00098 ,const Scalar2 v2[]
00099 ,const std::string &maxRelErr_error_name
00100 ,const ScalarMag &maxRelErr_error
00101 ,const std::string &maxRelErr_warning_name
00102 ,const ScalarMag &maxRelErr_warning
00103 ,std::ostream *out
00104 ,const std::string &leadingIndent = std::string("")
00105 );
00106
00113 template<class Scalar>
00114 bool testMaxErr(
00115 const std::string &error_name
00116 ,const Scalar &error
00117 ,const std::string &max_error_name
00118 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_error
00119 ,const std::string &max_warning_name
00120 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_warning
00121 ,std::ostream *out
00122 ,const std::string &leadingIndent = std::string("")
00123 );
00124
00133 template<class Scalar>
00134 bool testMaxErrors(
00135 const int num_scalars
00136 ,const std::string &error_name
00137 ,const Scalar error[]
00138 ,const std::string &max_error_name
00139 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_error
00140 ,const std::string &max_warning_name
00141 ,const typename Teuchos::ScalarTraits<Scalar>::magnitudeType &max_warning
00142 ,std::ostream *out
00143 ,const std::string &leadingIndent = std::string("")
00144 );
00145
00152 bool testBoolExpr(
00153 const std::string &boolExprName
00154 ,const bool &boolExpr
00155 ,const bool &boolExpected
00156 ,std::ostream *out
00157 ,const std::string &leadingIndent = std::string("")
00158 );
00159
00180 void printTestResults(
00181 const bool result
00182 ,const std::string &test_summary
00183 ,const bool show_all_tests
00184 ,bool *success
00185 ,std::ostream *out
00186 );
00187
00194 template<class Scalar>
00195 std::ostream& operator<<( std::ostream& o, const VectorBase<Scalar>& v );
00196
00203 template<class Scalar>
00204 std::ostream& operator<<( std::ostream& o, const LinearOpBase<Scalar>& M );
00205
00206 }
00207
00208
00209
00210
00211 inline
00212 void Thyra::printTestResults(
00213 const bool result
00214 ,const std::string &test_summary
00215 ,const bool show_all_tests
00216 ,bool *success
00217 ,std::ostream *out
00218 )
00219 {
00220 if(!result) *success = false;
00221 if(out) {
00222 if( !result || show_all_tests )
00223 *out << std::endl << test_summary;
00224 else
00225 *out << "passed!\n";
00226 }
00227 }
00228
00229 #endif // THYRA_TESTING_TOOLS_DECL_HPP