Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
2d3543f8
Commit
2d3543f8
authored
Sep 18, 2013
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoids clash with the max() macro on Windows
parent
c306ef2e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
gtest-internal.h
include/gtest/internal/gtest-internal.h
+11
-0
gtest-death-test_test.cc
test/gtest-death-test_test.cc
+5
-7
No files found.
include/gtest/internal/gtest-internal.h
View file @
2d3543f8
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
#endif
#endif
#include <ctype.h>
#include <ctype.h>
#include <float.h>
#include <string.h>
#include <string.h>
#include <iomanip>
#include <iomanip>
#include <limits>
#include <limits>
...
@@ -294,6 +295,9 @@ class FloatingPoint {
...
@@ -294,6 +295,9 @@ class FloatingPoint {
return
ReinterpretBits
(
kExponentBitMask
);
return
ReinterpretBits
(
kExponentBitMask
);
}
}
// Returns the maximum representable finite floating-point number.
static
RawType
Max
();
// Non-static methods
// Non-static methods
// Returns the bits that represents this number.
// Returns the bits that represents this number.
...
@@ -374,6 +378,13 @@ class FloatingPoint {
...
@@ -374,6 +378,13 @@ class FloatingPoint {
FloatingPointUnion
u_
;
FloatingPointUnion
u_
;
};
};
// We cannot use std::numeric_limits<T>::max() as it clashes with the max()
// macro defined by <windows.h>.
template
<>
inline
float
FloatingPoint
<
float
>::
Max
()
{
return
FLT_MAX
;
}
template
<>
inline
double
FloatingPoint
<
double
>::
Max
()
{
return
DBL_MAX
;
}
// Typedefs the instances of the FloatingPoint template class that we
// Typedefs the instances of the FloatingPoint template class that we
// care to use.
// care to use.
typedef
FloatingPoint
<
float
>
Float
;
typedef
FloatingPoint
<
float
>
Float
;
...
...
test/gtest-death-test_test.cc
View file @
2d3543f8
...
@@ -45,7 +45,6 @@ using testing::internal::AlwaysTrue;
...
@@ -45,7 +45,6 @@ using testing::internal::AlwaysTrue;
# else
# else
# include <unistd.h>
# include <unistd.h>
# include <sys/wait.h> // For waitpid.
# include <sys/wait.h> // For waitpid.
# include <limits> // For std::numeric_limits.
# endif // GTEST_OS_WINDOWS
# endif // GTEST_OS_WINDOWS
# include <limits.h>
# include <limits.h>
...
@@ -1123,17 +1122,16 @@ TEST(AutoHandleTest, AutoHandleWorks) {
...
@@ -1123,17 +1122,16 @@ TEST(AutoHandleTest, AutoHandleWorks) {
# if GTEST_OS_WINDOWS
# if GTEST_OS_WINDOWS
typedef
unsigned
__int64
BiggestParsable
;
typedef
unsigned
__int64
BiggestParsable
;
typedef
signed
__int64
BiggestSignedParsable
;
typedef
signed
__int64
BiggestSignedParsable
;
const
BiggestParsable
kBiggestParsableMax
=
ULLONG_MAX
;
const
BiggestSignedParsable
kBiggestSignedParsableMax
=
LLONG_MAX
;
# else
# else
typedef
unsigned
long
long
BiggestParsable
;
typedef
unsigned
long
long
BiggestParsable
;
typedef
signed
long
long
BiggestSignedParsable
;
typedef
signed
long
long
BiggestSignedParsable
;
const
BiggestParsable
kBiggestParsableMax
=
::
std
::
numeric_limits
<
BiggestParsable
>::
max
();
const
BiggestSignedParsable
kBiggestSignedParsableMax
=
::
std
::
numeric_limits
<
BiggestSignedParsable
>::
max
();
# endif // GTEST_OS_WINDOWS
# endif // GTEST_OS_WINDOWS
// We cannot use std::numeric_limits<T>::max() as it clashes with the
// max() macro defined by <windows.h>.
const
BiggestParsable
kBiggestParsableMax
=
ULLONG_MAX
;
const
BiggestSignedParsable
kBiggestSignedParsableMax
=
LLONG_MAX
;
TEST
(
ParseNaturalNumberTest
,
RejectsInvalidFormat
)
{
TEST
(
ParseNaturalNumberTest
,
RejectsInvalidFormat
)
{
BiggestParsable
result
=
0
;
BiggestParsable
result
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment