Fixes the definition of GTEST_HAS_EXCEPTIONS, allowing exception assertions to be used with gcc.
This commit is contained in:
		@@ -207,28 +207,31 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#endif  // GTEST_OS_LINUX
 | 
					#endif  // GTEST_OS_LINUX
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Defines GTEST_HAS_EXCEPTIONS to 1 if exceptions are enabled, or 0
 | 
				
			||||||
 | 
					// otherwise.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef _MSC_VER  // Compiled by MSVC?
 | 
				
			||||||
 | 
					// Assumes that exceptions are enabled by default.
 | 
				
			||||||
 | 
					#ifndef _HAS_EXCEPTIONS  // MSVC uses this macro to enable exceptions.
 | 
				
			||||||
 | 
					#define _HAS_EXCEPTIONS 1
 | 
				
			||||||
 | 
					#endif  // _HAS_EXCEPTIONS
 | 
				
			||||||
 | 
					#define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
 | 
				
			||||||
 | 
					#else  // The compiler is not MSVC.
 | 
				
			||||||
 | 
					// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.  For
 | 
				
			||||||
 | 
					// other compilers, we assume exceptions are disabled to be
 | 
				
			||||||
 | 
					// conservative.
 | 
				
			||||||
 | 
					#define GTEST_HAS_EXCEPTIONS (defined(__GNUC__) && __EXCEPTIONS)
 | 
				
			||||||
 | 
					#endif  // _MSC_VER
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Determines whether ::std::string and ::string are available.
 | 
					// Determines whether ::std::string and ::string are available.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef GTEST_HAS_STD_STRING
 | 
					#ifndef GTEST_HAS_STD_STRING
 | 
				
			||||||
// The user didn't tell us whether ::std::string is available, so we
 | 
					// The user didn't tell us whether ::std::string is available, so we
 | 
				
			||||||
// need to figure it out.
 | 
					// need to figure it out.  The only environment that we know
 | 
				
			||||||
 | 
					// ::std::string is not available is MSVC 7.1 or lower with exceptions
 | 
				
			||||||
#ifdef GTEST_OS_WINDOWS
 | 
					// disabled.
 | 
				
			||||||
// Assumes that exceptions are enabled by default.
 | 
					#define GTEST_HAS_STD_STRING \
 | 
				
			||||||
#ifndef _HAS_EXCEPTIONS
 | 
					    (!(defined(_MSC_VER) && (_MSC_VER < 1400) && !GTEST_HAS_EXCEPTIONS))
 | 
				
			||||||
#define _HAS_EXCEPTIONS 1
 | 
					 | 
				
			||||||
#endif  // _HAS_EXCEPTIONS
 | 
					 | 
				
			||||||
// GTEST_HAS_EXCEPTIONS is non-zero iff exceptions are enabled.  It is
 | 
					 | 
				
			||||||
// always defined, while _HAS_EXCEPTIONS is defined only on Windows.
 | 
					 | 
				
			||||||
#define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
 | 
					 | 
				
			||||||
// On Windows, we can use ::std::string if the compiler version is VS
 | 
					 | 
				
			||||||
// 2005 or above, or if exceptions are enabled.
 | 
					 | 
				
			||||||
#define GTEST_HAS_STD_STRING ((_MSC_VER >= 1400) || GTEST_HAS_EXCEPTIONS)
 | 
					 | 
				
			||||||
#else  // We are on Linux or Mac OS.
 | 
					 | 
				
			||||||
#define GTEST_HAS_EXCEPTIONS 0
 | 
					 | 
				
			||||||
#define GTEST_HAS_STD_STRING 1
 | 
					 | 
				
			||||||
#endif  // GTEST_OS_WINDOWS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif  // GTEST_HAS_STD_STRING
 | 
					#endif  // GTEST_HAS_STD_STRING
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef GTEST_HAS_GLOBAL_STRING
 | 
					#ifndef GTEST_HAS_GLOBAL_STRING
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@ Expected: true
 | 
				
			|||||||
gtest_output_test_.cc:#: Failure
 | 
					gtest_output_test_.cc:#: Failure
 | 
				
			||||||
