Menu

[r344]: / trunk / cppunit / src / cppunit / DefaultProtector.cpp  Maximize  Restore  History

Download this file

45 lines (37 with data), 962 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <cppunit/Exception.h>
#include <cppunit/extensions/TypeInfoHelper.h>
#include "DefaultProtector.h"
CPPUNIT_NS_BEGIN
bool
DefaultProtector::protect( const Functor &functor,
const ProtectorContext &context )
{
try
{
functor();
return true;
}
catch ( Exception &failure )
{
reportTestFailure( failure.message(), context, false );
}
catch ( std::exception &e )
{
std::string shortDescription( "uncaught exception of type " );
#if CPPUNIT_USE_TYPEINFO_NAME
shortDescription += TypeInfoHelper::getClassName( typeid(e) );
#else
shortDescription += "std::exception (or derived)."
#endif
Message message( shortDescription, e.what() );
reportTestFailure( message, context, true );
}
catch ( ... )
{
reportTestFailure( Message( "uncaught exception of unknown type"),
context,
true );
}
return false;
}
CPPUNIT_NS_END
MongoDB Logo MongoDB