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 SehExceptionInSetUpTestSuiteTest :
public Test {
72 TEST_F(SehExceptionInSetUpTestSuiteTest, ThrowsExceptionInSetUpTestSuite) {}
74 class SehExceptionInTearDownTestSuiteTest :
public Test {
79 TEST_F(SehExceptionInTearDownTestSuiteTest,
80 ThrowsExceptionInTearDownTestSuite) {}
82 class SehExceptionInSetUpTest :
public Test {
84 virtual void SetUp() { RaiseException(42, 0, 0, NULL); }
87 TEST_F(SehExceptionInSetUpTest, ThrowsExceptionInSetUp) {}
89 class SehExceptionInTearDownTest :
public Test {
91 virtual void TearDown() { RaiseException(42, 0, 0, NULL); }
94 TEST_F(SehExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
96 TEST(SehExceptionTest, ThrowsSehException) {
97 RaiseException(42, 0, 0, NULL);
100 #endif // GTEST_HAS_SEH 102 #if GTEST_HAS_EXCEPTIONS 104 class CxxExceptionInConstructorTest :
public Test {
106 CxxExceptionInConstructorTest() {
110 throw std::runtime_error(
"Standard C++ exception"));
115 "CxxExceptionInConstructorTest::TearDownTestSuite() " 116 "called as expected.\n");
120 ~CxxExceptionInConstructorTest()
override {
121 ADD_FAILURE() <<
"CxxExceptionInConstructorTest destructor " 122 <<
"called unexpectedly.";
125 void SetUp()
override {
126 ADD_FAILURE() <<
"CxxExceptionInConstructorTest::SetUp() " 127 <<
"called unexpectedly.";
131 ADD_FAILURE() <<
"CxxExceptionInConstructorTest::TearDown() " 132 <<
"called unexpectedly.";
136 TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
137 ADD_FAILURE() <<
"CxxExceptionInConstructorTest test body " 138 <<
"called unexpectedly.";
141 class CxxExceptionInSetUpTestSuiteTest :
public Test {
143 CxxExceptionInSetUpTestSuiteTest() {
145 "CxxExceptionInSetUpTestSuiteTest constructor " 146 "called as expected.\n");
150 throw std::runtime_error(
"Standard C++ exception");
155 "CxxExceptionInSetUpTestSuiteTest::TearDownTestSuite() " 156 "called as expected.\n");
160 ~CxxExceptionInSetUpTestSuiteTest()
override {
162 "CxxExceptionInSetUpTestSuiteTest destructor " 163 "called as expected.\n");
166 void SetUp()
override {
168 "CxxExceptionInSetUpTestSuiteTest::SetUp() " 169 "called as expected.\n");
174 "CxxExceptionInSetUpTestSuiteTest::TearDown() " 175 "called as expected.\n");
179 TEST_F(CxxExceptionInSetUpTestSuiteTest, ThrowsExceptionInSetUpTestSuite) {
181 "CxxExceptionInSetUpTestSuiteTest test body " 182 "called as expected.\n");
185 class CxxExceptionInTearDownTestSuiteTest :
public Test {
188 throw std::runtime_error(
"Standard C++ exception");
192 TEST_F(CxxExceptionInTearDownTestSuiteTest,
193 ThrowsExceptionInTearDownTestSuite) {}
195 class CxxExceptionInSetUpTest :
public Test {
199 "CxxExceptionInSetUpTest::TearDownTestSuite() " 200 "called as expected.\n");
204 ~CxxExceptionInSetUpTest()
override {
206 "CxxExceptionInSetUpTest destructor " 207 "called as expected.\n");
210 void SetUp()
override {
throw std::runtime_error(
"Standard C++ exception"); }
214 "CxxExceptionInSetUpTest::TearDown() " 215 "called as expected.\n");
219 TEST_F(CxxExceptionInSetUpTest, ThrowsExceptionInSetUp) {
220 ADD_FAILURE() <<
"CxxExceptionInSetUpTest test body " 221 <<
"called unexpectedly.";
224 class CxxExceptionInTearDownTest :
public Test {
228 "CxxExceptionInTearDownTest::TearDownTestSuite() " 229 "called as expected.\n");
233 ~CxxExceptionInTearDownTest()
override {
235 "CxxExceptionInTearDownTest destructor " 236 "called as expected.\n");
240 throw std::runtime_error(
"Standard C++ exception");
244 TEST_F(CxxExceptionInTearDownTest, ThrowsExceptionInTearDown) {}
246 class CxxExceptionInTestBodyTest :
public Test {
250 "CxxExceptionInTestBodyTest::TearDownTestSuite() " 251 "called as expected.\n");
255 ~CxxExceptionInTestBodyTest()
override {
257 "CxxExceptionInTestBodyTest destructor " 258 "called as expected.\n");
263 "CxxExceptionInTestBodyTest::TearDown() " 264 "called as expected.\n");
268 TEST_F(CxxExceptionInTestBodyTest, ThrowsStdCxxException) {
269 throw std::runtime_error(
"Standard C++ exception");
272 TEST(CxxExceptionTest, ThrowsNonStdCxxException) {
280 fprintf(stderr,
"%s\n",
"Unhandled C++ exception terminating the program.");
285 #endif // GTEST_HAS_EXCEPTIONS 287 int main(
int argc,
char** argv) {
288 #if GTEST_HAS_EXCEPTIONS #define TEST_F(test_fixture, test_name)
#define TEST(test_suite_name, test_name)
static void TearDownTestSuite()
int main(int argc, char **argv)
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
static void SetUpTestSuite()