44 #if GTEST_HAS_EXCEPTIONS
53 class SehExceptionInConstructorTest :
public Test {
55 SehExceptionInConstructorTest() { RaiseException(42, 0, 0, NULL); }
58 TEST_F(SehExceptionInConstructorTest, ThrowsExceptionInConstructor) {}
60 class SehExceptionInDestructorTest :
public Test {
62 ~SehExceptionInDestructorTest() { RaiseException(42, 0, 0, NULL); }
65 TEST_F(SehExceptionInDestructorTest, ThrowsExceptionInDestructor) {}
67 class SehExceptionInSetUpTestCaseTest :
public Test {
69 static void SetUpTestCase() { RaiseException(42, 0, 0, NULL); }
72 TEST_F(SehExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {}
74 class SehExceptionInTearDownTestCaseTest :
public Test {
79 TEST_F(SehExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}
81 class SehExceptionInSetUpTest :
public Test {
83 virtual void SetUp() { RaiseException(42, 0, 0, NULL); }
86 TEST_F(SehExceptionInSetUpTest, ThrowsExceptionInSetUp) {}
88 class SehExceptionInTearDownTest :
public Test {
90 virtual void TearDown() { RaiseException(42, 0, 0, NULL); }
93 TEST_F(SehExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
95 TEST(SehExceptionTest, ThrowsSehException) {
96 RaiseException(42, 0, 0, NULL);
99 #endif // GTEST_HAS_SEH
101 #if GTEST_HAS_EXCEPTIONS
103 class CxxExceptionInConstructorTest :
public Test {
105 CxxExceptionInConstructorTest() {
109 throw std::runtime_error(
"Standard C++ exception"));
114 "CxxExceptionInConstructorTest::TearDownTestCase() "
115 "called as expected.\n");
119 ~CxxExceptionInConstructorTest() {
120 ADD_FAILURE() <<
"CxxExceptionInConstructorTest destructor "
121 <<
"called unexpectedly.";
124 virtual void SetUp() {
125 ADD_FAILURE() <<
"CxxExceptionInConstructorTest::SetUp() "
126 <<
"called unexpectedly.";
130 ADD_FAILURE() <<
"CxxExceptionInConstructorTest::TearDown() "
131 <<
"called unexpectedly.";
135 TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
136 ADD_FAILURE() <<
"CxxExceptionInConstructorTest test body "
137 <<
"called unexpectedly.";
141 #if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
142 class CxxExceptionInDestructorTest :
public Test {
146 "CxxExceptionInDestructorTest::TearDownTestCase() "
147 "called as expected.\n");
151 ~CxxExceptionInDestructorTest() {
153 throw std::runtime_error(
"Standard C++ exception"));
157 TEST_F(CxxExceptionInDestructorTest, ThrowsExceptionInDestructor) {}
160 class CxxExceptionInSetUpTestCaseTest :
public Test {
162 CxxExceptionInSetUpTestCaseTest() {
164 "CxxExceptionInSetUpTestCaseTest constructor "
165 "called as expected.\n");
169 throw std::runtime_error(
"Standard C++ exception");
174 "CxxExceptionInSetUpTestCaseTest::TearDownTestCase() "
175 "called as expected.\n");
179 ~CxxExceptionInSetUpTestCaseTest() {
181 "CxxExceptionInSetUpTestCaseTest destructor "
182 "called as expected.\n");
185 virtual void SetUp() {
187 "CxxExceptionInSetUpTestCaseTest::SetUp() "
188 "called as expected.\n");
193 "CxxExceptionInSetUpTestCaseTest::TearDown() "
194 "called as expected.\n");
198 TEST_F(CxxExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {
200 "CxxExceptionInSetUpTestCaseTest test body "
201 "called as expected.\n");
204 class CxxExceptionInTearDownTestCaseTest :
public Test {
207 throw std::runtime_error(
"Standard C++ exception");
211 TEST_F(CxxExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}
213 class CxxExceptionInSetUpTest :
public Test {
217 "CxxExceptionInSetUpTest::TearDownTestCase() "
218 "called as expected.\n");
222 ~CxxExceptionInSetUpTest() {
224 "CxxExceptionInSetUpTest destructor "
225 "called as expected.\n");
228 virtual void SetUp() {
throw std::runtime_error(
"Standard C++ exception"); }
232 "CxxExceptionInSetUpTest::TearDown() "
233 "called as expected.\n");
237 TEST_F(CxxExceptionInSetUpTest, ThrowsExceptionInSetUp) {
238 ADD_FAILURE() <<
"CxxExceptionInSetUpTest test body "
239 <<
"called unexpectedly.";
242 class CxxExceptionInTearDownTest :
public Test {
246 "CxxExceptionInTearDownTest::TearDownTestCase() "
247 "called as expected.\n");
251 ~CxxExceptionInTearDownTest() {
253 "CxxExceptionInTearDownTest destructor "
254 "called as expected.\n");
258 throw std::runtime_error(
"Standard C++ exception");
262 TEST_F(CxxExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
264 class CxxExceptionInTestBodyTest :
public Test {
268 "CxxExceptionInTestBodyTest::TearDownTestCase() "
269 "called as expected.\n");
273 ~CxxExceptionInTestBodyTest() {
275 "CxxExceptionInTestBodyTest destructor "
276 "called as expected.\n");
281 "CxxExceptionInTestBodyTest::TearDown() "
282 "called as expected.\n");
286 TEST_F(CxxExceptionInTestBodyTest, ThrowsStdCxxException) {
287 throw std::runtime_error(
"Standard C++ exception");
290 TEST(CxxExceptionTest, ThrowsNonStdCxxException) {
298 fprintf(stderr,
"%s\n",
"Unhandled C++ exception terminating the program.");
303 #endif // GTEST_HAS_EXCEPTIONS
305 int main(
int argc,
char** argv) {
306 #if GTEST_HAS_EXCEPTIONS