Value of: 3
 | 
					Value of: 3
 | 
				
			||||||
Expected: 2
 | 
					Expected: 2
 | 
				
			||||||
[0;32m[==========] [mRunning 52 tests from 22 test cases.
 | 
					[0;32m[==========] [mRunning 54 tests from 22 test cases.
 | 
				
			||||||
[0;32m[----------] [mGlobal test environment set-up.
 | 
					[0;32m[----------] [mGlobal test environment set-up.
 | 
				
			||||||
FooEnvironment::SetUp() called.
 | 
					FooEnvironment::SetUp() called.
 | 
				
			||||||
BarEnvironment::SetUp() called.
 | 
					BarEnvironment::SetUp() called.
 | 
				
			||||||
@@ -270,7 +270,7 @@ test DefinedUsingTEST is defined using TEST.  You probably
 | 
				
			|||||||
want to change the TEST to TEST_F or move it to another test
 | 
					want to change the TEST to TEST_F or move it to another test
 | 
				
			||||||
case.
 | 
					case.
 | 
				
			||||||
[0;31m[  FAILED  ] [mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
 | 
					[0;31m[  FAILED  ] [mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
 | 
				
			||||||
[0;32m[----------] [m7 tests from ExpectNonfatalFailureTest
 | 
					[0;32m[----------] [m8 tests from ExpectNonfatalFailureTest
 | 
				
			||||||
[0;32m[ RUN      ] [mExpectNonfatalFailureTest.CanReferenceGlobalVariables
 | 
					[0;32m[ RUN      ] [mExpectNonfatalFailureTest.CanReferenceGlobalVariables
 | 
				
			||||||
[0;32m[       OK ] [mExpectNonfatalFailureTest.CanReferenceGlobalVariables
 | 
					[0;32m[       OK ] [mExpectNonfatalFailureTest.CanReferenceGlobalVariables
 | 
				
			||||||
[0;32m[ RUN      ] [mExpectNonfatalFailureTest.CanReferenceLocalVariables
 | 
					[0;32m[ RUN      ] [mExpectNonfatalFailureTest.CanReferenceLocalVariables
 | 
				
			||||||
@@ -313,7 +313,13 @@ gtest.cc:#: Failure
 | 
				
			|||||||
Expected: 1 non-fatal failure
 | 
					Expected: 1 non-fatal failure
 | 
				
			||||||
  Actual: 0 failures
 | 
					  Actual: 0 failures
 | 
				
			||||||
[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenStatementReturns
 | 
					[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenStatementReturns
 | 
				
			||||||
[0;32m[----------] [m7 tests from ExpectFatalFailureTest
 | 
					[0;32m[ RUN      ] [mExpectNonfatalFailureTest.FailsWhenStatementThrows
 | 
				
			||||||
 | 
					(expecting a failure)
 | 
				
			||||||
 | 
					gtest.cc:#: Failure
 | 
				
			||||||
 | 
					Expected: 1 non-fatal failure
 | 
				
			||||||
 | 
					  Actual: 0 failures
 | 
				
			||||||
 | 
					[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenStatementThrows
 | 
				
			||||||
 | 
					[0;32m[----------] [m8 tests from ExpectFatalFailureTest
 | 
				
			||||||
[0;32m[ RUN      ] [mExpectFatalFailureTest.CanReferenceGlobalVariables
 | 
					[0;32m[ RUN      ] [mExpectFatalFailureTest.CanReferenceGlobalVariables
 | 
				
			||||||
[0;32m[       OK ] [mExpectFatalFailureTest.CanReferenceGlobalVariables
 | 
					[0;32m[       OK ] [mExpectFatalFailureTest.CanReferenceGlobalVariables
 | 
				
			||||||
[0;32m[ RUN      ] [mExpectFatalFailureTest.CanReferenceLocalStaticVariables
 | 
					[0;32m[ RUN      ] [mExpectFatalFailureTest.CanReferenceLocalStaticVariables
 | 
				
			||||||
@@ -356,6 +362,12 @@ gtest.cc:#: Failure
 | 
				
			|||||||
Expected: 1 fatal failure
 | 
					Expected: 1 fatal failure
 | 
				
			||||||
  Actual: 0 failures
 | 
					  Actual: 0 failures
 | 
				
			||||||
[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenStatementReturns
 | 
					[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenStatementReturns
 | 
				
			||||||
 | 
					[0;32m[ RUN      ] [mExpectFatalFailureTest.FailsWhenStatementThrows
 | 
				
			||||||
 | 
					(expecting a failure)
 | 
				
			||||||
 | 
					gtest.cc:#: Failure
 | 
				
			||||||
 | 
					Expected: 1 fatal failure
 | 
				
			||||||
 | 
					  Actual: 0 failures
 | 
				
			||||||
 | 
					[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenStatementThrows
 | 
				
			||||||
[0;32m[----------] [m2 tests from TypedTest/0, where TypeParam = int
 | 
					[0;32m[----------] [m2 tests from TypedTest/0, where TypeParam = int
 | 
				
			||||||
[0;32m[ RUN      ] [mTypedTest/0.Success
 | 
					[0;32m[ RUN      ] [mTypedTest/0.Success
 | 
				
			||||||
[0;32m[       OK ] [mTypedTest/0.Success
 | 
					[0;32m[       OK ] [mTypedTest/0.Success
 | 
				
			||||||
@@ -496,9 +508,9 @@ FooEnvironment::TearDown() called.
 | 
				
			|||||||
gtest_output_test_.cc:#: Failure
 | 
					gtest_output_test_.cc:#: Failure
 | 
				
			||||||
Failed
 | 
					Failed
 | 
				
			||||||
Expected fatal failure.
 | 
					Expected fatal failure.
 | 
				
			||||||
[0;32m[==========] [m52 tests from 22 test cases ran.
 | 
					[0;32m[==========] [m54 tests from 22 test cases ran.
 | 
				
			||||||
[0;32m[  PASSED  ] [m19 tests.
 | 
					[0;32m[  PASSED  ] [m19 tests.
 | 
				
			||||||
[0;31m[  FAILED  ] [m33 tests, listed below:
 | 
					[0;31m[  FAILED  ] [m35 tests, listed below:
 | 
				
			||||||
[0;31m[  FAILED  ] [mFatalFailureTest.FatalFailureInSubroutine
 | 
					[0;31m[  FAILED  ] [mFatalFailureTest.FatalFailureInSubroutine
 | 
				
			||||||
[0;31m[  FAILED  ] [mFatalFailureTest.FatalFailureInNestedSubroutine
 | 
					[0;31m[  FAILED  ] [mFatalFailureTest.FatalFailureInNestedSubroutine
 | 
				
			||||||
[0;31m[  FAILED  ] [mFatalFailureTest.NonfatalFailureInSubroutine
 | 
					[0;31m[  FAILED  ] [mFatalFailureTest.NonfatalFailureInSubroutine
 | 
				
			||||||
@@ -521,10 +533,12 @@ Expected fatal failure.
 | 
				
			|||||||
[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures
 | 
					[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures
 | 
				
			||||||
[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure
 | 
					[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure
 | 
				
			||||||
[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenStatementReturns
 | 
					[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenStatementReturns
 | 
				
			||||||
 | 
					[0;31m[  FAILED  ] [mExpectNonfatalFailureTest.FailsWhenStatementThrows
 | 
				
			||||||
[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure
 | 
					[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure
 | 
				
			||||||
[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures
 | 
					[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures
 | 
				
			||||||
[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure
 | 
					[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure
 | 
				
			||||||
[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenStatementReturns
 | 
					[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenStatementReturns
 | 
				
			||||||
 | 
					[0;31m[  FAILED  ] [mExpectFatalFailureTest.FailsWhenStatementThrows
 | 
				
			||||||
[0;31m[  FAILED  ] [mTypedTest/0.Failure, where TypeParam = int
 | 
					[0;31m[  FAILED  ] [mTypedTest/0.Failure, where TypeParam = int
 | 
				
			||||||
[0;31m[  FAILED  ] [mUnsigned/TypedTestP/0.Failure, where TypeParam = unsigned char
 | 
					[0;31m[  FAILED  ] [mUnsigned/TypedTestP/0.Failure, where TypeParam = unsigned char
 | 
				
			||||||
[0;31m[  FAILED  ] [mUnsigned/TypedTestP/1.Failure, where TypeParam = unsigned int
 | 
					[0;31m[  FAILED  ] [mUnsigned/TypedTestP/1.Failure, where TypeParam = unsigned int
 | 
				
			||||||
@@ -533,7 +547,7 @@ Expected fatal failure.
 | 
				
			|||||||
[0;31m[  FAILED  ] [mExpectFailureTest.ExpectFatalFailureOnAllThreads
 | 
					[0;31m[  FAILED  ] [mExpectFailureTest.ExpectFatalFailureOnAllThreads
 | 
				
			||||||
[0;31m[  FAILED  ] [mExpectFailureTest.ExpectNonFatalFailureOnAllThreads
 | 
					[0;31m[  FAILED  ] [mExpectFailureTest.ExpectNonFatalFailureOnAllThreads
 | 
				
			||||||
 | 
					
 | 
				
			||||||
33 FAILED TESTS
 | 
					35 FAILED TESTS
 | 
				
			||||||
[0;33m  YOU HAVE 1 DISABLED TEST
 | 
					[0;33m  YOU HAVE 1 DISABLED TEST
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[mNote: Google Test filter = FatalFailureTest.*:LoggingTest.*
 | 
					[mNote: Google Test filter = FatalFailureTest.*:LoggingTest.*
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2869,31 +2869,37 @@ TEST(AssertionTest, ASSERT_GT) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#if GTEST_HAS_EXCEPTIONS
 | 
					#if GTEST_HAS_EXCEPTIONS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void ThrowNothing() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Tests ASSERT_THROW.
 | 
					// Tests ASSERT_THROW.
 | 
				
			||||||
TEST(AssertionTest, ASSERT_THROW) {
 | 
					TEST(AssertionTest, ASSERT_THROW) {
 | 
				
			||||||
  ASSERT_THROW(ThrowAnInteger(), int);
 | 
					  ASSERT_THROW(ThrowAnInteger(), int);
 | 
				
			||||||
  EXPECT_FATAL_FAILURE(ASSERT_THROW(ThrowAnInteger(), bool),
 | 
					  EXPECT_FATAL_FAILURE(
 | 
				
			||||||
                       "Expected: ThrowAnInteger() throws an exception of type"\
 | 
					      ASSERT_THROW(ThrowAnInteger(), bool),
 | 
				
			||||||
                       " bool.\n  Actual: it throws a different type.");
 | 
					      "Expected: ThrowAnInteger() throws an exception of type bool.\n"
 | 
				
			||||||
  EXPECT_FATAL_FAILURE(ASSERT_THROW(1, bool),
 | 
					      "  Actual: it throws a different type.");
 | 
				
			||||||
                       "Expected: 1 throws an exception of type bool.\n"\
 | 
					  EXPECT_FATAL_FAILURE(
 | 
				
			||||||
                       "  Actual: it throws nothing.");
 | 
					      ASSERT_THROW(ThrowNothing(), bool),
 | 
				
			||||||
 | 
					      "Expected: ThrowNothing() throws an exception of type bool.\n"
 | 
				
			||||||
 | 
					      "  Actual: it throws nothing.");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Tests ASSERT_NO_THROW.
 | 
					// Tests ASSERT_NO_THROW.
 | 
				
			||||||
TEST(AssertionTest, ASSERT_NO_THROW) {
 | 
					TEST(AssertionTest, ASSERT_NO_THROW) {
 | 
				
			||||||
  ASSERT_NO_THROW(1);
 | 
					  ASSERT_NO_THROW(ThrowNothing());
 | 
				
			||||||
  EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()),
 | 
					  EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()),
 | 
				
			||||||
                       "Expected: ThrowAnInteger() doesn't throw an exception."\
 | 
					                       "Expected: ThrowAnInteger() doesn't throw an exception."
 | 
				
			||||||
                       "\n  Actual: it throws.");
 | 
					                       "\n  Actual: it throws.");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Tests ASSERT_ANY_THROW.
 | 
					// Tests ASSERT_ANY_THROW.
 | 
				
			||||||
TEST(AssertionTest, ASSERT_ANY_THROW) {
 | 
					TEST(AssertionTest, ASSERT_ANY_THROW) {
 | 
				
			||||||
  ASSERT_ANY_THROW(ThrowAnInteger());
 | 
					  ASSERT_ANY_THROW(ThrowAnInteger());
 | 
				
			||||||
  EXPECT_FATAL_FAILURE(ASSERT_ANY_THROW(1),
 | 
					  EXPECT_FATAL_FAILURE(
 | 
				
			||||||
                       "Expected: 1 throws an exception.\n  Actual: it "\
 | 
					      ASSERT_ANY_THROW(ThrowNothing()),
 | 
				
			||||||
                       "doesn't.");
 | 
					      "Expected: ThrowNothing() throws an exception.\n"
 | 
				
			||||||
 | 
					      "  Actual: it doesn't.");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif  // GTEST_HAS_EXCEPTIONS
 | 
					#endif  // GTEST_HAS_EXCEPTIONS
 | 
				
			||||||
@@ -3149,7 +3155,7 @@ TEST(ExpectThrowTest, DoesNotGenerateUnreachableCodeWarning) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
 | 
					TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
 | 
				
			||||||
  if (false)
 | 
					  if (false)
 | 
				
			||||||
    EXPECT_THROW(1, bool);
 | 
					    EXPECT_THROW(ThrowNothing(), bool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (true)
 | 
					  if (true)
 | 
				
			||||||
    EXPECT_THROW(ThrowAnInteger(), int);
 | 
					    EXPECT_THROW(ThrowAnInteger(), int);
 | 
				
			||||||
@@ -3160,12 +3166,12 @@ TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
 | 
				
			|||||||
    EXPECT_NO_THROW(ThrowAnInteger());
 | 
					    EXPECT_NO_THROW(ThrowAnInteger());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (true)
 | 
					  if (true)
 | 
				
			||||||
    EXPECT_NO_THROW(1);
 | 
					    EXPECT_NO_THROW(ThrowNothing());
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    ;
 | 
					    ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (false)
 | 
					  if (false)
 | 
				
			||||||
    EXPECT_ANY_THROW(1);
 | 
					    EXPECT_ANY_THROW(ThrowNothing());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (true)
 | 
					  if (true)
 | 
				
			||||||
    EXPECT_ANY_THROW(ThrowAnInteger());
 | 
					    EXPECT_ANY_THROW(ThrowAnInteger());
 | 
				
			||||||
@@ -3424,27 +3430,29 @@ TEST(ExpectTest, EXPECT_GT) {
 | 
				
			|||||||
TEST(ExpectTest, EXPECT_THROW) {
 | 
					TEST(ExpectTest, EXPECT_THROW) {
 | 
				
			||||||
  EXPECT_THROW(ThrowAnInteger(), int);
 | 
					  EXPECT_THROW(ThrowAnInteger(), int);
 | 
				
			||||||
  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool),
 | 
					  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool),
 | 
				
			||||||
                          "Expected: ThrowAnInteger() throws an exception of "\
 | 
					                          "Expected: ThrowAnInteger() throws an exception of "
 | 
				
			||||||
                          "type bool.\n  Actual: it throws a different type.");
 | 
					                          "type bool.\n  Actual: it throws a different type.");
 | 
				
			||||||
  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(1, bool),
 | 
					  EXPECT_NONFATAL_FAILURE(
 | 
				
			||||||
                          "Expected: 1 throws an exception of type bool.\n"\
 | 
					      EXPECT_THROW(ThrowNothing(), bool),
 | 
				
			||||||
                          "  Actual: it throws nothing.");
 | 
					      "Expected: ThrowNothing() throws an exception of type bool.\n"
 | 
				
			||||||
 | 
					      "  Actual: it throws nothing.");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Tests EXPECT_NO_THROW.
 | 
					// Tests EXPECT_NO_THROW.
 | 
				
			||||||
TEST(ExpectTest, EXPECT_NO_THROW) {
 | 
					TEST(ExpectTest, EXPECT_NO_THROW) {
 | 
				
			||||||
  EXPECT_NO_THROW(1);
 | 
					  EXPECT_NO_THROW(ThrowNothing());
 | 
				
			||||||
  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()),
 | 
					  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()),
 | 
				
			||||||
                          "Expected: ThrowAnInteger() doesn't throw an "\
 | 
					                          "Expected: ThrowAnInteger() doesn't throw an "
 | 
				
			||||||
                          "exception.\n  Actual: it throws.");
 | 
					                          "exception.\n  Actual: it throws.");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Tests EXPECT_ANY_THROW.
 | 
					// Tests EXPECT_ANY_THROW.
 | 
				
			||||||
TEST(ExpectTest, EXPECT_ANY_THROW) {
 | 
					TEST(ExpectTest, EXPECT_ANY_THROW) {
 | 
				
			||||||
  EXPECT_ANY_THROW(ThrowAnInteger());
 | 
					  EXPECT_ANY_THROW(ThrowAnInteger());
 | 
				
			||||||
  EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(1),
 | 
					  EXPECT_NONFATAL_FAILURE(
 | 
				
			||||||
                          "Expected: 1 throws an exception.\n  Actual: it "\
 | 
					      EXPECT_ANY_THROW(ThrowNothing()),
 | 
				
			||||||
                          "doesn't.");
 | 
					      "Expected: ThrowNothing() throws an exception.\n"
 | 
				
			||||||
 | 
					      "  Actual: it doesn't.");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif  // GTEST_HAS_EXCEPTIONS
 | 
					#endif  // GTEST_HAS_EXCEPTIONS
 | 
				
			||||||
@@ -5056,8 +5064,8 @@ TEST(StreamingAssertionsTest, Throw) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(StreamingAssertionsTest, NoThrow) {
 | 
					TEST(StreamingAssertionsTest, NoThrow) {
 | 
				
			||||||
  EXPECT_NO_THROW(1) << "unexpected failure";
 | 
					  EXPECT_NO_THROW(ThrowNothing()) << "unexpected failure";
 | 
				
			||||||
  ASSERT_NO_THROW(1) << "unexpected failure";
 | 
					  ASSERT_NO_THROW(ThrowNothing()) << "unexpected failure";
 | 
				
			||||||
  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()) <<
 | 
					  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()) <<
 | 
				
			||||||
                          "expected failure", "expected failure");
 | 
					                          "expected failure", "expected failure");
 | 
				
			||||||
  EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()) <<
 | 
					  EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()) <<
 | 
				
			||||||
@@ -5067,9 +5075,9 @@ TEST(StreamingAssertionsTest, NoThrow) {
 | 
				
			|||||||
TEST(StreamingAssertionsTest, AnyThrow) {
 | 
					TEST(StreamingAssertionsTest, AnyThrow) {
 | 
				
			||||||
  EXPECT_ANY_THROW(ThrowAnInteger()) << "unexpected failure";
 | 
					  EXPECT_ANY_THROW(ThrowAnInteger()) << "unexpected failure";
 | 
				
			||||||
  ASSERT_ANY_THROW(ThrowAnInteger()) << "unexpected failure";
 | 
					  ASSERT_ANY_THROW(ThrowAnInteger()) << "unexpected failure";
 | 
				
			||||||
  EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(1) <<
 | 
					  EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(ThrowNothing()) <<
 | 
				
			||||||
                          "expected failure", "expected failure");
 | 
					                          "expected failure", "expected failure");
 | 
				
			||||||
  EXPECT_FATAL_FAILURE(ASSERT_ANY_THROW(1) <<
 | 
					  EXPECT_FATAL_FAILURE(ASSERT_ANY_THROW(ThrowNothing()) <<
 | 
				
			||||||
                       "expected failure", "expected failure");
 | 
					                       "expected failure", "expected failure");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user