PlayaTesterBase.hpp
00001
00002
00003
00004
00005
00006 #ifndef PLAYA_TESTERBASE_HPP
00007 #define PLAYA_TESTERBASE_HPP
00008
00009 #include "PlayaLinearOperatorDecl.hpp"
00010 #include "PlayaTestSpecifier.hpp"
00011 #include "Teuchos_ScalarTraits.hpp"
00012 #include "PlayaOut.hpp"
00013
00014
00015 using namespace Teuchos;
00016
00017
00018
00019 namespace Playa
00020 {
00021
00023 template <class Scalar>
00024 class TesterBase
00025 {
00026 public:
00028 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
00029
00031 TesterBase(){;}
00032
00034 virtual ~TesterBase(){;}
00035
00037 virtual bool runAllTests() const = 0 ;
00038
00039
00041 bool checkTest(const TestSpecifier<Scalar>& spec,
00042 const ScalarMag& err,
00043 const std::string& testName) const ;
00044
00046 void randomizeVec(Vector<Scalar>& x) const ;
00047
00048 };
00049
00050 template <class Scalar>
00051 inline void TesterBase<Scalar>
00052 ::randomizeVec(Vector<Scalar>& x) const
00053 {
00054 typedef Teuchos::ScalarTraits<Scalar> ST;
00055 x.randomize();
00056
00057 }
00058
00059 template <class Scalar>
00060 inline bool TesterBase<Scalar>
00061 ::checkTest(const TestSpecifier<Scalar>& spec,
00062 const ScalarMag& err,
00063 const std::string& testName) const
00064 {
00065 bool rtn = true;
00066 if (err > spec.errorTol())
00067 {
00068 Out::root() << testName << " test FAILED: err=" << err << ", tol = "
00069 << spec.errorTol() << std::endl;
00070 rtn = false;
00071 }
00072 else if (err > spec.warningTol())
00073 {
00074 Out::root() << "WARNING: " << testName << " test err="
00075 << err << " could not beat tol = "
00076 << spec.warningTol() << std::endl;
00077 }
00078 else
00079 {
00080 Out::root() << "test " << testName << " PASSED with tol=" << spec.errorTol() << std::endl;
00081 }
00082 return rtn;
00083 }
00084
00085 }
00086 #endif