From fe4d5f10840c5f62b984364a4d41719f1bc079a2 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 23 Sep 2020 17:32:45 -0400 Subject: [PATCH] Googletest export Revision of recent DoubleNearPredFormat change to support more toolchains. isnan() is a macro in C99, and std::isnan() is a function in C++11. The previous change used `isnan` directly, and broke some tests in open source. This CL changes it to follow the practice in gmock-matchers.h, and spell uses of isnan as (std::isnan)(f) . The parens around `std::isnan` prevent it from being recognized as a macro in the preprocessor. PiperOrigin-RevId: 333374377 --- googletest/src/gtest.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 293cc039..b5bc3539 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -35,7 +35,6 @@ #include "gtest/gtest-spi.h" #include -#include #include #include #include @@ -45,6 +44,7 @@ #include #include // NOLINT +#include #include #include #include @@ -1527,7 +1527,8 @@ AssertionResult DoubleNearPredFormat(const char* expr1, // requiring exotic floating-point knowledge. // Don't do an epsilon check if abs_error is zero because that implies // that an equality check was actually intended. - if (!isnan(val1) && !isnan(val2) && abs_error > 0 && abs_error < epsilon) { + if (!(std::isnan)(val1) && !(std::isnan)(val2) && abs_error > 0 && + abs_error < epsilon) { return AssertionFailure() << "The difference between " << expr1 << " and " << expr2 << " is " << diff << ", where\n"