From 58b762f965cc857aff08051f98ea0de98c713224 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 3 May 2014 18:13:16 -0700 Subject: [PATCH] Fix tests. --- test/gtest-extra-test.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/gtest-extra-test.cc b/test/gtest-extra-test.cc index db5ff7a7..bc7f86d5 100644 --- a/test/gtest-extra-test.cc +++ b/test/gtest-extra-test.cc @@ -44,6 +44,14 @@ std::string FormatSystemErrorMessage(int error_code, fmt::StringRef message) { EXPECT_THROW_MSG(statement, fmt::SystemError, \ FormatSystemErrorMessage(error_code, message)) +#ifndef _WIN32 +# define EXPECT_SYSTEM_ERROR_OR_DEATH(statement, error_code, message) \ + EXPECT_SYSTEM_ERROR(statement, error_code, message) +#else +# define EXPECT_SYSTEM_ERROR_OR_DEATH(statement, error_code, message) \ + EXPECT_DEATH(statement, "") +#endif + // Tests that assertion macros evaluate their arguments exactly once. class SingleEvaluationTest : public ::testing::Test { protected: @@ -327,7 +335,7 @@ TEST(FileTest, Read) { TEST(FileTest, ReadError) { File f; char buf; - EXPECT_SYSTEM_ERROR(f.read(&buf, 1), EBADF, "cannot read from file"); + EXPECT_SYSTEM_ERROR_OR_DEATH(f.read(&buf, 1), EBADF, "cannot read from file"); } TEST(FileTest, Write) { @@ -340,7 +348,7 @@ TEST(FileTest, Write) { TEST(FileTest, WriteError) { File f; - EXPECT_SYSTEM_ERROR(f.write(" ", 1), EBADF, "cannot write to file"); + EXPECT_SYSTEM_ERROR_OR_DEATH(f.write(" ", 1), EBADF, "cannot write to file"); } TEST(FileTest, Dup) {