googletest-catch-exceptions-test_.cc (googletest-release-1.11.0) | : | googletest-catch-exceptions-test_.cc (googletest-release-1.12.0) | ||
---|---|---|---|---|
skipping to change at line 35 | skipping to change at line 35 | |||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
// | // | |||
// Tests for Google Test itself. Tests in this file throw C++ or SEH | // Tests for Google Test itself. Tests in this file throw C++ or SEH | |||
// exceptions, and the output is verified by | // exceptions, and the output is verified by | |||
// googletest-catch-exceptions-test.py. | // googletest-catch-exceptions-test.py. | |||
#include <stdio.h> // NOLINT | #include <stdio.h> // NOLINT | |||
#include <stdlib.h> // For exit(). | #include <stdlib.h> // For exit(). | |||
#include "gtest/gtest.h" | #include "gtest/gtest.h" | |||
#if GTEST_HAS_SEH | #if GTEST_HAS_SEH | |||
# include <windows.h> | #include <windows.h> | |||
#endif | #endif | |||
#if GTEST_HAS_EXCEPTIONS | #if GTEST_HAS_EXCEPTIONS | |||
# include <exception> // For set_terminate(). | #include <exception> // For set_terminate(). | |||
# include <stdexcept> | #include <stdexcept> | |||
#endif | #endif | |||
using testing::Test; | using testing::Test; | |||
#if GTEST_HAS_SEH | #if GTEST_HAS_SEH | |||
class SehExceptionInConstructorTest : public Test { | class SehExceptionInConstructorTest : public Test { | |||
public: | public: | |||
SehExceptionInConstructorTest() { RaiseException(42, 0, 0, NULL); } | SehExceptionInConstructorTest() { RaiseException(42, 0, 0, NULL); } | |||
}; | }; | |||
skipping to change at line 96 | skipping to change at line 96 | |||
TEST_F(SehExceptionInSetUpTest, ThrowsExceptionInSetUp) {} | TEST_F(SehExceptionInSetUpTest, ThrowsExceptionInSetUp) {} | |||
class SehExceptionInTearDownTest : public Test { | class SehExceptionInTearDownTest : public Test { | |||
protected: | protected: | |||
virtual void TearDown() { RaiseException(42, 0, 0, NULL); } | virtual void TearDown() { RaiseException(42, 0, 0, NULL); } | |||
}; | }; | |||
TEST_F(SehExceptionInTearDownTest, ThrowsExceptionInTearDown) {} | TEST_F(SehExceptionInTearDownTest, ThrowsExceptionInTearDown) {} | |||
TEST(SehExceptionTest, ThrowsSehException) { | TEST(SehExceptionTest, ThrowsSehException) { RaiseException(42, 0, 0, NULL); } | |||
RaiseException(42, 0, 0, NULL); | ||||
} | ||||
#endif // GTEST_HAS_SEH | #endif // GTEST_HAS_SEH | |||
#if GTEST_HAS_EXCEPTIONS | #if GTEST_HAS_EXCEPTIONS | |||
class CxxExceptionInConstructorTest : public Test { | class CxxExceptionInConstructorTest : public Test { | |||
public: | public: | |||
CxxExceptionInConstructorTest() { | CxxExceptionInConstructorTest() { | |||
// Without this macro VC++ complains about unreachable code at the end of | // Without this macro VC++ complains about unreachable code at the end of | |||
// the constructor. | // the constructor. | |||
skipping to change at line 272 | skipping to change at line 270 | |||
printf("%s", | printf("%s", | |||
"CxxExceptionInTestBodyTest::TearDown() " | "CxxExceptionInTestBodyTest::TearDown() " | |||
"called as expected.\n"); | "called as expected.\n"); | |||
} | } | |||
}; | }; | |||
TEST_F(CxxExceptionInTestBodyTest, ThrowsStdCxxException) { | TEST_F(CxxExceptionInTestBodyTest, ThrowsStdCxxException) { | |||
throw std::runtime_error("Standard C++ exception"); | throw std::runtime_error("Standard C++ exception"); | |||
} | } | |||
TEST(CxxExceptionTest, ThrowsNonStdCxxException) { | TEST(CxxExceptionTest, ThrowsNonStdCxxException) { throw "C-string"; } | |||
throw "C-string"; | ||||
} | ||||
// This terminate handler aborts the program using exit() rather than abort(). | // This terminate handler aborts the program using exit() rather than abort(). | |||
// This avoids showing pop-ups on Windows systems and core dumps on Unix-like | // This avoids showing pop-ups on Windows systems and core dumps on Unix-like | |||
// ones. | // ones. | |||
void TerminateHandler() { | void TerminateHandler() { | |||
fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program."); | fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program."); | |||
fflush(nullptr); | fflush(nullptr); | |||
exit(3); | exit(3); | |||
} | } | |||
End of changes. 5 change blocks. | ||||
10 lines changed or deleted | 6 lines changed or added |