Commit fe4d5f10 authored by Abseil Team's avatar Abseil Team Committed by vslashg
Browse files

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
parent df94fc5f
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment