44#if GTEST_HAS_EXCEPTIONS
53class SehExceptionInConstructorTest :
public Test {
55 SehExceptionInConstructorTest() { RaiseException(42, 0, 0, NULL); }
58TEST_F(SehExceptionInConstructorTest, ThrowsExceptionInConstructor) {}
60class SehExceptionInDestructorTest :
public Test {
62 ~SehExceptionInDestructorTest() { RaiseException(42, 0, 0, NULL); }
65TEST_F(SehExceptionInDestructorTest, ThrowsExceptionInDestructor) {}
67class SehExceptionInSetUpTestCaseTest :
public Test {
69 static void SetUpTestCase() { RaiseException(42, 0, 0, NULL); }
72TEST_F(SehExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {}
74class SehExceptionInTearDownTestCaseTest :
public Test {
79TEST_F(SehExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}
81class SehExceptionInSetUpTest :
public Test {
83 virtual void SetUp() { RaiseException(42, 0, 0, NULL); }
86TEST_F(SehExceptionInSetUpTest, ThrowsExceptionInSetUp) {}
88class SehExceptionInTearDownTest :
public Test {
90 virtual void TearDown() { RaiseException(42, 0, 0, NULL); }
93TEST_F(SehExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
95TEST(SehExceptionTest, ThrowsSehException) {
96 RaiseException(42, 0, 0, NULL);
101#if GTEST_HAS_EXCEPTIONS
103class 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.";
135TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
136 ADD_FAILURE() <<
"CxxExceptionInConstructorTest test body "
137 <<
"called unexpectedly.";
142class CxxExceptionInDestructorTest :
public Test {
146 "CxxExceptionInDestructorTest::TearDownTestCase() "
147 "called as expected.\n");
151 ~CxxExceptionInDestructorTest() {
153 throw std::runtime_error(
"Standard C++ exception"));
157TEST_F(CxxExceptionInDestructorTest, ThrowsExceptionInDestructor) {}
160class 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");
198TEST_F(CxxExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {
200 "CxxExceptionInSetUpTestCaseTest test body "
201 "called as expected.\n");
204class CxxExceptionInTearDownTestCaseTest :
public Test {
207 throw std::runtime_error(
"Standard C++ exception");
211TEST_F(CxxExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}
213class 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");
237TEST_F(CxxExceptionInSetUpTest, ThrowsExceptionInSetUp) {
238 ADD_FAILURE() <<
"CxxExceptionInSetUpTest test body "
239 <<
"called unexpectedly.";
242class 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");
262TEST_F(CxxExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
264class 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");
286TEST_F(CxxExceptionInTestBodyTest, ThrowsStdCxxException) {
287 throw std::runtime_error(
"Standard C++ exception");
290TEST(CxxExceptionTest, ThrowsNonStdCxxException) {
298 fprintf(stderr,
"%s\n",
"Unhandled C++ exception terminating the program.");
306#if GTEST_HAS_EXCEPTIONS
static void SetUpTestCase()
static void TearDownTestCase()
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
#define TEST_F(test_fixture, test_name)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
#define TEST(test_case_name, test_name)
LOGGING_API void printf(Category category, const char *format,...)
GTEST_API_ void InitGoogleTest(int *argc, char **argv)