diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-01-29 06:49:00 (GMT) |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-01-29 06:49:00 (GMT) |
commit | 4b83461e9772cce62e84310060fe84172e9bf4ba (patch) | |
tree | 81c398e25c7db78187ecb3c6a756b9996140943b /include | |
parent | c946ae60194727ede9d3ef44754839f48541a981 (diff) | |
download | googletest-4b83461e9772cce62e84310060fe84172e9bf4ba.zip googletest-4b83461e9772cce62e84310060fe84172e9bf4ba.tar.gz googletest-4b83461e9772cce62e84310060fe84172e9bf4ba.tar.bz2 |
Fixes some warnings when compiled with MSVC at warning level 4.
Diffstat (limited to 'include')
-rw-r--r-- | include/gtest/gtest.h | 16 | ||||
-rw-r--r-- | include/gtest/internal/gtest-internal.h | 5 |
2 files changed, 17 insertions, 4 deletions
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h index dfa338b..f1184de 100644 --- a/include/gtest/gtest.h +++ b/include/gtest/gtest.h @@ -614,10 +614,20 @@ AssertionResult CmpHelperEQ(const char* expected_expression, const char* actual_expression, const T1& expected, const T2& actual) { +#ifdef _MSC_VER +#pragma warning(push) // Saves the current warning state. +#pragma warning(disable:4389) // Temporarily disables warning on + // signed/unsigned mismatch. +#endif + if (expected == actual) { return AssertionSuccess(); } +#ifdef _MSC_VER +#pragma warning(pop) // Restores the warning state. +#endif + return EqFailure(expected_expression, actual_expression, FormatForComparisonFailureMessage(expected, actual), @@ -688,7 +698,7 @@ class EqHelper<true> { template <typename T1, typename T2> static AssertionResult Compare(const char* expected_expression, const char* actual_expression, - const T1& expected, + const T1& /* expected */, T2* actual) { // We already know that 'expected' is a null pointer. return CmpHelperEQ(expected_expression, actual_expression, @@ -1315,7 +1325,7 @@ bool StaticAssertTypeEq() { // value, as it always calls GetTypeId<>() from the Google Test // framework. #define TEST(test_case_name, test_name)\ - GTEST_TEST_(test_case_name, test_name,\ + GTEST_TEST_(test_case_name, test_name, \ ::testing::Test, ::testing::internal::GetTestTypeId()) @@ -1346,7 +1356,7 @@ bool StaticAssertTypeEq() { // } #define TEST_F(test_fixture, test_name)\ - GTEST_TEST_(test_fixture, test_name, test_fixture,\ + GTEST_TEST_(test_fixture, test_name, test_fixture, \ ::testing::internal::GetTypeId<test_fixture>()) // Use this macro in main() to run all tests. It returns 0 if all diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h index 37faaae..541c89b 100644 --- a/include/gtest/internal/gtest-internal.h +++ b/include/gtest/internal/gtest-internal.h @@ -748,6 +748,9 @@ String GetCurrentOsStackTraceExceptTop(UnitTest* unit_test, int skip_count); // Returns the number of failed test parts in the given test result object. int GetFailedPartCount(const TestResult* result); +// A helper for suppressing warnings on unreachable code in some macros. +inline bool True() { return true; } + } // namespace internal } // namespace testing @@ -835,7 +838,7 @@ int GetFailedPartCount(const TestResult* result); GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ if (const char* gtest_msg = "") { \ ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \ - { statement; } \ + if (::testing::internal::True()) { statement; } \ if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \ gtest_msg = "Expected: " #statement " doesn't generate new fatal " \ "failures in the current thread.\n" \ |