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
This commit is contained in:
Abseil Team 2020-09-23 17:32:45 -04:00 committed by vslashg
parent df94fc5f7e
commit fe4d5f1084

View File

@ -35,7 +35,6 @@
#include "gtest/gtest-spi.h"
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@ -45,6 +44,7 @@
#include <algorithm>
#include <chrono> // NOLINT
#include <cmath>
#include <cstdint>
#include <iomanip>
#include <limits>
@ -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"