TestFailure.h

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile$
00027  * Date modified: $Date: 2005-01-16 17:51:42 -0600 (Sun, 16 Jan 2005) $
00028  * Version:       $Revision: 16627 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #ifndef _TEST_FAILURE_H_
00034 #define _TEST_FAILURE_H_
00035 
00036 #include <vpr/vpr.h>
00037 #include <vrj/vrjConfig.h>
00038 
00039 #include <vpr/Util/Assert.h>
00040 
00041 #include <vrj/Test/Message.h>
00042 #include <vrj/Test/Test.h>
00043 
00044 #include <string>
00045 #include <vector>
00046 #include <sstream>
00047 
00048 #include <exception>
00049 
00050 namespace vrj {
00051 namespace test
00052 {
00053 
00063 class TestFailure : public std::exception
00064 {
00065 public:
00066    TestFailure(Test* failedTest, vrj::test::Message message, 
00067                const std::string& fileName, int lineNumber)
00068       throw()
00069       : mFailedTest(failedTest)
00070       , mMessage(message)
00071       , mFileName(fileName)
00072       , mLineNumber(lineNumber)
00073    {
00074 
00075    }
00076 
00077    virtual ~TestFailure() throw()
00078    {;}
00079 
00080    Test* getFailedTest()
00081    {
00082       return mFailedTest;
00083    }
00084 
00085    std::string getFailedTestName()
00086    {
00087       return mFailedTest->getName();
00088    }
00089 
00090    vrj::test::Message getMessage() const
00091    {
00092       return mMessage;
00093    }
00094    
00095    std::string getFileName() const
00096    {
00097       return mFileName;
00098    }
00099 
00100    int getLineNumber() const
00101    {
00102       return mLineNumber;
00103    }
00104 
00105    std::string getFullDescription()
00106    {
00107       vprASSERT(NULL != mFailedTest);
00108 
00109       std::stringstream oss;
00110       oss << getFailedTestName() << ": ";
00111       oss << getFileName() << ": line:";
00112       oss << getLineNumber() << ": ";
00113       oss << getMessage().shortDesc();
00114       oss << "\n" << getMessage().details();
00115       return oss.str();
00116    }
00117 
00118 
00119 protected:
00120    Test*                mFailedTest;      
00121    vrj::test::Message   mMessage;         
00122    std::string          mFileName;        
00123    int                  mLineNumber;      
00124 };
00125 
00126 } }
00127 
00128 
00129 #endif

Generated on Thu Jan 4 10:56:52 2007 for VR Juggler by  doxygen 1.5.1