Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
88e97c82
Commit
88e97c82
authored
Dec 16, 2009
by
zhanyong.wan
Browse files
Removes uses of GTEST_HAS_STD_STRING.
parent
075b76bb
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
90 additions
and
149 deletions
+90
-149
include/gtest/gtest.h
include/gtest/gtest.h
+10
-19
include/gtest/internal/gtest-internal.h
include/gtest/internal/gtest-internal.h
+0
-2
include/gtest/internal/gtest-port.h
include/gtest/internal/gtest-port.h
+12
-54
include/gtest/internal/gtest-string.h
include/gtest/internal/gtest-string.h
+0
-4
run_tests.py
run_tests.py
+8
-1
scons/SConscript.common
scons/SConscript.common
+0
-3
scons/SConstruct
scons/SConstruct
+5
-1
scons/SConstruct.common
scons/SConstruct.common
+15
-8
src/gtest.cc
src/gtest.cc
+0
-14
test/gtest-death-test_test.cc
test/gtest-death-test_test.cc
+0
-2
test/gtest-message_test.cc
test/gtest-message_test.cc
+0
-4
test/gtest-port_test.cc
test/gtest-port_test.cc
+0
-2
test/gtest_output_test.py
test/gtest_output_test.py
+14
-14
test/gtest_unittest.cc
test/gtest_unittest.cc
+0
-18
test/run_tests_util.py
test/run_tests_util.py
+26
-3
No files found.
include/gtest/gtest.h
View file @
88e97c82
...
@@ -62,24 +62,19 @@
...
@@ -62,24 +62,19 @@
#include <gtest/gtest-typed-test.h>
#include <gtest/gtest-typed-test.h>
// Depending on the platform, different string classes are available.
// Depending on the platform, different string classes are available.
// On Windows, ::std::string compiles only when exceptions are
// On Linux, in addition to ::std::string, Google also makes use of
// enabled. On Linux, in addition to ::std::string, Google also makes
// class ::string, which has the same interface as ::std::string, but
// use of class ::string, which has the same interface as
// has a different implementation.
// ::std::string, but has a different implementation.
//
//
// The user can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that
// The user can tell us whether ::std::string is available in his
// ::string is available AND is a distinct type to ::std::string, or
// environment by defining the macro GTEST_HAS_STD_STRING to either 1
// define it to 0 to indicate otherwise.
// or 0 on the compiler command line. He can also define
// GTEST_HAS_GLOBAL_STRING to 1 to indicate that ::string is available
// AND is a distinct type to ::std::string, or define it to 0 to
// indicate otherwise.
//
//
// If the user's ::std::string and ::string are the same class due to
// If the user's ::std::string and ::string are the same class due to
// aliasing, he should define GTEST_HAS_STD_STRING to 1 and
// aliasing, he should define GTEST_HAS_GLOBAL_STRING to 0.
// GTEST_HAS_GLOBAL_STRING to 0.
//
//
// If the user doesn't define GTEST_HAS_
STD
_STRING
and/or
// If the user doesn't define GTEST_HAS_
GLOBAL
_STRING
, it is defined
//
GTEST_HAS_GLOBAL_STRING, they are defined
heuristically.
// heuristically.
namespace
testing
{
namespace
testing
{
...
@@ -1210,11 +1205,9 @@ void InitGoogleTest(int* argc, wchar_t** argv);
...
@@ -1210,11 +1205,9 @@ void InitGoogleTest(int* argc, wchar_t** argv);
namespace
internal
{
namespace
internal
{
// These overloaded versions handle ::std::string and ::std::wstring.
// These overloaded versions handle ::std::string and ::std::wstring.
#if GTEST_HAS_STD_STRING
inline
String
FormatForFailureMessage
(
const
::
std
::
string
&
str
)
{
inline
String
FormatForFailureMessage
(
const
::
std
::
string
&
str
)
{
return
(
Message
()
<<
'"'
<<
str
<<
'"'
).
GetString
();
return
(
Message
()
<<
'"'
<<
str
<<
'"'
).
GetString
();
}
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
inline
String
FormatForFailureMessage
(
const
::
std
::
wstring
&
wstr
)
{
inline
String
FormatForFailureMessage
(
const
::
std
::
wstring
&
wstr
)
{
...
@@ -1464,14 +1457,12 @@ AssertionResult IsNotSubstring(
...
@@ -1464,14 +1457,12 @@ AssertionResult IsNotSubstring(
AssertionResult
IsNotSubstring
(
AssertionResult
IsNotSubstring
(
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
wchar_t
*
needle
,
const
wchar_t
*
haystack
);
const
wchar_t
*
needle
,
const
wchar_t
*
haystack
);
#if GTEST_HAS_STD_STRING
AssertionResult
IsSubstring
(
AssertionResult
IsSubstring
(
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
);
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
);
AssertionResult
IsNotSubstring
(
AssertionResult
IsNotSubstring
(
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
);
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
);
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
AssertionResult
IsSubstring
(
AssertionResult
IsSubstring
(
...
...
include/gtest/internal/gtest-internal.h
View file @
88e97c82
...
@@ -259,9 +259,7 @@ inline String FormatForComparisonFailureMessage(\
...
@@ -259,9 +259,7 @@ inline String FormatForComparisonFailureMessage(\
return operand1_printer(str);\
return operand1_printer(str);\
}
}
#if GTEST_HAS_STD_STRING
GTEST_FORMAT_IMPL_
(
::
std
::
string
,
String
::
ShowCStringQuoted
)
GTEST_FORMAT_IMPL_
(
::
std
::
string
,
String
::
ShowCStringQuoted
)
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
GTEST_FORMAT_IMPL_
(
::
std
::
wstring
,
String
::
ShowWideCStringQuoted
)
GTEST_FORMAT_IMPL_
(
::
std
::
wstring
,
String
::
ShowWideCStringQuoted
)
#endif // GTEST_HAS_STD_WSTRING
#endif // GTEST_HAS_STD_WSTRING
...
...
include/gtest/internal/gtest-port.h
View file @
88e97c82
...
@@ -52,9 +52,6 @@
...
@@ -52,9 +52,6 @@
// is/isn't available.
// is/isn't available.
// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't
// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't
// enabled.
// enabled.
// GTEST_HAS_STD_STRING - Define it to 1/0 to indicate that
// std::string does/doesn't work (Google Test can
// be used where std::string is unavailable).
// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
// std::wstring does/doesn't work (Google Test can
// std::wstring does/doesn't work (Google Test can
// be used where std::wstring is unavailable).
// be used where std::wstring is unavailable).
...
@@ -261,23 +258,14 @@
...
@@ -261,23 +258,14 @@
#endif // defined(__GNUC__) && __EXCEPTIONS
#endif // defined(__GNUC__) && __EXCEPTIONS
#endif // defined(_MSC_VER) || defined(__BORLANDC__)
#endif // defined(_MSC_VER) || defined(__BORLANDC__)
// Determines whether ::std::string and ::string are available.
#if !defined(GTEST_HAS_STD_STRING)
// Even though we don't use this macro any longer, we keep it in case
#ifndef GTEST_HAS_STD_STRING
// some clients still depend on it.
// The user didn't tell us whether ::std::string is available, so we
// need to figure it out. The only environment that we know
// ::std::string is not available is MSVC 7.1 or lower with exceptions
// disabled.
#if defined(_MSC_VER) && (_MSC_VER < 1400) && !GTEST_HAS_EXCEPTIONS
#if !GTEST_ALLOW_VC71_WITHOUT_EXCEPTIONS_
#error "When compiling gtest using MSVC 7.1, exceptions must be enabled."
#error "Otherwise std::string and std::vector don't compile."
#endif
#define GTEST_HAS_STD_STRING 0
#else
#define GTEST_HAS_STD_STRING 1
#define GTEST_HAS_STD_STRING 1
#endif
#elif !GTEST_HAS_STD_STRING
#endif // GTEST_HAS_STD_STRING
// The user told us that ::std::string isn't available.
#error "Google Test cannot be used where ::std::string isn't available."
#endif // !defined(GTEST_HAS_STD_STRING)
#ifndef GTEST_HAS_GLOBAL_STRING
#ifndef GTEST_HAS_GLOBAL_STRING
// The user didn't tell us whether ::string is available, so we need
// The user didn't tell us whether ::string is available, so we need
...
@@ -293,14 +281,10 @@
...
@@ -293,14 +281,10 @@
// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring
// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring
// is available.
// is available.
#if GTEST_OS_CYGWIN || GTEST_OS_SOLARIS
// Cygwin 1.5 and below doesn't support ::std::wstring.
// Cygwin 1.5 and below doesn't support ::std::wstring.
// Cygwin 1.7 might add wstring support; this should be updated when clear.
// Cygwin 1.7 might add wstring support; this should be updated when clear.
// Solaris' libc++ doesn't support it either.
// Solaris' libc++ doesn't support it either.
#define GTEST_HAS_STD_WSTRING 0
#define GTEST_HAS_STD_WSTRING (!(GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
#else
#define GTEST_HAS_STD_WSTRING GTEST_HAS_STD_STRING
#endif // GTEST_OS_CYGWIN || GTEST_OS_SOLARIS
#endif // GTEST_HAS_STD_WSTRING
#endif // GTEST_HAS_STD_WSTRING
...
@@ -311,17 +295,8 @@
...
@@ -311,17 +295,8 @@
(GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
(GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
#endif // GTEST_HAS_GLOBAL_WSTRING
#endif // GTEST_HAS_GLOBAL_WSTRING
#if GTEST_HAS_STD_STRING || GTEST_HAS_GLOBAL_STRING || \
GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
#include <string> // NOLINT
#include <string> // NOLINT
#endif // GTEST_HAS_STD_STRING || GTEST_HAS_GLOBAL_STRING ||
// GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
#if GTEST_HAS_STD_STRING
#include <sstream> // NOLINT
#include <sstream> // NOLINT
#else
#include <strstream> // NOLINT
#endif // GTEST_HAS_STD_STRING
// Determines whether RTTI is available.
// Determines whether RTTI is available.
#ifndef GTEST_HAS_RTTI
#ifndef GTEST_HAS_RTTI
...
@@ -457,15 +432,10 @@
...
@@ -457,15 +432,10 @@
#endif // GTEST_HAS_CLONE
#endif // GTEST_HAS_CLONE
// Determines whether to support death tests.
// Determines whether to support death tests.
// Google Test does not support death tests for VC 7.1 and earlier for
// Google Test does not support death tests for VC 7.1 and earlier as
// these reasons:
// abort() in a VC 7.1 application compiled as GUI in debug config
// 1. std::vector does not build in VC 7.1 when exceptions are disabled.
// 2. std::string does not build in VC 7.1 when exceptions are disabled
// (this is covered by GTEST_HAS_STD_STRING guard).
// 3. abort() in a VC 7.1 application compiled as GUI in debug config
// pops up a dialog window that cannot be suppressed programmatically.
// pops up a dialog window that cannot be suppressed programmatically.
#if GTEST_HAS_STD_STRING && \
#if (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || \
(GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || \
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || GTEST_OS_WINDOWS_MINGW)
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || GTEST_OS_WINDOWS_MINGW)
#define GTEST_HAS_DEATH_TEST 1
#define GTEST_HAS_DEATH_TEST 1
#include <vector> // NOLINT
#include <vector> // NOLINT
...
@@ -572,15 +542,7 @@ namespace internal {
...
@@ -572,15 +542,7 @@ namespace internal {
class
String
;
class
String
;
// std::strstream is deprecated. However, we have to use it on
// Windows as std::stringstream won't compile on Windows when
// exceptions are disabled. We use std::stringstream on other
// platforms to avoid compiler warnings there.
#if GTEST_HAS_STD_STRING
typedef
::
std
::
stringstream
StrStream
;
typedef
::
std
::
stringstream
StrStream
;
#else
typedef
::
std
::
strstream
StrStream
;
#endif // GTEST_HAS_STD_STRING
// A helper for suppressing warnings on constant condition. It just
// A helper for suppressing warnings on constant condition. It just
// returns 'condition'.
// returns 'condition'.
...
@@ -629,9 +591,7 @@ class scoped_ptr {
...
@@ -629,9 +591,7 @@ class scoped_ptr {
class
RE
{
class
RE
{
public:
public:
// Constructs an RE from a string.
// Constructs an RE from a string.
#if GTEST_HAS_STD_STRING
RE
(
const
::
std
::
string
&
regex
)
{
Init
(
regex
.
c_str
());
}
// NOLINT
RE
(
const
::
std
::
string
&
regex
)
{
Init
(
regex
.
c_str
());
}
// NOLINT
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_GLOBAL_STRING
RE
(
const
::
string
&
regex
)
{
Init
(
regex
.
c_str
());
}
// NOLINT
RE
(
const
::
string
&
regex
)
{
Init
(
regex
.
c_str
());
}
// NOLINT
...
@@ -650,14 +610,12 @@ class RE {
...
@@ -650,14 +610,12 @@ class RE {
//
//
// TODO(wan@google.com): make FullMatch() and PartialMatch() work
// TODO(wan@google.com): make FullMatch() and PartialMatch() work
// when str contains NUL characters.
// when str contains NUL characters.
#if GTEST_HAS_STD_STRING
static
bool
FullMatch
(
const
::
std
::
string
&
str
,
const
RE
&
re
)
{
static
bool
FullMatch
(
const
::
std
::
string
&
str
,
const
RE
&
re
)
{
return
FullMatch
(
str
.
c_str
(),
re
);
return
FullMatch
(
str
.
c_str
(),
re
);
}
}
static
bool
PartialMatch
(
const
::
std
::
string
&
str
,
const
RE
&
re
)
{
static
bool
PartialMatch
(
const
::
std
::
string
&
str
,
const
RE
&
re
)
{
return
PartialMatch
(
str
.
c_str
(),
re
);
return
PartialMatch
(
str
.
c_str
(),
re
);
}
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_GLOBAL_STRING
static
bool
FullMatch
(
const
::
string
&
str
,
const
RE
&
re
)
{
static
bool
FullMatch
(
const
::
string
&
str
,
const
RE
&
re
)
{
...
...
include/gtest/internal/gtest-string.h
View file @
88e97c82
...
@@ -44,9 +44,7 @@
...
@@ -44,9 +44,7 @@
#include <string.h>
#include <string.h>
#include <gtest/internal/gtest-port.h>
#include <gtest/internal/gtest-port.h>
#if GTEST_HAS_GLOBAL_STRING || GTEST_HAS_STD_STRING
#include <string>
#include <string>
#endif // GTEST_HAS_GLOBAL_STRING || GTEST_HAS_STD_STRING
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
...
@@ -221,13 +219,11 @@ class String {
...
@@ -221,13 +219,11 @@ class String {
// Converting a ::std::string or ::string containing an embedded NUL
// Converting a ::std::string or ::string containing an embedded NUL
// character to a String will result in the prefix up to the first
// character to a String will result in the prefix up to the first
// NUL character.
// NUL character.
#if GTEST_HAS_STD_STRING
String
(
const
::
std
::
string
&
str
)
{
String
(
const
::
std
::
string
&
str
)
{
ConstructNonNull
(
str
.
c_str
(),
str
.
length
());
ConstructNonNull
(
str
.
c_str
(),
str
.
length
());
}
}
operator
::
std
::
string
()
const
{
return
::
std
::
string
(
c_str
(),
length
());
}
operator
::
std
::
string
()
const
{
return
::
std
::
string
(
c_str
(),
length
());
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_GLOBAL_STRING
String
(
const
::
string
&
str
)
{
String
(
const
::
string
&
str
)
{
...
...
run_tests.py
View file @
88e97c82
...
@@ -39,6 +39,12 @@ import sys
...
@@ -39,6 +39,12 @@ import sys
SCRIPT_DIR
=
os
.
path
.
dirname
(
__file__
)
or
'.'
SCRIPT_DIR
=
os
.
path
.
dirname
(
__file__
)
or
'.'
# Some Python tests don't work in all configurations.
PYTHON_TESTS_TO_SKIP
=
(
(
'win-dbg'
,
'gtest_throw_on_failure_test.py'
),
(
'win-opt'
,
'gtest_throw_on_failure_test.py'
),
)
sys
.
path
.
append
(
os
.
path
.
join
(
SCRIPT_DIR
,
'test'
))
sys
.
path
.
append
(
os
.
path
.
join
(
SCRIPT_DIR
,
'test'
))
import
run_tests_util
import
run_tests_util
...
@@ -50,7 +56,8 @@ def _Main():
...
@@ -50,7 +56,8 @@ def _Main():
test_runner
=
run_tests_util
.
TestRunner
(
script_dir
=
SCRIPT_DIR
)
test_runner
=
run_tests_util
.
TestRunner
(
script_dir
=
SCRIPT_DIR
)
tests
=
test_runner
.
GetTestsToRun
(
args
,
tests
=
test_runner
.
GetTestsToRun
(
args
,
options
.
configurations
,
options
.
configurations
,
options
.
built_configurations
)
options
.
built_configurations
,
python_tests_to_skip
=
PYTHON_TESTS_TO_SKIP
)
if
not
tests
:
if
not
tests
:
sys
.
exit
(
1
)
# Incorrect parameters given, abort execution.
sys
.
exit
(
1
)
# Incorrect parameters given, abort execution.
...
...
scons/SConscript.common
View file @
88e97c82
...
@@ -88,9 +88,6 @@ class EnvCreator:
...
@@ -88,9 +88,6 @@ class EnvCreator:
if env['PLATFORM'] == 'win32':
if env['PLATFORM'] == 'win32':
env.Append(CCFLAGS=['/EHsc'])
env.Append(CCFLAGS=['/EHsc'])
env.Append(CPPDEFINES='_HAS_EXCEPTIONS=1')
env.Append(CPPDEFINES='_HAS_EXCEPTIONS=1')
# Undoes the _TYPEINFO_ hack, which is unnecessary and only creates
# trouble when exceptions are enabled.
cls._Remove(env, 'CPPDEFINES', '_TYPEINFO_')
cls._Remove(env, 'CPPDEFINES', '_HAS_EXCEPTIONS=0')
cls._Remove(env, 'CPPDEFINES', '_HAS_EXCEPTIONS=0')
else:
else:
env.Append(CCFLAGS='-fexceptions')
env.Append(CCFLAGS='-fexceptions')
...
...
scons/SConstruct
View file @
88e97c82
...
@@ -50,8 +50,12 @@ sconstruct_helper.Initialize(build_root_path='..',
...
@@ -50,8 +50,12 @@ sconstruct_helper.Initialize(build_root_path='..',
win_base
=
sconstruct_helper
.
MakeWinBaseEnvironment
()
win_base
=
sconstruct_helper
.
MakeWinBaseEnvironment
()
# We don't support VC 7.1 with exceptions disabled, so we always
# enable exceptions for VC 7.1. For newer versions of VC, we still
# compile with exceptions disabled by default, as that's a more common
# setting for our users.
if
win_base
.
get
(
'MSVS_VERSION'
,
None
)
==
'7.1'
:
if
win_base
.
get
(
'MSVS_VERSION'
,
None
)
==
'7.1'
:
sconstruct_helper
.
AllowVc71StlWithout
Exceptions
(
win_base
)
sconstruct_helper
.
Enable
Exceptions
(
win_base
)
sconstruct_helper
.
MakeWinDebugEnvironment
(
win_base
,
'win-dbg'
)
sconstruct_helper
.
MakeWinDebugEnvironment
(
win_base
,
'win-dbg'
)
sconstruct_helper
.
MakeWinOptimizedEnvironment
(
win_base
,
'win-opt'
)
sconstruct_helper
.
MakeWinOptimizedEnvironment
(
win_base
,
'win-opt'
)
...
...
scons/SConstruct.common
View file @
88e97c82
...
@@ -45,6 +45,13 @@ class SConstructHelper:
...
@@ -45,6 +45,13 @@ class SConstructHelper:
# A dictionary to look up an environment by its name.
# A dictionary to look up an environment by its name.
self.env_dict = {}
self.env_dict = {}
def _Remove(self, env, attribute, value):
"""Removes the given attribute value from the environment."""
attribute_values = env[attribute]
if value in attribute_values:
attribute_values.remove(value)
def Initialize(self, build_root_path, support_multiple_win_builds=False):
def Initialize(self, build_root_path, support_multiple_win_builds=False):
test_env = Environment()
test_env = Environment()
platform = test_env['PLATFORM']
platform = test_env['PLATFORM']
...
@@ -83,13 +90,14 @@ class SConstructHelper:
...
@@ -83,13 +90,14 @@ class SConstructHelper:
# Enable scons -h
# Enable scons -h
Help(vars.GenerateHelpText(self.env_base))
Help(vars.GenerateHelpText(self.env_base))
def AllowVc71StlWithoutExceptions(self, env):
def EnableExceptions(self, env):
env.Append(
if env['PLATFORM'] == 'win32':
CPPDEFINES = [# needed for using some parts of STL with exception
env.Append(CCFLAGS=['/EHsc'])
# disabled. The scoop is given here, with comments
env.Append(CPPDEFINES='_HAS_EXCEPTIONS=1')
# from P.J. Plauger at
self._Remove(env, 'CPPDEFINES', '_HAS_EXCEPTIONS=0')
# http://groups.google.com/group/microsoft.public.vc.stl/browse_thread/thread/5e719833c6bdb177?q=_HAS_EXCEPTIONS+using+namespace+std&pli=1
else:
'_TYPEINFO_'])
env.Append(CCFLAGS='-fexceptions')
self._Remove(env, 'CCFLAGS', '-fno-exceptions')
def MakeWinBaseEnvironment(self):
def MakeWinBaseEnvironment(self):
win_base = self.env_base.Clone(
win_base = self.env_base.Clone(
...
@@ -117,7 +125,6 @@ class SConstructHelper:
...
@@ -117,7 +125,6 @@ class SConstructHelper:
'STRICT',
'STRICT',
'WIN32_LEAN_AND_MEAN',
'WIN32_LEAN_AND_MEAN',
'_HAS_EXCEPTIONS=0',
'_HAS_EXCEPTIONS=0',
'GTEST_ALLOW_VC71_WITHOUT_EXCEPTIONS_=1',
],
],
LIBPATH=['#/$MAIN_DIR/lib'],
LIBPATH=['#/$MAIN_DIR/lib'],
LINKFLAGS=['-MACHINE:x86', # Enable safe SEH (not supp. on x64)
LINKFLAGS=['-MACHINE:x86', # Enable safe SEH (not supp. on x64)
...
...
src/gtest.cc
View file @
88e97c82
...
@@ -1316,7 +1316,6 @@ AssertionResult IsNotSubstring(
...
@@ -1316,7 +1316,6 @@ AssertionResult IsNotSubstring(
return
IsSubstringImpl
(
false
,
needle_expr
,
haystack_expr
,
needle
,
haystack
);
return
IsSubstringImpl
(
false
,
needle_expr
,
haystack_expr
,
needle
,
haystack
);
}
}
#if GTEST_HAS_STD_STRING
AssertionResult
IsSubstring
(
AssertionResult
IsSubstring
(
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
char
*
needle_expr
,
const
char
*
haystack_expr
,
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
)
{
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
)
{
...
@@ -1328,7 +1327,6 @@ AssertionResult IsNotSubstring(
...
@@ -1328,7 +1327,6 @@ AssertionResult IsNotSubstring(
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
)
{
const
::
std
::
string
&
needle
,
const
::
std
::
string
&
haystack
)
{
return
IsSubstringImpl
(
false
,
needle_expr
,
haystack_expr
,
needle
,
haystack
);
return
IsSubstringImpl
(
false
,
needle_expr
,
haystack_expr
,
needle
,
haystack
);
}
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
AssertionResult
IsSubstring
(
AssertionResult
IsSubstring
(
...
@@ -1748,14 +1746,9 @@ String String::Format(const char * format, ...) {
...
@@ -1748,14 +1746,9 @@ String String::Format(const char * format, ...) {
// Converts the buffer in a StrStream to a String, converting NUL
// Converts the buffer in a StrStream to a String, converting NUL
// bytes to "\\0" along the way.
// bytes to "\\0" along the way.
String
StrStreamToString
(
StrStream
*
ss
)
{
String
StrStreamToString
(
StrStream
*
ss
)
{
#if GTEST_HAS_STD_STRING
const
::
std
::
string
&
str
=
ss
->
str
();
const
::
std
::
string
&
str
=
ss
->
str
();
const
char
*
const
start
=
str
.
c_str
();
const
char
*
const
start
=
str
.
c_str
();
const
char
*
const
end
=
start
+
str
.
length
();
const
char
*
const
end
=
start
+
str
.
length
();
#else
const
char
*
const
start
=
ss
->
str
();
const
char
*
const
end
=
start
+
ss
->
pcount
();
#endif // GTEST_HAS_STD_STRING
// We need to use a helper StrStream to do this transformation
// We need to use a helper StrStream to do this transformation
// because String doesn't support push_back().
// because String doesn't support push_back().
...
@@ -1768,14 +1761,7 @@ String StrStreamToString(StrStream* ss) {
...
@@ -1768,14 +1761,7 @@ String StrStreamToString(StrStream* ss) {
}
}
}
}
#if GTEST_HAS_STD_STRING
return
String
(
helper
.
str
().
c_str
());
return
String
(
helper
.
str
().
c_str
());
#else
const
String
str
(
helper
.
str
(),
helper
.
pcount
());
helper
.
freeze
(
false
);
ss
->
freeze
(
false
);
return
str
;
#endif // GTEST_HAS_STD_STRING
}
}
// Appends the user-supplied message to the Google-Test-generated message.
// Appends the user-supplied message to the Google-Test-generated message.
...
...
test/gtest-death-test_test.cc
View file @
88e97c82
...
@@ -449,10 +449,8 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
...
@@ -449,10 +449,8 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
EXPECT_DEATH
(
GlobalFunction
(),
regex_str
);
EXPECT_DEATH
(
GlobalFunction
(),
regex_str
);
#endif // GTEST_HAS_GLOBAL_STRING
#endif // GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_STD_STRING
const
::
std
::
string
regex_std_str
(
regex_c_str
);
const
::
std
::
string
regex_std_str
(
regex_c_str
);
EXPECT_DEATH
(
GlobalFunction
(),
regex_std_str
);
EXPECT_DEATH
(
GlobalFunction
(),
regex_std_str
);
#endif // GTEST_HAS_STD_STRING
}
}
// Tests that a non-void function can be used in a death test.
// Tests that a non-void function can be used in a death test.
...
...
test/gtest-message_test.cc
View file @
88e97c82
...
@@ -92,8 +92,6 @@ TEST(MessageTest, StreamsNullCString) {
...
@@ -92,8 +92,6 @@ TEST(MessageTest, StreamsNullCString) {
EXPECT_STREQ
(
"(null)"
,
ToCString
(
Message
()
<<
p
));
EXPECT_STREQ
(
"(null)"
,
ToCString
(
Message
()
<<
p
));
}
}
#if GTEST_HAS_STD_STRING
// Tests streaming std::string.
// Tests streaming std::string.
//
//
// As std::string has problem in MSVC when exception is disabled, we only
// As std::string has problem in MSVC when exception is disabled, we only
...
@@ -113,8 +111,6 @@ TEST(MessageTest, StreamsStringWithEmbeddedNUL) {
...
@@ -113,8 +111,6 @@ TEST(MessageTest, StreamsStringWithEmbeddedNUL) {
ToCString
(
Message
()
<<
string_with_nul
));
ToCString
(
Message
()
<<
string_with_nul
));
}
}
#endif // GTEST_HAS_STD_STRING
// Tests streaming a NUL char.
// Tests streaming a NUL char.
TEST
(
MessageTest
,
StreamsNULChar
)
{
TEST
(
MessageTest
,
StreamsNULChar
)
{
EXPECT_STREQ
(
"
\\
0"
,
ToCString
(
Message
()
<<
'\0'
));
EXPECT_STREQ
(
"
\\
0"
,
ToCString
(
Message
()
<<
'\0'
));
...
...
test/gtest-port_test.cc
View file @
88e97c82
...
@@ -177,9 +177,7 @@ class RETest : public ::testing::Test {};
...
@@ -177,9 +177,7 @@ class RETest : public ::testing::Test {};
// Defines StringTypes as the list of all string types that class RE
// Defines StringTypes as the list of all string types that class RE
// supports.
// supports.
typedef
testing
::
Types
<
typedef
testing
::
Types
<
#if GTEST_HAS_STD_STRING
::
std
::
string
,
::
std
::
string
,
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_GLOBAL_STRING
::
string
,
::
string
,
#endif // GTEST_HAS_GLOBAL_STRING
#endif // GTEST_HAS_GLOBAL_STRING
...
...
test/gtest_output_test.py
View file @
88e97c82
...
@@ -126,15 +126,15 @@ def RemoveTime(output):
...
@@ -126,15 +126,15 @@ def RemoveTime(output):
def
RemoveTestCounts
(
output
):
def
RemoveTestCounts
(
output
):
"""Removes test counts from a Google Test program's output."""
"""Removes test counts from a Google Test program's output."""
output
=
re
.
sub
(
r
'\d+ tests, listed below'
,
output
=
re
.
sub
(
r
'\d+ tests
?
, listed below'
,
'? tests, listed below'
,
output
)
'? tests, listed below'
,
output
)
output
=
re
.
sub
(
r
'\d+ FAILED TESTS'
,
output
=
re
.
sub
(
r
'\d+ FAILED TESTS'
,
'? FAILED TESTS'
,
output
)
'? FAILED TESTS'
,
output
)
output
=
re
.
sub
(
r
'\d+ tests from \d+ test cases'
,
output
=
re
.
sub
(
r
'\d+ tests
?
from \d+ test cases
?
'
,
'? tests from ? test cases'
,
output
)
'? tests from ? test cases'
,
output
)
output
=
re
.
sub
(
r
'\d+ tests from ([a-zA-Z_])'
,
output
=
re
.
sub
(
r
'\d+ tests
?
from ([a-zA-Z_])'
,
r
'? tests from \1'
,
output
)
r
'? tests from \1'
,
output
)
return
re
.
sub
(
r
'\d+ tests\.'
,
'? tests.'
,
output
)
return
re
.
sub
(
r
'\d+ tests
?
\.'
,
'? tests.'
,
output
)
def
RemoveMatchingTests
(
test_output
,
pattern
):
def
RemoveMatchingTests
(
test_output
,
pattern
):
...
@@ -268,16 +268,16 @@ class GTestOutputTest(gtest_test_utils.TestCase):
...
@@ -268,16 +268,16 @@ class GTestOutputTest(gtest_test_utils.TestCase):
normalized_actual
=
RemoveTestCounts
(
output
)
normalized_actual
=
RemoveTestCounts
(
output
)
normalized_golden
=
RemoveTestCounts
(
self
.
RemoveUnsupportedTests
(
golden
))
normalized_golden
=
RemoveTestCounts
(
self
.
RemoveUnsupportedTests
(
golden
))
# This code is very handy when debugging
test
differences
so I left it
# This code is very handy when debugging
golden file
differences
:
# here, commented.
if
os
.
getenv
(
'DEBUG_GTEST_OUTPUT_TEST'
):
#
open(os.path.join(
open
(
os
.
path
.
join
(
#
gtest_test_utils.GetSourceDir(),
gtest_test_utils
.
GetSourceDir
(),
#
'_gtest_output_test_normalized_actual.txt'), 'wb').write(
'_gtest_output_test_normalized_actual.txt'
),
'wb'
).
write
(
#
normalized_actual)
normalized_actual
)
#
open(os.path.join(
open
(
os
.
path
.
join
(
#
gtest_test_utils.GetSourceDir(),
gtest_test_utils
.
GetSourceDir
(),
#
'_gtest_output_test_normalized_golden.txt'), 'wb').write(
'_gtest_output_test_normalized_golden.txt'
),
'wb'
).
write
(
#
normalized_golden)
normalized_golden
)
self
.
assert_
(
normalized_golden
==
normalized_actual
)
self
.
assert_
(
normalized_golden
==
normalized_actual
)
...
...
test/gtest_unittest.cc
View file @
88e97c82
...
@@ -1111,8 +1111,6 @@ TEST(StringTest, Constructors) {
...
@@ -1111,8 +1111,6 @@ TEST(StringTest, Constructors) {
EXPECT_EQ
(
'c'
,
s7
.
c_str
()[
3
]);
EXPECT_EQ
(
'c'
,
s7
.
c_str
()[
3
]);
}
}
#if GTEST_HAS_STD_STRING
TEST
(
StringTest
,
ConvertsFromStdString
)
{
TEST
(
StringTest
,
ConvertsFromStdString
)
{
// An empty std::string.
// An empty std::string.
const
std
::
string
src1
(
""
);
const
std
::
string
src1
(
""
);
...
@@ -1152,8 +1150,6 @@ TEST(StringTest, ConvertsToStdString) {
...
@@ -1152,8 +1150,6 @@ TEST(StringTest, ConvertsToStdString) {
EXPECT_EQ
(
std
::
string
(
"x
\0
y"
,
3
),
dest3
);
EXPECT_EQ
(
std
::
string
(
"x
\0
y"
,
3
),
dest3
);
}
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_GLOBAL_STRING
TEST
(
StringTest
,
ConvertsFromGlobalString
)
{
TEST
(
StringTest
,
ConvertsFromGlobalString
)
{
...
@@ -2818,8 +2814,6 @@ TEST(IsSubstringTest, GeneratesCorrectMessageForCString) {
...
@@ -2818,8 +2814,6 @@ TEST(IsSubstringTest, GeneratesCorrectMessageForCString) {
"needle"
,
"haystack"
).
failure_message
());
"needle"
,
"haystack"
).
failure_message
());
}
}
#if GTEST_HAS_STD_STRING
// Tests that IsSubstring returns the correct result when the input
// Tests that IsSubstring returns the correct result when the input
// argument type is ::std::string.
// argument type is ::std::string.
TEST
(
IsSubstringTest
,
ReturnsCorrectResultsForStdString
)
{
TEST
(
IsSubstringTest
,
ReturnsCorrectResultsForStdString
)
{
...
@@ -2827,8 +2821,6 @@ TEST(IsSubstringTest, ReturnsCorrectResultsForStdString) {
...
@@ -2827,8 +2821,6 @@ TEST(IsSubstringTest, ReturnsCorrectResultsForStdString) {
EXPECT_FALSE
(
IsSubstring
(
""
,
""
,
"hello"
,
std
::
string
(
"world"
)));
EXPECT_FALSE
(
IsSubstring
(
""
,
""
,
"hello"
,
std
::
string
(
"world"
)));
}
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
// Tests that IsSubstring returns the correct result when the input
// Tests that IsSubstring returns the correct result when the input
// argument type is ::std::wstring.
// argument type is ::std::wstring.
...
@@ -2879,8 +2871,6 @@ TEST(IsNotSubstringTest, GeneratesCorrectMessageForWideCString) {
...
@@ -2879,8 +2871,6 @@ TEST(IsNotSubstringTest, GeneratesCorrectMessageForWideCString) {
L"needle"
,
L"two needles"
).
failure_message
());
L"needle"
,
L"two needles"
).
failure_message
());
}
}
#if GTEST_HAS_STD_STRING
// Tests that IsNotSubstring returns the correct result when the input
// Tests that IsNotSubstring returns the correct result when the input
// argument type is ::std::string.
// argument type is ::std::string.
TEST
(
IsNotSubstringTest
,
ReturnsCorrectResultsForStdString
)
{
TEST
(
IsNotSubstringTest
,
ReturnsCorrectResultsForStdString
)
{
...
@@ -2900,8 +2890,6 @@ TEST(IsNotSubstringTest, GeneratesCorrectMessageForStdString) {
...
@@ -2900,8 +2890,6 @@ TEST(IsNotSubstringTest, GeneratesCorrectMessageForStdString) {
::
std
::
string
(
"needle"
),
"two needles"
).
failure_message
());
::
std
::
string
(
"needle"
),
"two needles"
).
failure_message
());
}
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
// Tests that IsNotSubstring returns the correct result when the input
// Tests that IsNotSubstring returns the correct result when the input
...
@@ -4575,7 +4563,6 @@ TEST(StreamableToStringTest, NullCString) {
...
@@ -4575,7 +4563,6 @@ TEST(StreamableToStringTest, NullCString) {
// Tests using streamable values as assertion messages.
// Tests using streamable values as assertion messages.
#if GTEST_HAS_STD_STRING
// Tests using std::string as an assertion message.
// Tests using std::string as an assertion message.
TEST
(
StreamableTest
,
string
)
{
TEST
(
StreamableTest
,
string
)
{
static
const
std
::
string
str
(
static
const
std
::
string
str
(
...
@@ -4596,8 +4583,6 @@ TEST(StreamableTest, stringWithEmbeddedNUL) {
...
@@ -4596,8 +4583,6 @@ TEST(StreamableTest, stringWithEmbeddedNUL) {
"Here's a NUL
\\
0 and some more string"
);
"Here's a NUL
\\
0 and some more string"
);
}
}
#endif // GTEST_HAS_STD_STRING
// Tests that we can output a NUL char.
// Tests that we can output a NUL char.
TEST
(
StreamableTest
,
NULChar
)
{
TEST
(
StreamableTest
,
NULChar
)
{
EXPECT_FATAL_FAILURE
({
// NOLINT
EXPECT_FATAL_FAILURE
({
// NOLINT
...
@@ -4720,7 +4705,6 @@ TEST(EqAssertionTest, WideChar) {
...
@@ -4720,7 +4705,6 @@ TEST(EqAssertionTest, WideChar) {
"Value of: wchar"
);
"Value of: wchar"
);
}
}
#if GTEST_HAS_STD_STRING
// Tests using ::std::string values in {EXPECT|ASSERT}_EQ.
// Tests using ::std::string values in {EXPECT|ASSERT}_EQ.
TEST
(
EqAssertionTest
,
StdString
)
{
TEST
(
EqAssertionTest
,
StdString
)
{
// Compares a const char* to an std::string that has identical
// Compares a const char* to an std::string that has identical
...
@@ -4751,8 +4735,6 @@ TEST(EqAssertionTest, StdString) {
...
@@ -4751,8 +4735,6 @@ TEST(EqAssertionTest, StdString) {
" Actual:
\"
A
\\
0 in the middle
\"
"
);
" Actual:
\"
A
\\
0 in the middle
\"
"
);
}
}
#endif // GTEST_HAS_STD_STRING
#if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
// Tests using ::std::wstring values in {EXPECT|ASSERT}_EQ.
// Tests using ::std::wstring values in {EXPECT|ASSERT}_EQ.
...
...
test/run_tests_util.py
View file @
88e97c82
...
@@ -152,6 +152,20 @@ def _GetGtestBuildDir(injected_os, script_dir, config):
...
@@ -152,6 +152,20 @@ def _GetGtestBuildDir(injected_os, script_dir, config):
'gtest/scons'
))
'gtest/scons'
))
def
_GetConfigFromBuildDir
(
build_dir
):
"""Extracts the configuration name from the build directory."""
# We don't want to depend on build_dir containing the correct path
# separators.
m
=
re
.
match
(
r
'.*[\\/]([^\\/]+)[\\/][^\\/]+[\\/]scons[\\/]?$'
,
build_dir
)
if
m
:
return
m
.
group
(
1
)
else
:
print
>>
sys
.
stderr
,
(
'%s is an invalid build directory that does not '
'correspond to any configuration.'
%
(
build_dir
,))
return
''
# All paths in this script are either absolute or relative to the current
# All paths in this script are either absolute or relative to the current
# working directory, unless otherwise specified.
# working directory, unless otherwise specified.
class
TestRunner
(
object
):
class
TestRunner
(
object
):
...
@@ -270,7 +284,8 @@ class TestRunner(object):
...
@@ -270,7 +284,8 @@ class TestRunner(object):
args
,
args
,
named_configurations
,
named_configurations
,
built_configurations
,
built_configurations
,
available_configurations
=
CONFIGS
):
available_configurations
=
CONFIGS
,
python_tests_to_skip
=
None
):
"""Determines what tests should be run.
"""Determines what tests should be run.
Args:
Args:
...
@@ -279,6 +294,8 @@ class TestRunner(object):
...
@@ -279,6 +294,8 @@ class TestRunner(object):
built_configurations: True if -b has been specified.
built_configurations: True if -b has been specified.
available_configurations: a list of configurations available on the
available_configurations: a list of configurations available on the
current platform, injectable for testing.
current platform, injectable for testing.
python_tests_to_skip: a collection of (configuration, python test name)s
that need to be skipped.
Returns:
Returns:
A tuple with 2 elements: the list of Python tests to run and the list of
A tuple with 2 elements: the list of Python tests to run and the list of
...
@@ -356,6 +373,12 @@ class TestRunner(object):
...
@@ -356,6 +373,12 @@ class TestRunner(object):
python_test_pairs
=
[]
python_test_pairs
=
[]
for
directory
in
build_dirs
:
for
directory
in
build_dirs
:
for
test
in
selected_python_tests
:
for
test
in
selected_python_tests
:
config
=
_GetConfigFromBuildDir
(
directory
)
file_name
=
os
.
path
.
basename
(
test
)
if
python_tests_to_skip
and
(
config
,
file_name
)
in
python_tests_to_skip
:
print
(
'NOTE: %s is skipped for configuration %s, as it does not '
'work there.'
%
(
file_name
,
config
))
else
:
python_test_pairs
.
append
((
directory
,
test
))
python_test_pairs
.
append
((
directory
,
test
))
binary_test_pairs
=
[]
binary_test_pairs
=
[]
...
...
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