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 #ifndef WEXCEPTION_TEST_H
00026 #define WEXCEPTION_TEST_H
00027
00028 #include <string>
00029
00030 #include <boost/shared_ptr.hpp>
00031 #include <cxxtest/TestSuite.h>
00032
00033 #include "../WException.h"
00034
00035
00036
00037
00038 class WExceptionTest : public CxxTest::TestSuite
00039 {
00040 public:
00041
00042
00043
00044 void testInstantiation( void )
00045 {
00046 TS_ASSERT_THROWS_NOTHING( WException e() );
00047 TS_ASSERT_THROWS_NOTHING( WException e( std::string( "Some message" ) ) );
00048 }
00049
00050
00051
00052
00053 void testGetMessage( void )
00054 {
00055 WException e( std::string( "Dummy exception" ) );
00056 e.m_trace.push_back( "first" );
00057 e.m_trace.push_back( "second" );
00058 std::string expected = "Dummy exception\n\ntrace: first\ntrace: second";
00059 TS_ASSERT_EQUALS( expected, e.getTrace() );
00060 WException f;
00061 TS_ASSERT_EQUALS( std::string(), f.getTrace() );
00062 }
00063
00064
00065
00066
00067 void testBacktrace( void )
00068 {
00069 #if ( defined( __linux__ ) && defined( __GNUC__ ) )
00070 try
00071 {
00072 new WException();
00073 }
00074 catch( const WException& e )
00075 {
00076 std::string bt = e.getBacktrace();
00077
00078
00079 TS_ASSERT( bt.length() );
00080 }
00081 #else
00082
00083 TS_ASSERT( true );
00084 #endif
00085 }
00086 };
00087
00088 #endif // WEXCEPTION_TEST_H