Skip to content

Commit 67bf112

Browse files
deps: update googletest to 90a4152
1 parent a822a1c commit 67bf112

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

deps/googletest/include/gtest/internal/gtest-internal.h

+14-22
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,17 @@ class FloatingPoint {
290290
// around may change its bits, although the new value is guaranteed
291291
// to be also a NAN. Therefore, don't expect this constructor to
292292
// preserve the bits in x when x is a NAN.
293-
explicit FloatingPoint(const RawType& x) { u_.value_ = x; }
293+
explicit FloatingPoint(RawType x) { memcpy(&bits_, &x, sizeof(x)); }
294294

295295
// Static methods
296296

297297
// Reinterprets a bit pattern as a floating-point number.
298298
//
299299
// This function is needed to test the AlmostEquals() method.
300-
static RawType ReinterpretBits(const Bits bits) {
301-
FloatingPoint fp(0);
302-
fp.u_.bits_ = bits;
303-
return fp.u_.value_;
300+
static RawType ReinterpretBits(Bits bits) {
301+
RawType fp;
302+
memcpy(&fp, &bits, sizeof(fp));
303+
return fp;
304304
}
305305

306306
// Returns the floating-point number that represent positive infinity.
@@ -309,16 +309,16 @@ class FloatingPoint {
309309
// Non-static methods
310310

311311
// Returns the bits that represents this number.
312-
const Bits& bits() const { return u_.bits_; }
312+
const Bits& bits() const { return bits_; }
313313

314314
// Returns the exponent bits of this number.
315-
Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }
315+
Bits exponent_bits() const { return kExponentBitMask & bits_; }
316316

317317
// Returns the fraction bits of this number.
318-
Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }
318+
Bits fraction_bits() const { return kFractionBitMask & bits_; }
319319

320320
// Returns the sign bit of this number.
321-
Bits sign_bit() const { return kSignBitMask & u_.bits_; }
321+
Bits sign_bit() const { return kSignBitMask & bits_; }
322322

323323
// Returns true if and only if this is NAN (not a number).
324324
bool is_nan() const {
@@ -332,23 +332,16 @@ class FloatingPoint {
332332
//
333333
// - returns false if either number is (or both are) NAN.
334334
// - treats really large numbers as almost equal to infinity.
335-
// - thinks +0.0 and -0.0 are 0 DLP's apart.
335+
// - thinks +0.0 and -0.0 are 0 ULP's apart.
336336
bool AlmostEquals(const FloatingPoint& rhs) const {
337337
// The IEEE standard says that any comparison operation involving
338338
// a NAN must return false.
339339
if (is_nan() || rhs.is_nan()) return false;
340340

341-
return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_) <=
342-
kMaxUlps;
341+
return DistanceBetweenSignAndMagnitudeNumbers(bits_, rhs.bits_) <= kMaxUlps;
343342
}
344343

345344
private:
346-
// The data type used to store the actual floating-point number.
347-
union FloatingPointUnion {
348-
RawType value_; // The raw floating-point number.
349-
Bits bits_; // The bits that represent the number.
350-
};
351-
352345
// Converts an integer from the sign-and-magnitude representation to
353346
// the biased representation. More precisely, let N be 2 to the
354347
// power of (kBitCount - 1), an integer x is represented by the
@@ -364,7 +357,7 @@ class FloatingPoint {
364357
//
365358
// Read https://en.wikipedia.org/wiki/Signed_number_representations
366359
// for more details on signed number representations.
367-
static Bits SignAndMagnitudeToBiased(const Bits& sam) {
360+
static Bits SignAndMagnitudeToBiased(Bits sam) {
368361
if (kSignBitMask & sam) {
369362
// sam represents a negative number.
370363
return ~sam + 1;
@@ -376,14 +369,13 @@ class FloatingPoint {
376369

377370
// Given two numbers in the sign-and-magnitude representation,
378371
// returns the distance between them as an unsigned number.
379-
static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits& sam1,
380-
const Bits& sam2) {
372+
static Bits DistanceBetweenSignAndMagnitudeNumbers(Bits sam1, Bits sam2) {
381373
const Bits biased1 = SignAndMagnitudeToBiased(sam1);
382374
const Bits biased2 = SignAndMagnitudeToBiased(sam2);
383375
return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
384376
}
385377

386-
FloatingPointUnion u_;
378+
Bits bits_; // The bits that represent the number.
387379
};
388380

389381
// Typedefs the instances of the FloatingPoint template class that we

deps/googletest/include/gtest/internal/gtest-port.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,14 @@
282282

283283
// Detect C++ feature test macros as gracefully as possible.
284284
// MSVC >= 19.15, Clang >= 3.4.1, and GCC >= 4.1.2 support feature test macros.
285-
#if GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L && \
286-
(!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE(<version>))
287-
#include <version> // C++20 and later
288-
#elif (!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE(<ciso646>))
285+
//
286+
// GCC15 warns that <ciso646> is deprecated in C++17 and suggests using
287+
// <version> instead, even though <version> is not available in C++17 mode prior
288+
// to GCC9.
289+
#if GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L || \
290+
GTEST_INTERNAL_HAS_INCLUDE(<version>)
291+
#include <version> // C++20 or <version> support.
292+
#else
289293
#include <ciso646> // Pre-C++20
290294
#endif
291295

0 commit comments

Comments
 (0)