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
76bce79a
Unverified
Commit
76bce79a
authored
May 01, 2023
by
Andy Soffer
Committed by
GitHub
May 01, 2023
Browse files
Merge branch 'main' into fixes_std_pair_diff
parents
6f1c4b3d
f345b2ca
Changes
92
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
310 additions
and
223 deletions
+310
-223
googletest/src/gtest-test-part.cc
googletest/src/gtest-test-part.cc
+3
-2
googletest/src/gtest-typed-test.cc
googletest/src/gtest-typed-test.cc
+5
-1
googletest/src/gtest.cc
googletest/src/gtest.cc
+156
-84
googletest/src/gtest_main.cc
googletest/src/gtest_main.cc
+4
-4
googletest/test/googletest-break-on-failure-unittest_.cc
googletest/test/googletest-break-on-failure-unittest_.cc
+4
-4
googletest/test/googletest-death-test-test.cc
googletest/test/googletest-death-test-test.cc
+17
-14
googletest/test/googletest-death-test_ex_test.cc
googletest/test/googletest-death-test_ex_test.cc
+1
-1
googletest/test/googletest-filepath-test.cc
googletest/test/googletest-filepath-test.cc
+13
-13
googletest/test/googletest-json-outfiles-test.py
googletest/test/googletest-json-outfiles-test.py
+6
-6
googletest/test/googletest-json-output-unittest.py
googletest/test/googletest-json-output-unittest.py
+28
-28
googletest/test/googletest-list-tests-unittest_.cc
googletest/test/googletest-list-tests-unittest_.cc
+3
-0
googletest/test/googletest-listener-test.cc
googletest/test/googletest-listener-test.cc
+2
-7
googletest/test/googletest-options-test.cc
googletest/test/googletest-options-test.cc
+12
-12
googletest/test/googletest-output-test.py
googletest/test/googletest-output-test.py
+1
-1
googletest/test/googletest-output-test_.cc
googletest/test/googletest-output-test_.cc
+10
-7
googletest/test/googletest-param-test-invalid-name2-test_.cc
googletest/test/googletest-param-test-invalid-name2-test_.cc
+2
-0
googletest/test/googletest-param-test-test.cc
googletest/test/googletest-param-test-test.cc
+1
-1
googletest/test/googletest-port-test.cc
googletest/test/googletest-port-test.cc
+27
-25
googletest/test/googletest-printers-test.cc
googletest/test/googletest-printers-test.cc
+15
-12
googletest/test/googletest-shuffle-test_.cc
googletest/test/googletest-shuffle-test_.cc
+0
-1
No files found.
googletest/src/gtest-test-part.cc
View file @
76bce79a
...
@@ -32,13 +32,14 @@
...
@@ -32,13 +32,14 @@
#include "gtest/gtest-test-part.h"
#include "gtest/gtest-test-part.h"
#include <ostream>
#include <string>
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-port.h"
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
namespace
testing
{
namespace
testing
{
using
internal
::
GetUnitTestImpl
;
// Gets the summary of the failure message by omitting the stack trace
// Gets the summary of the failure message by omitting the stack trace
// in it.
// in it.
std
::
string
TestPartResult
::
ExtractSummary
(
const
char
*
message
)
{
std
::
string
TestPartResult
::
ExtractSummary
(
const
char
*
message
)
{
...
...
googletest/src/gtest-typed-test.cc
View file @
76bce79a
...
@@ -29,6 +29,10 @@
...
@@ -29,6 +29,10 @@
#include "gtest/gtest-typed-test.h"
#include "gtest/gtest-typed-test.h"
#include <set>
#include <string>
#include <vector>
#include "gtest/gtest.h"
#include "gtest/gtest.h"
namespace
testing
{
namespace
testing
{
...
@@ -90,7 +94,7 @@ const char* TypedTestSuitePState::VerifyRegisteredTestNames(
...
@@ -90,7 +94,7 @@ const char* TypedTestSuitePState::VerifyRegisteredTestNames(
}
}
const
std
::
string
&
errors_str
=
errors
.
GetString
();
const
std
::
string
&
errors_str
=
errors
.
GetString
();
if
(
errors_str
!=
""
)
{
if
(
!
errors_str
.
empty
()
)
{
fprintf
(
stderr
,
"%s %s"
,
FormatFileLocation
(
file
,
line
).
c_str
(),
fprintf
(
stderr
,
"%s %s"
,
FormatFileLocation
(
file
,
line
).
c_str
(),
errors_str
.
c_str
());
errors_str
.
c_str
());
fflush
(
stderr
);
fflush
(
stderr
);
...
...
googletest/src/gtest.cc
View file @
76bce79a
...
@@ -44,16 +44,21 @@
...
@@ -44,16 +44,21 @@
#include <chrono> // NOLINT
#include <chrono> // NOLINT
#include <cmath>
#include <cmath>
#include <cstdint>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <initializer_list>
#include <initializer_list>
#include <iomanip>
#include <iomanip>
#include <ios>
#include <ios>
#include <iostream>
#include <iterator>
#include <iterator>
#include <limits>
#include <limits>
#include <list>
#include <list>
#include <map>
#include <map>
#include <ostream> // NOLINT
#include <ostream> // NOLINT
#include <set>
#include <sstream>
#include <sstream>
#include <unordered_set>
#include <unordered_set>
#include <utility>
#include <vector>
#include <vector>
#include "gtest/gtest-assertion-result.h"
#include "gtest/gtest-assertion-result.h"
...
@@ -61,7 +66,7 @@
...
@@ -61,7 +66,7 @@
#include "gtest/internal/custom/gtest.h"
#include "gtest/internal/custom/gtest.h"
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-port.h"
#if GTEST_OS_LINUX
#if
def
GTEST_OS_LINUX
#include <fcntl.h> // NOLINT
#include <fcntl.h> // NOLINT
#include <limits.h> // NOLINT
#include <limits.h> // NOLINT
...
@@ -74,18 +79,18 @@
...
@@ -74,18 +79,18 @@
#include <string>
#include <string>
#elif GTEST_OS_ZOS
#elif
defined(
GTEST_OS_ZOS
)
#include <sys/time.h> // NOLINT
#include <sys/time.h> // NOLINT
// On z/OS we additionally need strings.h for strcasecmp.
// On z/OS we additionally need strings.h for strcasecmp.
#include <strings.h> // NOLINT
#include <strings.h> // NOLINT
#elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE.
#elif
defined(
GTEST_OS_WINDOWS_MOBILE
)
// We are on Windows CE.
#include <windows.h> // NOLINT
#include <windows.h> // NOLINT
#undef min
#undef min
#elif GTEST_OS_WINDOWS // We are on Windows proper.
#elif
defined(
GTEST_OS_WINDOWS
)
// We are on Windows proper.
#include <windows.h> // NOLINT
#include <windows.h> // NOLINT
#undef min
#undef min
...
@@ -99,7 +104,7 @@
...
@@ -99,7 +104,7 @@
#include <sys/timeb.h> // NOLINT
#include <sys/timeb.h> // NOLINT
#include <sys/types.h> // NOLINT
#include <sys/types.h> // NOLINT
#if GTEST_OS_WINDOWS_MINGW
#if
def
GTEST_OS_WINDOWS_MINGW
#include <sys/time.h> // NOLINT
#include <sys/time.h> // NOLINT
#endif // GTEST_OS_WINDOWS_MINGW
#endif // GTEST_OS_WINDOWS_MINGW
...
@@ -125,17 +130,18 @@
...
@@ -125,17 +130,18 @@
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
#define vsnprintf _vsnprintf
#define vsnprintf _vsnprintf
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
#if GTEST_OS_MAC
#if
def
GTEST_OS_MAC
#ifndef GTEST_OS_IOS
#ifndef GTEST_OS_IOS
#include <crt_externs.h>
#include <crt_externs.h>
#endif
#endif
#endif
#endif
#if GTEST_HAS_ABSL
#ifdef GTEST_HAS_ABSL
#include "absl/container/flat_hash_set.h"
#include "absl/debugging/failure_signal_handler.h"
#include "absl/debugging/failure_signal_handler.h"
#include "absl/debugging/stacktrace.h"
#include "absl/debugging/stacktrace.h"
#include "absl/debugging/symbolize.h"
#include "absl/debugging/symbolize.h"
...
@@ -143,6 +149,8 @@
...
@@ -143,6 +149,8 @@
#include "absl/flags/usage.h"
#include "absl/flags/usage.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/str_replace.h"
#include "absl/strings/string_view.h"
#include "absl/strings/strip.h"
#endif // GTEST_HAS_ABSL
#endif // GTEST_HAS_ABSL
// Checks builtin compiler feature |x| while avoiding an extra layer of #ifdefs
// Checks builtin compiler feature |x| while avoiding an extra layer of #ifdefs
...
@@ -408,7 +416,7 @@ uint32_t Random::Generate(uint32_t range) {
...
@@ -408,7 +416,7 @@ uint32_t Random::Generate(uint32_t range) {
// GTestIsInitialized() returns true if and only if the user has initialized
// GTestIsInitialized() returns true if and only if the user has initialized
// Google Test. Useful for catching the user mistake of not initializing
// Google Test. Useful for catching the user mistake of not initializing
// Google Test before calling RUN_ALL_TESTS().
// Google Test before calling RUN_ALL_TESTS().
static
bool
GTestIsInitialized
()
{
return
GetArgvs
().
size
()
>
0
;
}
static
bool
GTestIsInitialized
()
{
return
!
GetArgvs
().
empty
()
;
}
// Iterates over a vector of TestSuites, keeping a running sum of the
// Iterates over a vector of TestSuites, keeping a running sum of the
// results of calling a given int-returning method on each.
// results of calling a given int-returning method on each.
...
@@ -630,7 +638,7 @@ static ::std::vector<std::string> g_argvs;
...
@@ -630,7 +638,7 @@ static ::std::vector<std::string> g_argvs;
FilePath
GetCurrentExecutableName
()
{
FilePath
GetCurrentExecutableName
()
{
FilePath
result
;
FilePath
result
;
#if GTEST_OS_WINDOWS || GTEST_OS_OS2
#if
defined(
GTEST_OS_WINDOWS
)
||
defined(
GTEST_OS_OS2
)
result
.
Set
(
FilePath
(
GetArgvs
()[
0
]).
RemoveExtension
(
"exe"
));
result
.
Set
(
FilePath
(
GetArgvs
()[
0
]).
RemoveExtension
(
"exe"
));
#else
#else
result
.
Set
(
FilePath
(
GetArgvs
()[
0
]));
result
.
Set
(
FilePath
(
GetArgvs
()[
0
]));
...
@@ -1165,7 +1173,7 @@ TimeInMillis GetTimeInMillis() {
...
@@ -1165,7 +1173,7 @@ TimeInMillis GetTimeInMillis() {
// class String.
// class String.
#if GTEST_OS_WINDOWS_MOBILE
#if
def
GTEST_OS_WINDOWS_MOBILE
// Creates a UTF-16 wide string from the given ANSI string, allocating
// Creates a UTF-16 wide string from the given ANSI string, allocating
// memory using new. The caller is responsible for deleting the return
// memory using new. The caller is responsible for deleting the return
// value using delete[]. Returns the wide string, or NULL if the
// value using delete[]. Returns the wide string, or NULL if the
...
@@ -1867,14 +1875,14 @@ AssertionResult IsNotSubstring(const char* needle_expr,
...
@@ -1867,14 +1875,14 @@ AssertionResult IsNotSubstring(const char* needle_expr,
namespace
internal
{
namespace
internal
{
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
namespace
{
namespace
{
// Helper function for IsHRESULT{SuccessFailure} predicates
// Helper function for IsHRESULT{SuccessFailure} predicates
AssertionResult
HRESULTFailureHelper
(
const
char
*
expr
,
const
char
*
expected
,
AssertionResult
HRESULTFailureHelper
(
const
char
*
expr
,
const
char
*
expected
,
long
hr
)
{
// NOLINT
long
hr
)
{
// NOLINT
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_TV_TITLE
#if
defined(
GTEST_OS_WINDOWS_MOBILE
)
||
defined(
GTEST_OS_WINDOWS_TV_TITLE
)
// Windows CE doesn't support FormatMessage.
// Windows CE doesn't support FormatMessage.
const
char
error_text
[]
=
""
;
const
char
error_text
[]
=
""
;
...
@@ -2135,9 +2143,9 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
...
@@ -2135,9 +2143,9 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
if
(
rhs
==
nullptr
)
return
false
;
if
(
rhs
==
nullptr
)
return
false
;
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
return
_wcsicmp
(
lhs
,
rhs
)
==
0
;
return
_wcsicmp
(
lhs
,
rhs
)
==
0
;
#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID
#elif
defined(
GTEST_OS_LINUX
)
&& !
defined(
GTEST_OS_LINUX_ANDROID
)
return
wcscasecmp
(
lhs
,
rhs
)
==
0
;
return
wcscasecmp
(
lhs
,
rhs
)
==
0
;
#else
#else
// Android, Mac OS X and Cygwin don't define wcscasecmp.
// Android, Mac OS X and Cygwin don't define wcscasecmp.
...
@@ -2237,7 +2245,7 @@ TestResult::TestResult()
...
@@ -2237,7 +2245,7 @@ TestResult::TestResult()
:
death_test_count_
(
0
),
start_timestamp_
(
0
),
elapsed_time_
(
0
)
{}
:
death_test_count_
(
0
),
start_timestamp_
(
0
),
elapsed_time_
(
0
)
{}
// D'tor.
// D'tor.
TestResult
::~
TestResult
()
{}
TestResult
::~
TestResult
()
=
default
;
// Returns the i-th test part result among all the results. i can
// Returns the i-th test part result among all the results. i can
// range from 0 to total_part_count() - 1. If i is not in that range,
// range from 0 to total_part_count() - 1. If i is not in that range,
...
@@ -2325,7 +2333,9 @@ static std::vector<std::string> GetReservedAttributesForElement(
...
@@ -2325,7 +2333,9 @@ static std::vector<std::string> GetReservedAttributesForElement(
return
std
::
vector
<
std
::
string
>
();
return
std
::
vector
<
std
::
string
>
();
}
}
#if GTEST_HAS_FILE_SYSTEM
// TODO(jdesprez): Merge the two getReserved attributes once skip is improved
// TODO(jdesprez): Merge the two getReserved attributes once skip is improved
// This function is only used when file systems are enabled.
static
std
::
vector
<
std
::
string
>
GetReservedOutputAttributesForElement
(
static
std
::
vector
<
std
::
string
>
GetReservedOutputAttributesForElement
(
const
std
::
string
&
xml_element
)
{
const
std
::
string
&
xml_element
)
{
if
(
xml_element
==
"testsuites"
)
{
if
(
xml_element
==
"testsuites"
)
{
...
@@ -2340,6 +2350,7 @@ static std::vector<std::string> GetReservedOutputAttributesForElement(
...
@@ -2340,6 +2350,7 @@ static std::vector<std::string> GetReservedOutputAttributesForElement(
// This code is unreachable but some compilers may not realizes that.
// This code is unreachable but some compilers may not realizes that.
return
std
::
vector
<
std
::
string
>
();
return
std
::
vector
<
std
::
string
>
();
}
}
#endif
static
std
::
string
FormatWordList
(
const
std
::
vector
<
std
::
string
>&
words
)
{
static
std
::
string
FormatWordList
(
const
std
::
vector
<
std
::
string
>&
words
)
{
Message
word_list
;
Message
word_list
;
...
@@ -2443,7 +2454,7 @@ Test::Test() : gtest_flag_saver_(new GTEST_FLAG_SAVER_) {}
...
@@ -2443,7 +2454,7 @@ Test::Test() : gtest_flag_saver_(new GTEST_FLAG_SAVER_) {}
// The d'tor restores the states of all flags. The actual work is
// The d'tor restores the states of all flags. The actual work is
// done by the d'tor of the gtest_flag_saver_ field, and thus not
// done by the d'tor of the gtest_flag_saver_ field, and thus not
// visible here.
// visible here.
Test
::~
Test
()
{}
Test
::~
Test
()
=
default
;
// Sets up the test fixture.
// Sets up the test fixture.
//
//
...
@@ -2978,6 +2989,25 @@ void TestSuite::Run() {
...
@@ -2978,6 +2989,25 @@ void TestSuite::Run() {
TestEventListener
*
repeater
=
UnitTest
::
GetInstance
()
->
listeners
().
repeater
();
TestEventListener
*
repeater
=
UnitTest
::
GetInstance
()
->
listeners
().
repeater
();
// Ensure our tests are in a deterministic order.
//
// We do this by sorting lexicographically on (file, line number), providing
// an order matching what the user can see in the source code.
//
// In the common case the line number comparison shouldn't be necessary,
// because the registrations made by the TEST macro are executed in order
// within a translation unit. But this is not true of the manual registration
// API, and in more exotic scenarios a single file may be part of multiple
// translation units.
std
::
stable_sort
(
test_info_list_
.
begin
(),
test_info_list_
.
end
(),
[](
const
TestInfo
*
const
a
,
const
TestInfo
*
const
b
)
{
if
(
const
int
result
=
std
::
strcmp
(
a
->
file
(),
b
->
file
()))
{
return
result
<
0
;
}
return
a
->
line
()
<
b
->
line
();
});
// Call both legacy and the new API
// Call both legacy and the new API
repeater
->
OnTestSuiteStart
(
*
this
);
repeater
->
OnTestSuiteStart
(
*
this
);
// Legacy API is deprecated but still available
// Legacy API is deprecated but still available
...
@@ -3141,7 +3171,7 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) {
...
@@ -3141,7 +3171,7 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) {
// following statements add the test part result message to the Output
// following statements add the test part result message to the Output
// window such that the user can double-click on it to jump to the
// window such that the user can double-click on it to jump to the
// corresponding source code location; otherwise they do nothing.
// corresponding source code location; otherwise they do nothing.
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
#if
defined(
GTEST_OS_WINDOWS
)
&& !
defined(
GTEST_OS_WINDOWS_MOBILE
)
// We don't call OutputDebugString*() on Windows Mobile, as printing
// We don't call OutputDebugString*() on Windows Mobile, as printing
// to stdout is done by OutputDebugString() there already - we don't
// to stdout is done by OutputDebugString() there already - we don't
// want the same message printed twice.
// want the same message printed twice.
...
@@ -3151,8 +3181,9 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) {
...
@@ -3151,8 +3181,9 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) {
}
}
// class PrettyUnitTestResultPrinter
// class PrettyUnitTestResultPrinter
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \
#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) && \
!GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
!defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) && \
!defined(GTEST_OS_WINDOWS_MINGW)
// Returns the character attribute for the given color.
// Returns the character attribute for the given color.
static
WORD
GetColorAttribute
(
GTestColor
color
)
{
static
WORD
GetColorAttribute
(
GTestColor
color
)
{
...
@@ -3224,7 +3255,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
...
@@ -3224,7 +3255,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
const
char
*
const
gtest_color
=
c
.
c_str
();
const
char
*
const
gtest_color
=
c
.
c_str
();
if
(
String
::
CaseInsensitiveCStringEquals
(
gtest_color
,
"auto"
))
{
if
(
String
::
CaseInsensitiveCStringEquals
(
gtest_color
,
"auto"
))
{
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
#if
defined(
GTEST_OS_WINDOWS
)
&& !
defined(
GTEST_OS_WINDOWS_MINGW
)
// On Windows the TERM variable is usually not set, but the
// On Windows the TERM variable is usually not set, but the
// console there does support colors.
// console there does support colors.
return
stdout_is_tty
;
return
stdout_is_tty
;
...
@@ -3279,8 +3310,9 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
...
@@ -3279,8 +3310,9 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
return
;
return
;
}
}
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \
#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) && \
!GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
!defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) && \
!defined(GTEST_OS_WINDOWS_MINGW)
const
HANDLE
stdout_handle
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
const
HANDLE
stdout_handle
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
// Gets the current text color.
// Gets the current text color.
...
@@ -3334,7 +3366,7 @@ static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
...
@@ -3334,7 +3366,7 @@ static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
// Class PrettyUnitTestResultPrinter is copyable.
// Class PrettyUnitTestResultPrinter is copyable.
class
PrettyUnitTestResultPrinter
:
public
TestEventListener
{
class
PrettyUnitTestResultPrinter
:
public
TestEventListener
{
public:
public:
PrettyUnitTestResultPrinter
()
{}
PrettyUnitTestResultPrinter
()
=
default
;
static
void
PrintTestName
(
const
char
*
test_suite
,
const
char
*
test
)
{
static
void
PrintTestName
(
const
char
*
test_suite
,
const
char
*
test
)
{
printf
(
"%s.%s"
,
test_suite
,
test
);
printf
(
"%s.%s"
,
test_suite
,
test
);
}
}
...
@@ -3642,7 +3674,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
...
@@ -3642,7 +3674,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// Class BriefUnitTestResultPrinter is copyable.
// Class BriefUnitTestResultPrinter is copyable.
class
BriefUnitTestResultPrinter
:
public
TestEventListener
{
class
BriefUnitTestResultPrinter
:
public
TestEventListener
{
public:
public:
BriefUnitTestResultPrinter
()
{}
BriefUnitTestResultPrinter
()
=
default
;
static
void
PrintTestName
(
const
char
*
test_suite
,
const
char
*
test
)
{
static
void
PrintTestName
(
const
char
*
test_suite
,
const
char
*
test
)
{
printf
(
"%s.%s"
,
test_suite
,
test
);
printf
(
"%s.%s"
,
test_suite
,
test
);
}
}
...
@@ -3757,28 +3789,28 @@ class TestEventRepeater : public TestEventListener {
...
@@ -3757,28 +3789,28 @@ class TestEventRepeater : public TestEventListener {
bool
forwarding_enabled
()
const
{
return
forwarding_enabled_
;
}
bool
forwarding_enabled
()
const
{
return
forwarding_enabled_
;
}
void
set_forwarding_enabled
(
bool
enable
)
{
forwarding_enabled_
=
enable
;
}
void
set_forwarding_enabled
(
bool
enable
)
{
forwarding_enabled_
=
enable
;
}
void
OnTestProgramStart
(
const
UnitTest
&
unit_test
)
override
;
void
OnTestProgramStart
(
const
UnitTest
&
parameter
)
override
;
void
OnTestIterationStart
(
const
UnitTest
&
unit_test
,
int
iteration
)
override
;
void
OnTestIterationStart
(
const
UnitTest
&
unit_test
,
int
iteration
)
override
;
void
OnEnvironmentsSetUpStart
(
const
UnitTest
&
unit_test
)
override
;
void
OnEnvironmentsSetUpStart
(
const
UnitTest
&
parameter
)
override
;
void
OnEnvironmentsSetUpEnd
(
const
UnitTest
&
unit_test
)
override
;
void
OnEnvironmentsSetUpEnd
(
const
UnitTest
&
parameter
)
override
;
// Legacy API is deprecated but still available
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnTestCaseStart
(
const
TestSuite
&
parameter
)
override
;
void
OnTestCaseStart
(
const
TestSuite
&
parameter
)
override
;
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnTestSuiteStart
(
const
TestSuite
&
parameter
)
override
;
void
OnTestSuiteStart
(
const
TestSuite
&
parameter
)
override
;
void
OnTestStart
(
const
TestInfo
&
test_info
)
override
;
void
OnTestStart
(
const
TestInfo
&
parameter
)
override
;
void
OnTestDisabled
(
const
TestInfo
&
test_info
)
override
;
void
OnTestDisabled
(
const
TestInfo
&
parameter
)
override
;
void
OnTestPartResult
(
const
TestPartResult
&
result
)
override
;
void
OnTestPartResult
(
const
TestPartResult
&
parameter
)
override
;
void
OnTestEnd
(
const
TestInfo
&
test_info
)
override
;
void
OnTestEnd
(
const
TestInfo
&
parameter
)
override
;
// Legacy API is deprecated but still available
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnTestCaseEnd
(
const
TestCase
&
parameter
)
override
;
void
OnTestCaseEnd
(
const
TestCase
&
parameter
)
override
;
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
void
OnTestSuiteEnd
(
const
TestSuite
&
parameter
)
override
;
void
OnTestSuiteEnd
(
const
TestSuite
&
parameter
)
override
;
void
OnEnvironmentsTearDownStart
(
const
UnitTest
&
unit_test
)
override
;
void
OnEnvironmentsTearDownStart
(
const
UnitTest
&
parameter
)
override
;
void
OnEnvironmentsTearDownEnd
(
const
UnitTest
&
unit_test
)
override
;
void
OnEnvironmentsTearDownEnd
(
const
UnitTest
&
parameter
)
override
;
void
OnTestIterationEnd
(
const
UnitTest
&
unit_test
,
int
iteration
)
override
;
void
OnTestIterationEnd
(
const
UnitTest
&
unit_test
,
int
iteration
)
override
;
void
OnTestProgramEnd
(
const
UnitTest
&
unit_test
)
override
;
void
OnTestProgramEnd
(
const
UnitTest
&
parameter
)
override
;
private:
private:
// Controls whether events will be forwarded to listeners_. Set to false
// Controls whether events will be forwarded to listeners_. Set to false
...
@@ -4953,7 +4985,7 @@ const char* const OsStackTraceGetterInterface::kElidedFramesMarker =
...
@@ -4953,7 +4985,7 @@ const char* const OsStackTraceGetterInterface::kElidedFramesMarker =
std
::
string
OsStackTraceGetter
::
CurrentStackTrace
(
int
max_depth
,
int
skip_count
)
std
::
string
OsStackTraceGetter
::
CurrentStackTrace
(
int
max_depth
,
int
skip_count
)
GTEST_LOCK_EXCLUDED_
(
mutex_
)
{
GTEST_LOCK_EXCLUDED_
(
mutex_
)
{
#if GTEST_HAS_ABSL
#if
def
GTEST_HAS_ABSL
std
::
string
result
;
std
::
string
result
;
if
(
max_depth
<=
0
)
{
if
(
max_depth
<=
0
)
{
...
@@ -5002,7 +5034,7 @@ std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count)
...
@@ -5002,7 +5034,7 @@ std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count)
}
}
void
OsStackTraceGetter
::
UponLeavingGTest
()
GTEST_LOCK_EXCLUDED_
(
mutex_
)
{
void
OsStackTraceGetter
::
UponLeavingGTest
()
GTEST_LOCK_EXCLUDED_
(
mutex_
)
{
#if GTEST_HAS_ABSL
#if
def
GTEST_HAS_ABSL
void
*
caller_frame
=
nullptr
;
void
*
caller_frame
=
nullptr
;
if
(
absl
::
GetStackTrace
(
&
caller_frame
,
1
,
3
)
<=
0
)
{
if
(
absl
::
GetStackTrace
(
&
caller_frame
,
1
,
3
)
<=
0
)
{
caller_frame
=
nullptr
;
caller_frame
=
nullptr
;
...
@@ -5013,7 +5045,7 @@ void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) {
...
@@ -5013,7 +5045,7 @@ void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) {
#endif // GTEST_HAS_ABSL
#endif // GTEST_HAS_ABSL
}
}
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
// A helper class that creates the premature-exit file in its
// A helper class that creates the premature-exit file in its
// constructor and deletes the file in its destructor.
// constructor and deletes the file in its destructor.
class
ScopedPrematureExitFile
{
class
ScopedPrematureExitFile
{
...
@@ -5033,7 +5065,7 @@ class ScopedPrematureExitFile {
...
@@ -5033,7 +5065,7 @@ class ScopedPrematureExitFile {
}
}
~
ScopedPrematureExitFile
()
{
~
ScopedPrematureExitFile
()
{
#if
!
GTEST_OS_ESP8266
#if
ndef
GTEST_OS_ESP8266
if
(
!
premature_exit_filepath_
.
empty
())
{
if
(
!
premature_exit_filepath_
.
empty
())
{
int
retval
=
remove
(
premature_exit_filepath_
.
c_str
());
int
retval
=
remove
(
premature_exit_filepath_
.
c_str
());
if
(
retval
)
{
if
(
retval
)
{
...
@@ -5301,7 +5333,7 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
...
@@ -5301,7 +5333,7 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
msg
<<
message
;
msg
<<
message
;
internal
::
MutexLock
lock
(
&
mutex_
);
internal
::
MutexLock
lock
(
&
mutex_
);
if
(
impl_
->
gtest_trace_stack
().
size
()
>
0
)
{
if
(
!
impl_
->
gtest_trace_stack
().
empty
()
)
{
msg
<<
"
\n
"
<<
GTEST_NAME_
<<
" trace:"
;
msg
<<
"
\n
"
<<
GTEST_NAME_
<<
" trace:"
;
for
(
size_t
i
=
impl_
->
gtest_trace_stack
().
size
();
i
>
0
;
--
i
)
{
for
(
size_t
i
=
impl_
->
gtest_trace_stack
().
size
();
i
>
0
;
--
i
)
{
...
@@ -5314,6 +5346,8 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
...
@@ -5314,6 +5346,8 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
if
(
os_stack_trace
.
c_str
()
!=
nullptr
&&
!
os_stack_trace
.
empty
())
{
if
(
os_stack_trace
.
c_str
()
!=
nullptr
&&
!
os_stack_trace
.
empty
())
{
msg
<<
internal
::
kStackTraceMarker
<<
os_stack_trace
;
msg
<<
internal
::
kStackTraceMarker
<<
os_stack_trace
;
}
else
{
msg
<<
"
\n
"
;
}
}
const
TestPartResult
result
=
TestPartResult
(
const
TestPartResult
result
=
TestPartResult
(
...
@@ -5329,7 +5363,8 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
...
@@ -5329,7 +5363,8 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
// with another testing framework) and specify the former on the
// with another testing framework) and specify the former on the
// command line for debugging.
// command line for debugging.
if
(
GTEST_FLAG_GET
(
break_on_failure
))
{
if
(
GTEST_FLAG_GET
(
break_on_failure
))
{
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_PHONE) && \
!defined(GTEST_OS_WINDOWS_RT)
// Using DebugBreak on Windows allows gtest to still break into a debugger
// Using DebugBreak on Windows allows gtest to still break into a debugger
// when a failure happens and both the --gtest_break_on_failure and
// when a failure happens and both the --gtest_break_on_failure and
// the --gtest_catch_exceptions flags are specified.
// the --gtest_catch_exceptions flags are specified.
...
@@ -5377,7 +5412,7 @@ void UnitTest::RecordProperty(const std::string& key,
...
@@ -5377,7 +5412,7 @@ void UnitTest::RecordProperty(const std::string& key,
// We don't protect this under mutex_, as we only support calling it
// We don't protect this under mutex_, as we only support calling it
// from the main thread.
// from the main thread.
int
UnitTest
::
Run
()
{
int
UnitTest
::
Run
()
{
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
const
bool
in_death_test_child_process
=
const
bool
in_death_test_child_process
=
GTEST_FLAG_GET
(
internal_run_death_test
).
length
()
>
0
;
GTEST_FLAG_GET
(
internal_run_death_test
).
length
()
>
0
;
...
@@ -5406,32 +5441,36 @@ int UnitTest::Run() {
...
@@ -5406,32 +5441,36 @@ int UnitTest::Run() {
in_death_test_child_process
in_death_test_child_process
?
nullptr
?
nullptr
:
internal
::
posix
::
GetEnv
(
"TEST_PREMATURE_EXIT_FILE"
));
:
internal
::
posix
::
GetEnv
(
"TEST_PREMATURE_EXIT_FILE"
));
#else
const
bool
in_death_test_child_process
=
false
;
#endif // GTEST_HAS_DEATH_TEST
#endif // GTEST_HAS_DEATH_TEST
// Captures the value of GTEST_FLAG(catch_exceptions). This value will be
// Captures the value of GTEST_FLAG(catch_exceptions). This value will be
// used for the duration of the program.
// used for the duration of the program.
impl
()
->
set_catch_exceptions
(
GTEST_FLAG_GET
(
catch_exceptions
));
impl
()
->
set_catch_exceptions
(
GTEST_FLAG_GET
(
catch_exceptions
));
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
// Either the user wants Google Test to catch exceptions thrown by the
// Either the user wants Google Test to catch exceptions thrown by the
// tests or this is executing in the context of death test child
// tests or this is executing in the context of death test child
// process. In either case the user does not want to see pop-up dialogs
// process. In either case the user does not want to see pop-up dialogs
// about crashes - they are expected.
// about crashes - they are expected.
if
(
impl
()
->
catch_exceptions
()
||
in_death_test_child_process
)
{
if
(
impl
()
->
catch_exceptions
()
||
in_death_test_child_process
)
{
#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_PHONE) && \
!defined(GTEST_OS_WINDOWS_RT)
// SetErrorMode doesn't exist on CE.
// SetErrorMode doesn't exist on CE.
SetErrorMode
(
SEM_FAILCRITICALERRORS
|
SEM_NOALIGNMENTFAULTEXCEPT
|
SetErrorMode
(
SEM_FAILCRITICALERRORS
|
SEM_NOALIGNMENTFAULTEXCEPT
|
SEM_NOGPFAULTERRORBOX
|
SEM_NOOPENFILEERRORBOX
);
SEM_NOGPFAULTERRORBOX
|
SEM_NOOPENFILEERRORBOX
);
#endif // !GTEST_OS_WINDOWS_MOBILE
#endif // !GTEST_OS_WINDOWS_MOBILE
#if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE
#if (defined(_MSC_VER) || defined(GTEST_OS_WINDOWS_MINGW)) && \
!defined(GTEST_OS_WINDOWS_MOBILE)
// Death test children can be terminated with _abort(). On Windows,
// Death test children can be terminated with _abort(). On Windows,
// _abort() can show a dialog with a warning message. This forces the
// _abort() can show a dialog with a warning message. This forces the
// abort message to go to stderr instead.
// abort message to go to stderr instead.
_set_error_mode
(
_OUT_TO_STDERR
);
_set_error_mode
(
_OUT_TO_STDERR
);
#endif
#endif
#if defined(_MSC_VER) && !GTEST_OS_WINDOWS_MOBILE
#if defined(_MSC_VER) && !
defined(
GTEST_OS_WINDOWS_MOBILE
)
// In the debug version, Visual Studio pops up a separate dialog
// In the debug version, Visual Studio pops up a separate dialog
// offering a choice to debug the aborted program. We need to suppress
// offering a choice to debug the aborted program. We need to suppress
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
...
@@ -5453,6 +5492,8 @@ int UnitTest::Run() {
...
@@ -5453,6 +5492,8 @@ int UnitTest::Run() {
}
}
#endif
#endif
}
}
#else
(
void
)
in_death_test_child_process
;
// Needed inside the #if block above
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
return
internal
::
HandleExceptionsInMethodIfSupported
(
return
internal
::
HandleExceptionsInMethodIfSupported
(
...
@@ -5548,7 +5589,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
...
@@ -5548,7 +5589,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
random_
(
0
),
// Will be reseeded before first use.
random_
(
0
),
// Will be reseeded before first use.
start_timestamp_
(
0
),
start_timestamp_
(
0
),
elapsed_time_
(
0
),
elapsed_time_
(
0
),
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
death_test_factory_
(
new
DefaultDeathTestFactory
),
death_test_factory_
(
new
DefaultDeathTestFactory
),
#endif
#endif
// Will be overridden by the flag before first use.
// Will be overridden by the flag before first use.
...
@@ -5588,11 +5629,11 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
...
@@ -5588,11 +5629,11 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
test_result
->
RecordProperty
(
xml_element
,
test_property
);
test_result
->
RecordProperty
(
xml_element
,
test_property
);
}
}
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
// Disables event forwarding if the control is currently in a death test
// Disables event forwarding if the control is currently in a death test
// subprocess. Must not be called before InitGoogleTest.
// subprocess. Must not be called before InitGoogleTest.
void
UnitTestImpl
::
SuppressTestEventsIfInSubprocess
()
{
void
UnitTestImpl
::
SuppressTestEventsIfInSubprocess
()
{
if
(
internal_run_death_test_flag_
.
get
()
!=
nullptr
)
if
(
internal_run_death_test_flag_
!=
nullptr
)
listeners
()
->
SuppressEventForwarding
();
listeners
()
->
SuppressEventForwarding
();
}
}
#endif // GTEST_HAS_DEATH_TEST
#endif // GTEST_HAS_DEATH_TEST
...
@@ -5608,7 +5649,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
...
@@ -5608,7 +5649,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
}
else
if
(
output_format
==
"json"
)
{
}
else
if
(
output_format
==
"json"
)
{
listeners
()
->
SetDefaultXmlGenerator
(
new
JsonUnitTestResultPrinter
(
listeners
()
->
SetDefaultXmlGenerator
(
new
JsonUnitTestResultPrinter
(
UnitTestOptions
::
GetAbsolutePathToOutputFile
().
c_str
()));
UnitTestOptions
::
GetAbsolutePathToOutputFile
().
c_str
()));
}
else
if
(
output_format
!=
""
)
{
}
else
if
(
!
output_format
.
empty
()
)
{
GTEST_LOG_
(
WARNING
)
<<
"WARNING: unrecognized output format
\"
"
GTEST_LOG_
(
WARNING
)
<<
"WARNING: unrecognized output format
\"
"
<<
output_format
<<
"
\"
ignored."
;
<<
output_format
<<
"
\"
ignored."
;
}
}
...
@@ -5651,7 +5692,7 @@ void UnitTestImpl::PostFlagParsingInit() {
...
@@ -5651,7 +5692,7 @@ void UnitTestImpl::PostFlagParsingInit() {
listeners
()
->
Append
(
new
GTEST_CUSTOM_TEST_EVENT_LISTENER_
());
listeners
()
->
Append
(
new
GTEST_CUSTOM_TEST_EVENT_LISTENER_
());
#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
InitDeathTestSubprocessControlInfo
();
InitDeathTestSubprocessControlInfo
();
SuppressTestEventsIfInSubprocess
();
SuppressTestEventsIfInSubprocess
();
#endif // GTEST_HAS_DEATH_TEST
#endif // GTEST_HAS_DEATH_TEST
...
@@ -5674,7 +5715,7 @@ void UnitTestImpl::PostFlagParsingInit() {
...
@@ -5674,7 +5715,7 @@ void UnitTestImpl::PostFlagParsingInit() {
ConfigureStreamingOutput
();
ConfigureStreamingOutput
();
#endif // GTEST_CAN_STREAM_RESULTS_
#endif // GTEST_CAN_STREAM_RESULTS_
#if GTEST_HAS_ABSL
#if
def
GTEST_HAS_ABSL
if
(
GTEST_FLAG_GET
(
install_failure_signal_handler
))
{
if
(
GTEST_FLAG_GET
(
install_failure_signal_handler
))
{
absl
::
FailureSignalHandlerOptions
options
;
absl
::
FailureSignalHandlerOptions
options
;
absl
::
InstallFailureSignalHandler
(
options
);
absl
::
InstallFailureSignalHandler
(
options
);
...
@@ -5789,9 +5830,8 @@ bool UnitTestImpl::RunAllTests() {
...
@@ -5789,9 +5830,8 @@ bool UnitTestImpl::RunAllTests() {
// death test.
// death test.
bool
in_subprocess_for_death_test
=
false
;
bool
in_subprocess_for_death_test
=
false
;
#if GTEST_HAS_DEATH_TEST
#ifdef GTEST_HAS_DEATH_TEST
in_subprocess_for_death_test
=
in_subprocess_for_death_test
=
(
internal_run_death_test_flag_
!=
nullptr
);
(
internal_run_death_test_flag_
.
get
()
!=
nullptr
);
#if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
#if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
if
(
in_subprocess_for_death_test
)
{
if
(
in_subprocess_for_death_test
)
{
GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_
();
GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_
();
...
@@ -5954,10 +5994,6 @@ bool UnitTestImpl::RunAllTests() {
...
@@ -5954,10 +5994,6 @@ bool UnitTestImpl::RunAllTests() {
"() before calling RUN_ALL_TESTS(). This is INVALID. Soon "
GTEST_NAME_
"() before calling RUN_ALL_TESTS(). This is INVALID. Soon "
GTEST_NAME_
" will start to enforce the valid usage. "
" will start to enforce the valid usage. "
"Please fix it ASAP, or IT WILL START TO FAIL.
\n
"
);
// NOLINT
"Please fix it ASAP, or IT WILL START TO FAIL.
\n
"
);
// NOLINT
#if GTEST_FOR_GOOGLE_
ColoredPrintf
(
GTestColor
::
kRed
,
"For more details, see http://wiki/Main/ValidGUnitMain.
\n
"
);
#endif // GTEST_FOR_GOOGLE_
}
}
return
!
failed
;
return
!
failed
;
...
@@ -6513,7 +6549,7 @@ static const char kColorEncodedHelpMessage[] =
...
@@ -6513,7 +6549,7 @@ static const char kColorEncodedHelpMessage[] =
#endif // GTEST_CAN_STREAM_RESULTS_
#endif // GTEST_CAN_STREAM_RESULTS_
"
\n
"
"
\n
"
"Assertion Behavior:
\n
"
"Assertion Behavior:
\n
"
#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
#if
defined(
GTEST_HAS_DEATH_TEST
)
&& !
defined(
GTEST_OS_WINDOWS
)
" @G--"
GTEST_FLAG_PREFIX_
" @G--"
GTEST_FLAG_PREFIX_
"death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D
\n
"
"death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D
\n
"
" Set the default death test style.
\n
"
" Set the default death test style.
\n
"
...
@@ -6654,26 +6690,60 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
...
@@ -6654,26 +6690,60 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
}
}
// Parses the command line for Google Test flags, without initializing
// Parses the command line for Google Test flags, without initializing
// other parts of Google Test.
// other parts of Google Test. This function updates argc and argv by removing
// flags that are known to GoogleTest (including other user flags defined using
// ABSL_FLAG if GoogleTest is built with GTEST_USE_ABSL). Other arguments
// remain in place. Unrecognized flags are not reported and do not cause the
// program to exit.
void
ParseGoogleTestFlagsOnly
(
int
*
argc
,
char
**
argv
)
{
void
ParseGoogleTestFlagsOnly
(
int
*
argc
,
char
**
argv
)
{
#if GTEST_HAS_ABSL
#ifdef GTEST_HAS_ABSL
if
(
*
argc
>
0
)
{
if
(
*
argc
<=
0
)
return
;
// absl::ParseCommandLine() requires *argc > 0.
auto
positional_args
=
absl
::
flags_internal
::
ParseCommandLineImpl
(
std
::
vector
<
char
*>
positional_args
;
*
argc
,
argv
,
absl
::
flags_internal
::
ArgvListAction
::
kRemoveParsedArgs
,
std
::
vector
<
absl
::
UnrecognizedFlag
>
unrecognized_flags
;
absl
::
flags_internal
::
UsageFlagsAction
::
kHandleUsage
,
absl
::
ParseAbseilFlagsOnly
(
*
argc
,
argv
,
positional_args
,
unrecognized_flags
);
absl
::
flags_internal
::
OnUndefinedFlag
::
kReportUndefined
);
absl
::
flat_hash_set
<
absl
::
string_view
>
unrecognized
;
// Any command-line positional arguments not part of any command-line flag
for
(
const
auto
&
flag
:
unrecognized_flags
)
{
// (or arguments to a flag) are copied back out to argv, with the program
unrecognized
.
insert
(
flag
.
flag_name
);
// invocation name at position 0, and argc is resized. This includes
}
// positional arguments after the flag-terminating delimiter '--'.
absl
::
flat_hash_set
<
char
*>
positional
;
// See https://abseil.io/docs/cpp/guides/flags.
for
(
const
auto
&
arg
:
positional_args
)
{
std
::
copy
(
positional_args
.
begin
(),
positional_args
.
end
(),
argv
);
positional
.
insert
(
arg
);
if
(
static_cast
<
int
>
(
positional_args
.
size
())
<
*
argc
)
{
}
argv
[
positional_args
.
size
()]
=
nullptr
;
*
argc
=
static_cast
<
int
>
(
positional_args
.
size
());
int
out_pos
=
1
;
int
in_pos
=
1
;
for
(;
in_pos
<
*
argc
;
++
in_pos
)
{
char
*
arg
=
argv
[
in_pos
];
absl
::
string_view
arg_str
(
arg
);
if
(
absl
::
ConsumePrefix
(
&
arg_str
,
"--"
))
{
// Flag-like argument. If the flag was unrecognized, keep it.
// If it was a GoogleTest flag, remove it.
if
(
unrecognized
.
contains
(
arg_str
))
{
argv
[
out_pos
++
]
=
argv
[
in_pos
];
continue
;
}
}
}
if
(
arg_str
.
empty
())
{
++
in_pos
;
break
;
// '--' indicates that the rest of the arguments are positional
}
// Probably a positional argument. If it is in fact positional, keep it.
// If it was a value for the flag argument, remove it.
if
(
positional
.
contains
(
arg
))
{
argv
[
out_pos
++
]
=
arg
;
}
}
// The rest are positional args for sure.
while
(
in_pos
<
*
argc
)
{
argv
[
out_pos
++
]
=
argv
[
in_pos
++
];
}
}
*
argc
=
out_pos
;
argv
[
out_pos
]
=
nullptr
;
#else
#else
ParseGoogleTestFlagsOnlyImpl
(
argc
,
argv
);
ParseGoogleTestFlagsOnlyImpl
(
argc
,
argv
);
#endif
#endif
...
@@ -6681,7 +6751,7 @@ void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
...
@@ -6681,7 +6751,7 @@ void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
// Fix the value of *_NSGetArgc() on macOS, but if and only if
// Fix the value of *_NSGetArgc() on macOS, but if and only if
// *_NSGetArgv() == argv
// *_NSGetArgv() == argv
// Only applicable to char** version of argv
// Only applicable to char** version of argv
#if GTEST_OS_MAC
#if
def
GTEST_OS_MAC
#ifndef GTEST_OS_IOS
#ifndef GTEST_OS_IOS
if
(
*
_NSGetArgv
()
==
argv
)
{
if
(
*
_NSGetArgv
()
==
argv
)
{
*
_NSGetArgc
()
=
*
argc
;
*
_NSGetArgc
()
=
*
argc
;
...
@@ -6709,7 +6779,7 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
...
@@ -6709,7 +6779,7 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
g_argvs
.
push_back
(
StreamableToString
(
argv
[
i
]));
g_argvs
.
push_back
(
StreamableToString
(
argv
[
i
]));
}
}
#if GTEST_HAS_ABSL
#if
def
GTEST_HAS_ABSL
absl
::
InitializeSymbolizer
(
g_argvs
[
0
].
c_str
());
absl
::
InitializeSymbolizer
(
g_argvs
[
0
].
c_str
());
// When using the Abseil Flags library, set the program usage message to the
// When using the Abseil Flags library, set the program usage message to the
...
@@ -6793,16 +6863,16 @@ static std::string GetDirFromEnv(
...
@@ -6793,16 +6863,16 @@ static std::string GetDirFromEnv(
std
::
string
TempDir
()
{
std
::
string
TempDir
()
{
#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)
#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)
return
GTEST_CUSTOM_TEMPDIR_FUNCTION_
();
return
GTEST_CUSTOM_TEMPDIR_FUNCTION_
();
#elif GTEST_OS_WINDOWS || GTEST_OS_WINDOWS_MOBILE
#elif
defined(
GTEST_OS_WINDOWS
)
||
defined(
GTEST_OS_WINDOWS_MOBILE
)
return
GetDirFromEnv
({
"TEST_TMPDIR"
,
"TEMP"
},
"
\\
temp
\\
"
,
'\\'
);
return
GetDirFromEnv
({
"TEST_TMPDIR"
,
"TEMP"
},
"
\\
temp
\\
"
,
'\\'
);
#elif GTEST_OS_LINUX_ANDROID
#elif
defined(
GTEST_OS_LINUX_ANDROID
)
return
GetDirFromEnv
({
"TEST_TMPDIR"
,
"TMPDIR"
},
"/data/local/tmp/"
,
'/'
);
return
GetDirFromEnv
({
"TEST_TMPDIR"
,
"TMPDIR"
},
"/data/local/tmp/"
,
'/'
);
#else
#else
return
GetDirFromEnv
({
"TEST_TMPDIR"
,
"TMPDIR"
},
"/tmp/"
,
'/'
);
return
GetDirFromEnv
({
"TEST_TMPDIR"
,
"TMPDIR"
},
"/tmp/"
,
'/'
);
#endif
#endif
}
}
#if !defined(GTEST_CUSTOM_SRCDIR_FUNCTION_)
#if
GTEST_HAS_FILE_SYSTEM &&
!defined(GTEST_CUSTOM_SRCDIR_FUNCTION_)
// Returns the directory path (including terminating separator) of the current
// Returns the directory path (including terminating separator) of the current
// executable as derived from argv[0].
// executable as derived from argv[0].
static
std
::
string
GetCurrentExecutableDirectory
()
{
static
std
::
string
GetCurrentExecutableDirectory
()
{
...
@@ -6811,13 +6881,14 @@ static std::string GetCurrentExecutableDirectory() {
...
@@ -6811,13 +6881,14 @@ static std::string GetCurrentExecutableDirectory() {
}
}
#endif
#endif
#if GTEST_HAS_FILE_SYSTEM
std
::
string
SrcDir
()
{
std
::
string
SrcDir
()
{
#if defined(GTEST_CUSTOM_SRCDIR_FUNCTION_)
#if defined(GTEST_CUSTOM_SRCDIR_FUNCTION_)
return
GTEST_CUSTOM_SRCDIR_FUNCTION_
();
return
GTEST_CUSTOM_SRCDIR_FUNCTION_
();
#elif GTEST_OS_WINDOWS || GTEST_OS_WINDOWS_MOBILE
#elif
defined(
GTEST_OS_WINDOWS
)
||
defined(
GTEST_OS_WINDOWS_MOBILE
)
return
GetDirFromEnv
({
"TEST_SRCDIR"
},
GetCurrentExecutableDirectory
().
c_str
(),
return
GetDirFromEnv
({
"TEST_SRCDIR"
},
GetCurrentExecutableDirectory
().
c_str
(),
'\\'
);
'\\'
);
#elif GTEST_OS_LINUX_ANDROID
#elif
defined(
GTEST_OS_LINUX_ANDROID
)
return
GetDirFromEnv
({
"TEST_SRCDIR"
},
GetCurrentExecutableDirectory
().
c_str
(),
return
GetDirFromEnv
({
"TEST_SRCDIR"
},
GetCurrentExecutableDirectory
().
c_str
(),
'/'
);
'/'
);
#else
#else
...
@@ -6825,6 +6896,7 @@ std::string SrcDir() {
...
@@ -6825,6 +6896,7 @@ std::string SrcDir() {
'/'
);
'/'
);
#endif
#endif
}
}
#endif
// Class ScopedTrace
// Class ScopedTrace
...
...
googletest/src/gtest_main.cc
View file @
76bce79a
...
@@ -31,10 +31,10 @@
...
@@ -31,10 +31,10 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#if GTEST_OS_ESP8266 || GTEST_OS_ESP32
#if
defined(
GTEST_OS_ESP8266
)
||
defined(
GTEST_OS_ESP32
)
// Arduino-like platforms: program entry points are setup/loop instead of main.
// Arduino-like platforms: program entry points are setup/loop instead of main.
#if GTEST_OS_ESP8266
#if
def
GTEST_OS_ESP8266
extern
"C"
{
extern
"C"
{
#endif
#endif
...
@@ -42,11 +42,11 @@ void setup() { testing::InitGoogleTest(); }
...
@@ -42,11 +42,11 @@ void setup() { testing::InitGoogleTest(); }
void
loop
()
{
RUN_ALL_TESTS
();
}
void
loop
()
{
RUN_ALL_TESTS
();
}
#if GTEST_OS_ESP8266
#if
def
GTEST_OS_ESP8266
}
}
#endif
#endif
#elif GTEST_OS_QURT
#elif
defined(
GTEST_OS_QURT
)
// QuRT: program entry point is main, but argc/argv are unusable.
// QuRT: program entry point is main, but argc/argv are unusable.
GTEST_API_
int
main
()
{
GTEST_API_
int
main
()
{
...
...
googletest/test/googletest-break-on-failure-unittest_.cc
View file @
76bce79a
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
#include <stdlib.h>
#include <stdlib.h>
#include <windows.h>
#include <windows.h>
#endif
#endif
...
@@ -49,7 +49,7 @@ namespace {
...
@@ -49,7 +49,7 @@ namespace {
// A test that's expected to fail.
// A test that's expected to fail.
TEST
(
Foo
,
Bar
)
{
EXPECT_EQ
(
2
,
3
);
}
TEST
(
Foo
,
Bar
)
{
EXPECT_EQ
(
2
,
3
);
}
#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
#if GTEST_HAS_SEH && !
defined(
GTEST_OS_WINDOWS_MOBILE
)
// On Windows Mobile global exception handlers are not supported.
// On Windows Mobile global exception handlers are not supported.
LONG
WINAPI
LONG
WINAPI
ExitWithExceptionCode
(
struct
_EXCEPTION_POINTERS
*
exception_pointers
)
{
ExitWithExceptionCode
(
struct
_EXCEPTION_POINTERS
*
exception_pointers
)
{
...
@@ -60,12 +60,12 @@ ExitWithExceptionCode(struct _EXCEPTION_POINTERS* exception_pointers) {
...
@@ -60,12 +60,12 @@ ExitWithExceptionCode(struct _EXCEPTION_POINTERS* exception_pointers) {
}
// namespace
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
// Suppresses display of the Windows error dialog upon encountering
// Suppresses display of the Windows error dialog upon encountering
// a general protection fault (segment violation).
// a general protection fault (segment violation).
SetErrorMode
(
SEM_NOGPFAULTERRORBOX
|
SEM_FAILCRITICALERRORS
);
SetErrorMode
(
SEM_NOGPFAULTERRORBOX
|
SEM_FAILCRITICALERRORS
);
#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
#if GTEST_HAS_SEH && !
defined(
GTEST_OS_WINDOWS_MOBILE
)
// The default unhandled exception filter does not always exit
// The default unhandled exception filter does not always exit
// with the exception code as exit code - for example it exits with
// with the exception code as exit code - for example it exits with
...
...
googletest/test/googletest-death-test-test.cc
View file @
76bce79a
...
@@ -37,9 +37,9 @@
...
@@ -37,9 +37,9 @@
using
testing
::
internal
::
AlwaysFalse
;
using
testing
::
internal
::
AlwaysFalse
;
using
testing
::
internal
::
AlwaysTrue
;
using
testing
::
internal
::
AlwaysTrue
;
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
#include <direct.h> // For chdir().
#include <direct.h> // For chdir().
#include <fcntl.h> // For O_BINARY
#include <fcntl.h> // For O_BINARY
#include <io.h>
#include <io.h>
...
@@ -52,7 +52,10 @@ using testing::internal::AlwaysTrue;
...
@@ -52,7 +52,10 @@ using testing::internal::AlwaysTrue;
#include <signal.h>
#include <signal.h>
#include <stdio.h>
#include <stdio.h>
#if GTEST_OS_LINUX
#include <string>
#include <vector>
#ifdef GTEST_OS_LINUX
#include <sys/time.h>
#include <sys/time.h>
#endif // GTEST_OS_LINUX
#endif // GTEST_OS_LINUX
...
@@ -200,7 +203,7 @@ int DieInDebugElse12(int* sideeffect) {
...
@@ -200,7 +203,7 @@ int DieInDebugElse12(int* sideeffect) {
return
12
;
return
12
;
}
}
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
// Death in dbg due to Windows CRT assertion failure, not opt.
// Death in dbg due to Windows CRT assertion failure, not opt.
int
DieInCRTDebugElse12
(
int
*
sideeffect
)
{
int
DieInCRTDebugElse12
(
int
*
sideeffect
)
{
...
@@ -220,7 +223,7 @@ int DieInCRTDebugElse12(int* sideeffect) {
...
@@ -220,7 +223,7 @@ int DieInCRTDebugElse12(int* sideeffect) {
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
#if
defined(
GTEST_OS_WINDOWS
)
||
defined(
GTEST_OS_FUCHSIA
)
// Tests the ExitedWithCode predicate.
// Tests the ExitedWithCode predicate.
TEST
(
ExitStatusPredicateTest
,
ExitedWithCode
)
{
TEST
(
ExitStatusPredicateTest
,
ExitedWithCode
)
{
...
@@ -374,7 +377,7 @@ TEST_F(TestForDeathTest, FastDeathTestInChangedDir) {
...
@@ -374,7 +377,7 @@ TEST_F(TestForDeathTest, FastDeathTestInChangedDir) {
ASSERT_DEATH
(
_exit
(
1
),
""
);
ASSERT_DEATH
(
_exit
(
1
),
""
);
}
}
#if GTEST_OS_LINUX
#if
def
GTEST_OS_LINUX
void
SigprofAction
(
int
,
siginfo_t
*
,
void
*
)
{
/* no op */
void
SigprofAction
(
int
,
siginfo_t
*
,
void
*
)
{
/* no op */
}
}
...
@@ -641,7 +644,7 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
...
@@ -641,7 +644,7 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
#endif
#endif
}
}
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode
// In debug mode, the calls to _CrtSetReportMode and _CrtSetReportFile enable
// In debug mode, the calls to _CrtSetReportMode and _CrtSetReportFile enable
...
@@ -693,7 +696,7 @@ void ExpectDebugDeathHelper(bool* aborted) {
...
@@ -693,7 +696,7 @@ void ExpectDebugDeathHelper(bool* aborted) {
*
aborted
=
false
;
*
aborted
=
false
;
}
}
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
TEST
(
PopUpDeathTest
,
DoesNotShowPopUpOnAbort
)
{
TEST
(
PopUpDeathTest
,
DoesNotShowPopUpOnAbort
)
{
printf
(
printf
(
"This test should be considered failing if it shows "
"This test should be considered failing if it shows "
...
@@ -805,14 +808,14 @@ static void TestExitMacros() {
...
@@ -805,14 +808,14 @@ static void TestExitMacros() {
EXPECT_EXIT
(
_exit
(
1
),
testing
::
ExitedWithCode
(
1
),
""
);
EXPECT_EXIT
(
_exit
(
1
),
testing
::
ExitedWithCode
(
1
),
""
);
ASSERT_EXIT
(
_exit
(
42
),
testing
::
ExitedWithCode
(
42
),
""
);
ASSERT_EXIT
(
_exit
(
42
),
testing
::
ExitedWithCode
(
42
),
""
);
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
// Of all signals effects on the process exit code, only those of SIGABRT
// Of all signals effects on the process exit code, only those of SIGABRT
// are documented on Windows.
// are documented on Windows.
// See https://msdn.microsoft.com/en-us/query-bi/m/dwwzkt4c.
// See https://msdn.microsoft.com/en-us/query-bi/m/dwwzkt4c.
EXPECT_EXIT
(
raise
(
SIGABRT
),
testing
::
ExitedWithCode
(
3
),
""
)
<<
"b_ar"
;
EXPECT_EXIT
(
raise
(
SIGABRT
),
testing
::
ExitedWithCode
(
3
),
""
)
<<
"b_ar"
;
#elif !GTEST_OS_FUCHSIA
#elif !
defined(
GTEST_OS_FUCHSIA
)
// Fuchsia has no unix signals.
// Fuchsia has no unix signals.
EXPECT_EXIT
(
raise
(
SIGKILL
),
testing
::
KilledBySignal
(
SIGKILL
),
""
)
<<
"foo"
;
EXPECT_EXIT
(
raise
(
SIGKILL
),
testing
::
KilledBySignal
(
SIGKILL
),
""
)
<<
"foo"
;
...
@@ -1177,7 +1180,7 @@ TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {
...
@@ -1177,7 +1180,7 @@ TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {
EXPECT_STREQ
(
""
,
GetLastErrnoDescription
().
c_str
());
EXPECT_STREQ
(
""
,
GetLastErrnoDescription
().
c_str
());
}
}
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
TEST
(
AutoHandleTest
,
AutoHandleWorks
)
{
TEST
(
AutoHandleTest
,
AutoHandleWorks
)
{
HANDLE
handle
=
::
CreateEvent
(
NULL
,
FALSE
,
FALSE
,
NULL
);
HANDLE
handle
=
::
CreateEvent
(
NULL
,
FALSE
,
FALSE
,
NULL
);
ASSERT_NE
(
INVALID_HANDLE_VALUE
,
handle
);
ASSERT_NE
(
INVALID_HANDLE_VALUE
,
handle
);
...
@@ -1204,7 +1207,7 @@ TEST(AutoHandleTest, AutoHandleWorks) {
...
@@ -1204,7 +1207,7 @@ TEST(AutoHandleTest, AutoHandleWorks) {
}
}
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
typedef
unsigned
__int64
BiggestParsable
;
typedef
unsigned
__int64
BiggestParsable
;
typedef
signed
__int64
BiggestSignedParsable
;
typedef
signed
__int64
BiggestSignedParsable
;
#else
#else
...
@@ -1301,7 +1304,7 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
...
@@ -1301,7 +1304,7 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
EXPECT_EQ
(
123
,
char_result
);
EXPECT_EQ
(
123
,
char_result
);
}
}
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
TEST
(
EnvironmentTest
,
HandleFitsIntoSizeT
)
{
TEST
(
EnvironmentTest
,
HandleFitsIntoSizeT
)
{
ASSERT_TRUE
(
sizeof
(
HANDLE
)
<=
sizeof
(
size_t
));
ASSERT_TRUE
(
sizeof
(
HANDLE
)
<=
sizeof
(
size_t
));
}
}
...
@@ -1353,7 +1356,7 @@ void DieWithMessage(const char* message) {
...
@@ -1353,7 +1356,7 @@ void DieWithMessage(const char* message) {
TEST
(
MatcherDeathTest
,
DoesNotBreakBareRegexMatching
)
{
TEST
(
MatcherDeathTest
,
DoesNotBreakBareRegexMatching
)
{
// googletest tests this, of course; here we ensure that including googlemock
// googletest tests this, of course; here we ensure that including googlemock
// has not broken it.
// has not broken it.
#if GTEST_USES_POSIX_RE
#if
def
GTEST_USES_POSIX_RE
EXPECT_DEATH
(
DieWithMessage
(
"O, I die, Horatio."
),
"I d[aeiou]e"
);
EXPECT_DEATH
(
DieWithMessage
(
"O, I die, Horatio."
),
"I d[aeiou]e"
);
#else
#else
EXPECT_DEATH
(
DieWithMessage
(
"O, I die, Horatio."
),
"I di?e"
);
EXPECT_DEATH
(
DieWithMessage
(
"O, I die, Horatio."
),
"I di?e"
);
...
...
googletest/test/googletest-death-test_ex_test.cc
View file @
76bce79a
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include "gtest/gtest-death-test.h"
#include "gtest/gtest-death-test.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_SEH
#if GTEST_HAS_SEH
#include <windows.h> // For RaiseException().
#include <windows.h> // For RaiseException().
...
...
googletest/test/googletest-filepath-test.cc
View file @
76bce79a
...
@@ -41,9 +41,9 @@
...
@@ -41,9 +41,9 @@
#include "gtest/internal/gtest-filepath.h"
#include "gtest/internal/gtest-filepath.h"
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#if GTEST_OS_WINDOWS_MOBILE
#if
def
GTEST_OS_WINDOWS_MOBILE
#include <windows.h> // NOLINT
#include <windows.h> // NOLINT
#elif GTEST_OS_WINDOWS
#elif
defined(
GTEST_OS_WINDOWS
)
#include <direct.h> // NOLINT
#include <direct.h> // NOLINT
#endif // GTEST_OS_WINDOWS_MOBILE
#endif // GTEST_OS_WINDOWS_MOBILE
...
@@ -51,7 +51,7 @@ namespace testing {
...
@@ -51,7 +51,7 @@ namespace testing {
namespace
internal
{
namespace
internal
{
namespace
{
namespace
{
#if GTEST_OS_WINDOWS_MOBILE
#if
def
GTEST_OS_WINDOWS_MOBILE
// Windows CE doesn't have the remove C function.
// Windows CE doesn't have the remove C function.
int
remove
(
const
char
*
path
)
{
int
remove
(
const
char
*
path
)
{
...
@@ -80,7 +80,7 @@ TEST(GetCurrentDirTest, ReturnsCurrentDir) {
...
@@ -80,7 +80,7 @@ TEST(GetCurrentDirTest, ReturnsCurrentDir) {
const
FilePath
cwd
=
FilePath
::
GetCurrentDir
();
const
FilePath
cwd
=
FilePath
::
GetCurrentDir
();
posix
::
ChDir
(
original_dir
.
c_str
());
posix
::
ChDir
(
original_dir
.
c_str
());
#if GTEST_OS_WINDOWS || GTEST_OS_OS2
#if
defined(
GTEST_OS_WINDOWS
)
||
defined(
GTEST_OS_OS2
)
// Skips the ":".
// Skips the ":".
const
char
*
const
cwd_without_drive
=
strchr
(
cwd
.
c_str
(),
':'
);
const
char
*
const
cwd_without_drive
=
strchr
(
cwd
.
c_str
(),
':'
);
...
@@ -174,7 +174,7 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) {
...
@@ -174,7 +174,7 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) {
// RemoveFileName "" -> "./"
// RemoveFileName "" -> "./"
TEST
(
RemoveFileNameTest
,
EmptyName
)
{
TEST
(
RemoveFileNameTest
,
EmptyName
)
{
#if GTEST_OS_WINDOWS_MOBILE
#if
def
GTEST_OS_WINDOWS_MOBILE
// On Windows CE, we use the root as the current directory.
// On Windows CE, we use the root as the current directory.
EXPECT_EQ
(
GTEST_PATH_SEP_
,
FilePath
(
""
).
RemoveFileName
().
string
());
EXPECT_EQ
(
GTEST_PATH_SEP_
,
FilePath
(
""
).
RemoveFileName
().
string
());
#else
#else
...
@@ -357,7 +357,7 @@ TEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) {
...
@@ -357,7 +357,7 @@ TEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) {
}
}
TEST
(
DirectoryTest
,
RootDirectoryExists
)
{
TEST
(
DirectoryTest
,
RootDirectoryExists
)
{
#if GTEST_OS_WINDOWS
// We are on Windows.
#if
def
GTEST_OS_WINDOWS // We are on Windows.
char
current_drive
[
_MAX_PATH
];
// NOLINT
char
current_drive
[
_MAX_PATH
];
// NOLINT
current_drive
[
0
]
=
static_cast
<
char
>
(
_getdrive
()
+
'A'
-
1
);
current_drive
[
0
]
=
static_cast
<
char
>
(
_getdrive
()
+
'A'
-
1
);
current_drive
[
1
]
=
':'
;
current_drive
[
1
]
=
':'
;
...
@@ -369,7 +369,7 @@ TEST(DirectoryTest, RootDirectoryExists) {
...
@@ -369,7 +369,7 @@ TEST(DirectoryTest, RootDirectoryExists) {
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
}
}
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
TEST
(
DirectoryTest
,
RootOfWrongDriveDoesNotExists
)
{
TEST
(
DirectoryTest
,
RootOfWrongDriveDoesNotExists
)
{
const
int
saved_drive_
=
_getdrive
();
const
int
saved_drive_
=
_getdrive
();
// Find a drive that doesn't exist. Start with 'Z' to avoid common ones.
// Find a drive that doesn't exist. Start with 'Z' to avoid common ones.
...
@@ -387,7 +387,7 @@ TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) {
...
@@ -387,7 +387,7 @@ TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) {
}
}
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
#if
!
GTEST_OS_WINDOWS_MOBILE
#if
ndef
GTEST_OS_WINDOWS_MOBILE
// Windows CE _does_ consider an empty directory to exist.
// Windows CE _does_ consider an empty directory to exist.
TEST
(
DirectoryTest
,
EmptyPathDirectoryDoesNotExist
)
{
TEST
(
DirectoryTest
,
EmptyPathDirectoryDoesNotExist
)
{
EXPECT_FALSE
(
FilePath
(
""
).
DirectoryExists
());
EXPECT_FALSE
(
FilePath
(
""
).
DirectoryExists
());
...
@@ -395,7 +395,7 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {
...
@@ -395,7 +395,7 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {
#endif // !GTEST_OS_WINDOWS_MOBILE
#endif // !GTEST_OS_WINDOWS_MOBILE
TEST
(
DirectoryTest
,
CurrentDirectoryExists
)
{
TEST
(
DirectoryTest
,
CurrentDirectoryExists
)
{
#if GTEST_OS_WINDOWS // We are on Windows.
#if
def
GTEST_OS_WINDOWS // We are on Windows.
#ifndef _WIN32_CE // Windows CE doesn't have a current directory.
#ifndef _WIN32_CE // Windows CE doesn't have a current directory.
EXPECT_TRUE
(
FilePath
(
"."
).
DirectoryExists
());
EXPECT_TRUE
(
FilePath
(
"."
).
DirectoryExists
());
...
@@ -423,7 +423,7 @@ TEST(NormalizeTest, MultipleConsecutiveSeparatorsInMidstring) {
...
@@ -423,7 +423,7 @@ TEST(NormalizeTest, MultipleConsecutiveSeparatorsInMidstring) {
// "/bar" == //bar" == "///bar"
// "/bar" == //bar" == "///bar"
TEST
(
NormalizeTest
,
MultipleConsecutiveSeparatorsAtStringStart
)
{
TEST
(
NormalizeTest
,
MultipleConsecutiveSeparatorsAtStringStart
)
{
EXPECT_EQ
(
GTEST_PATH_SEP_
"bar"
,
FilePath
(
GTEST_PATH_SEP_
"bar"
).
string
());
EXPECT_EQ
(
GTEST_PATH_SEP_
"bar"
,
FilePath
(
GTEST_PATH_SEP_
"bar"
).
string
());
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
EXPECT_EQ
(
GTEST_PATH_SEP_
GTEST_PATH_SEP_
"bar"
,
EXPECT_EQ
(
GTEST_PATH_SEP_
GTEST_PATH_SEP_
"bar"
,
FilePath
(
GTEST_PATH_SEP_
GTEST_PATH_SEP_
"bar"
).
string
());
FilePath
(
GTEST_PATH_SEP_
GTEST_PATH_SEP_
"bar"
).
string
());
#else
#else
...
@@ -515,7 +515,7 @@ class DirectoryCreationTest : public Test {
...
@@ -515,7 +515,7 @@ class DirectoryCreationTest : public Test {
}
}
// Strings representing a directory and a file, with identical paths
// Strings representing a directory and a file, with identical paths
// except for the trailing separator character that distin
q
uishes
// except for the trailing separator character that distin
g
uishes
// a directory named 'test' from a file named 'test'. Example names:
// a directory named 'test' from a file named 'test'. Example names:
FilePath
testdata_path_
;
// "/tmp/directory_creation/test/"
FilePath
testdata_path_
;
// "/tmp/directory_creation/test/"
FilePath
testdata_file_
;
// "/tmp/directory_creation/test"
FilePath
testdata_file_
;
// "/tmp/directory_creation/test"
...
@@ -620,7 +620,7 @@ TEST(FilePathTest, IsDirectory) {
...
@@ -620,7 +620,7 @@ TEST(FilePathTest, IsDirectory) {
TEST
(
FilePathTest
,
IsAbsolutePath
)
{
TEST
(
FilePathTest
,
IsAbsolutePath
)
{
EXPECT_FALSE
(
FilePath
(
"is"
GTEST_PATH_SEP_
"relative"
).
IsAbsolutePath
());
EXPECT_FALSE
(
FilePath
(
"is"
GTEST_PATH_SEP_
"relative"
).
IsAbsolutePath
());
EXPECT_FALSE
(
FilePath
(
""
).
IsAbsolutePath
());
EXPECT_FALSE
(
FilePath
(
""
).
IsAbsolutePath
());
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
EXPECT_TRUE
(
EXPECT_TRUE
(
FilePath
(
"c:
\\
"
GTEST_PATH_SEP_
"is_not"
GTEST_PATH_SEP_
"relative"
)
FilePath
(
"c:
\\
"
GTEST_PATH_SEP_
"is_not"
GTEST_PATH_SEP_
"relative"
)
.
IsAbsolutePath
());
.
IsAbsolutePath
());
...
@@ -638,7 +638,7 @@ TEST(FilePathTest, IsAbsolutePath) {
...
@@ -638,7 +638,7 @@ TEST(FilePathTest, IsAbsolutePath) {
}
}
TEST
(
FilePathTest
,
IsRootDirectory
)
{
TEST
(
FilePathTest
,
IsRootDirectory
)
{
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
EXPECT_TRUE
(
FilePath
(
"a:
\\
"
).
IsRootDirectory
());
EXPECT_TRUE
(
FilePath
(
"a:
\\
"
).
IsRootDirectory
());
EXPECT_TRUE
(
FilePath
(
"Z:/"
).
IsRootDirectory
());
EXPECT_TRUE
(
FilePath
(
"Z:/"
).
IsRootDirectory
());
EXPECT_TRUE
(
FilePath
(
"e://"
).
IsRootDirectory
());
EXPECT_TRUE
(
FilePath
(
"e://"
).
IsRootDirectory
());
...
...
googletest/test/googletest-json-outfiles-test.py
View file @
76bce79a
...
@@ -88,20 +88,20 @@ EXPECTED_2 = {
...
@@ -88,20 +88,20 @@ EXPECTED_2 = {
'time'
:
'*'
,
'time'
:
'*'
,
'timestamp'
:
'*'
,
'timestamp'
:
'*'
,
'testsuite'
:
[{
'testsuite'
:
[{
'name'
:
'TestInt64Properties'
,
'name'
:
'TestInt64
Convertible
Properties'
,
'file'
:
'gtest_xml_outfile2_test_.cc'
,
'file'
:
'gtest_xml_outfile2_test_.cc'
,
'line'
:
4
1
,
'line'
:
4
3
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'timestamp'
:
'*'
,
'timestamp'
:
'*'
,
'time'
:
'*'
,
'time'
:
'*'
,
'classname'
:
'PropertyTwo'
,
'classname'
:
'PropertyTwo'
,
'SetUpProp'
:
'2'
,
'SetUpProp'
:
'2'
,
'TestFloatProperty'
:
'3'
,
'TestFloatProperty'
:
'3
.25
'
,
'TestDoubleProperty'
:
'4'
,
'TestDoubleProperty'
:
'4
.75
'
,
'TestSizetProperty'
:
'5'
,
'TestSizetProperty'
:
'5'
,
'TestBoolProperty'
:
'
1
'
,
'TestBoolProperty'
:
'
true
'
,
'TestCharProperty'
:
'
65
'
,
'TestCharProperty'
:
'
A
'
,
'TestInt16Property'
:
'6'
,
'TestInt16Property'
:
'6'
,
'TestInt32Property'
:
'7'
,
'TestInt32Property'
:
'7'
,
'TestInt64Property'
:
'8'
,
'TestInt64Property'
:
'8'
,
...
...
googletest/test/googletest-json-output-unittest.py
View file @
76bce79a
...
@@ -54,7 +54,7 @@ SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv
...
@@ -54,7 +54,7 @@ SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv
if
SUPPORTS_STACK_TRACES
:
if
SUPPORTS_STACK_TRACES
:
STACK_TRACE_TEMPLATE
=
'
\n
Stack trace:
\n
*'
STACK_TRACE_TEMPLATE
=
'
\n
Stack trace:
\n
*'
else
:
else
:
STACK_TRACE_TEMPLATE
=
''
STACK_TRACE_TEMPLATE
=
'
\n
'
EXPECTED_NON_EMPTY
=
{
EXPECTED_NON_EMPTY
=
{
'tests'
:
26
,
'tests'
:
26
,
...
@@ -77,7 +77,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -77,7 +77,7 @@ EXPECTED_NON_EMPTY = {
'testsuite'
:
[{
'testsuite'
:
[{
'name'
:
'Succeeds'
,
'name'
:
'Succeeds'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
5
1
,
'line'
:
5
3
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -96,7 +96,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -96,7 +96,7 @@ EXPECTED_NON_EMPTY = {
'testsuite'
:
[{
'testsuite'
:
[{
'name'
:
'Fails'
,
'name'
:
'Fails'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
59
,
'line'
:
61
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -124,7 +124,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -124,7 +124,7 @@ EXPECTED_NON_EMPTY = {
'testsuite'
:
[{
'testsuite'
:
[{
'name'
:
'DISABLED_test_not_run'
,
'name'
:
'DISABLED_test_not_run'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
6
6
,
'line'
:
6
8
,
'status'
:
'NOTRUN'
,
'status'
:
'NOTRUN'
,
'result'
:
'SUPPRESSED'
,
'result'
:
'SUPPRESSED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -144,7 +144,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -144,7 +144,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'Skipped'
,
'name'
:
'Skipped'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
7
3
,
'line'
:
7
5
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'SKIPPED'
,
'result'
:
'SKIPPED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -154,7 +154,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -154,7 +154,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'SkippedWithMessage'
,
'name'
:
'SkippedWithMessage'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
7
7
,
'line'
:
7
9
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'SKIPPED'
,
'result'
:
'SKIPPED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -164,7 +164,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -164,7 +164,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'SkippedAfterFailure'
,
'name'
:
'SkippedAfterFailure'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
8
1
,
'line'
:
8
3
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -194,7 +194,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -194,7 +194,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'Succeeds'
,
'name'
:
'Succeeds'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
8
6
,
'line'
:
8
8
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -204,7 +204,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -204,7 +204,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'Fails'
,
'name'
:
'Fails'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
9
1
,
'line'
:
9
3
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -234,7 +234,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -234,7 +234,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'DISABLED_test'
,
'name'
:
'DISABLED_test'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
9
6
,
'line'
:
9
8
,
'status'
:
'NOTRUN'
,
'status'
:
'NOTRUN'
,
'result'
:
'SUPPRESSED'
,
'result'
:
'SUPPRESSED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -254,7 +254,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -254,7 +254,7 @@ EXPECTED_NON_EMPTY = {
'testsuite'
:
[{
'testsuite'
:
[{
'name'
:
'OutputsCData'
,
'name'
:
'OutputsCData'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
10
0
,
'line'
:
10
2
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -282,7 +282,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -282,7 +282,7 @@ EXPECTED_NON_EMPTY = {
'testsuite'
:
[{
'testsuite'
:
[{
'name'
:
'InvalidCharactersInMessage'
,
'name'
:
'InvalidCharactersInMessage'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
10
7
,
'line'
:
10
9
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -313,7 +313,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -313,7 +313,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'OneProperty'
,
'name'
:
'OneProperty'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
11
9
,
'line'
:
1
2
1
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -324,7 +324,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -324,7 +324,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'IntValuedProperty'
,
'name'
:
'IntValuedProperty'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
12
3
,
'line'
:
12
5
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -335,7 +335,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -335,7 +335,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'ThreeProperties'
,
'name'
:
'ThreeProperties'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
12
7
,
'line'
:
12
9
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -348,7 +348,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -348,7 +348,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'TwoValuesForOneKeyUsesLastValue'
,
'name'
:
'TwoValuesForOneKeyUsesLastValue'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
13
3
,
'line'
:
13
5
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -370,7 +370,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -370,7 +370,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'RecordProperty'
,
'name'
:
'RecordProperty'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
1
38
,
'line'
:
1
40
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -381,7 +381,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -381,7 +381,7 @@ EXPECTED_NON_EMPTY = {
{
{
'name'
:
'ExternalUtilityThatCallsRecordIntValuedProperty'
,
'name'
:
'ExternalUtilityThatCallsRecordIntValuedProperty'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
15
1
,
'line'
:
15
3
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -394,7 +394,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -394,7 +394,7 @@ EXPECTED_NON_EMPTY = {
'ExternalUtilityThatCallsRecordStringValuedProperty'
'ExternalUtilityThatCallsRecordStringValuedProperty'
),
),
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
15
5
,
'line'
:
15
7
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -416,7 +416,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -416,7 +416,7 @@ EXPECTED_NON_EMPTY = {
'name'
:
'HasTypeParamAttribute'
,
'name'
:
'HasTypeParamAttribute'
,
'type_param'
:
'int'
,
'type_param'
:
'int'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
17
1
,
'line'
:
17
3
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -436,7 +436,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -436,7 +436,7 @@ EXPECTED_NON_EMPTY = {
'name'
:
'HasTypeParamAttribute'
,
'name'
:
'HasTypeParamAttribute'
,
'type_param'
:
'long'
,
'type_param'
:
'long'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
17
1
,
'line'
:
17
3
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -456,7 +456,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -456,7 +456,7 @@ EXPECTED_NON_EMPTY = {
'name'
:
'HasTypeParamAttribute'
,
'name'
:
'HasTypeParamAttribute'
,
'type_param'
:
'int'
,
'type_param'
:
'int'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
1
7
8
,
'line'
:
18
0
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -476,7 +476,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -476,7 +476,7 @@ EXPECTED_NON_EMPTY = {
'name'
:
'HasTypeParamAttribute'
,
'name'
:
'HasTypeParamAttribute'
,
'type_param'
:
'long'
,
'type_param'
:
'long'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
1
7
8
,
'line'
:
18
0
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -497,7 +497,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -497,7 +497,7 @@ EXPECTED_NON_EMPTY = {
'name'
:
'HasValueParamAttribute/0'
,
'name'
:
'HasValueParamAttribute/0'
,
'value_param'
:
'33'
,
'value_param'
:
'33'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
16
2
,
'line'
:
16
4
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -508,7 +508,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -508,7 +508,7 @@ EXPECTED_NON_EMPTY = {
'name'
:
'HasValueParamAttribute/1'
,
'name'
:
'HasValueParamAttribute/1'
,
'value_param'
:
'42'
,
'value_param'
:
'42'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
16
2
,
'line'
:
16
4
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -519,7 +519,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -519,7 +519,7 @@ EXPECTED_NON_EMPTY = {
'name'
:
'AnotherTestThatHasValueParamAttribute/0'
,
'name'
:
'AnotherTestThatHasValueParamAttribute/0'
,
'value_param'
:
'33'
,
'value_param'
:
'33'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
16
3
,
'line'
:
16
5
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -530,7 +530,7 @@ EXPECTED_NON_EMPTY = {
...
@@ -530,7 +530,7 @@ EXPECTED_NON_EMPTY = {
'name'
:
'AnotherTestThatHasValueParamAttribute/1'
,
'name'
:
'AnotherTestThatHasValueParamAttribute/1'
,
'value_param'
:
'42'
,
'value_param'
:
'42'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
16
3
,
'line'
:
16
5
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
@@ -562,7 +562,7 @@ EXPECTED_FILTERED = {
...
@@ -562,7 +562,7 @@ EXPECTED_FILTERED = {
'testsuite'
:
[{
'testsuite'
:
[{
'name'
:
'Succeeds'
,
'name'
:
'Succeeds'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'file'
:
'gtest_xml_output_unittest_.cc'
,
'line'
:
5
1
,
'line'
:
5
3
,
'status'
:
'RUN'
,
'status'
:
'RUN'
,
'result'
:
'COMPLETED'
,
'result'
:
'COMPLETED'
,
'time'
:
'*'
,
'time'
:
'*'
,
...
...
googletest/test/googletest-list-tests-unittest_.cc
View file @
76bce79a
...
@@ -36,6 +36,9 @@
...
@@ -36,6 +36,9 @@
// This program will be invoked from a Python unit test.
// This program will be invoked from a Python unit test.
// Don't run it directly.
// Don't run it directly.
#include <ostream>
#include <string>
#include "gtest/gtest.h"
#include "gtest/gtest.h"
// Several different test cases and tests that will be listed.
// Several different test cases and tests that will be listed.
...
...
googletest/test/googletest-listener-test.cc
View file @
76bce79a
...
@@ -32,19 +32,14 @@
...
@@ -32,19 +32,14 @@
// This file verifies Google Test event listeners receive events at the
// This file verifies Google Test event listeners receive events at the
// right times.
// right times.
#include <string>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "gtest/internal/custom/gtest.h"
#include "gtest/internal/custom/gtest.h"
using
::
testing
::
AddGlobalTestEnvironment
;
using
::
testing
::
AddGlobalTestEnvironment
;
using
::
testing
::
Environment
;
using
::
testing
::
InitGoogleTest
;
using
::
testing
::
InitGoogleTest
;
using
::
testing
::
Test
;
using
::
testing
::
TestEventListener
;
using
::
testing
::
TestInfo
;
using
::
testing
::
TestPartResult
;
using
::
testing
::
TestSuite
;
using
::
testing
::
UnitTest
;
using
::
testing
::
UnitTest
;
// Used by tests to register their events.
// Used by tests to register their events.
...
@@ -278,7 +273,7 @@ int main(int argc, char** argv) {
...
@@ -278,7 +273,7 @@ int main(int argc, char** argv) {
AddGlobalTestEnvironment
(
new
EnvironmentInvocationCatcher
);
AddGlobalTestEnvironment
(
new
EnvironmentInvocationCatcher
);
GTEST_CHECK_
(
events
.
size
()
==
0
)
GTEST_CHECK_
(
events
.
empty
()
)
<<
"AddGlobalTestEnvironment should not generate any events itself."
;
<<
"AddGlobalTestEnvironment should not generate any events itself."
;
GTEST_FLAG_SET
(
repeat
,
2
);
GTEST_FLAG_SET
(
repeat
,
2
);
...
...
googletest/test/googletest-options-test.cc
View file @
76bce79a
...
@@ -40,11 +40,11 @@
...
@@ -40,11 +40,11 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#if GTEST_OS_WINDOWS_MOBILE
#if
def
GTEST_OS_WINDOWS_MOBILE
#include <windows.h>
#include <windows.h>
#elif GTEST_OS_WINDOWS
#elif
defined(
GTEST_OS_WINDOWS
)
#include <direct.h>
#include <direct.h>
#elif GTEST_OS_OS2
#elif
defined(
GTEST_OS_OS2
)
// For strcasecmp on OS/2
// For strcasecmp on OS/2
#include <strings.h>
#include <strings.h>
#endif // GTEST_OS_WINDOWS_MOBILE
#endif // GTEST_OS_WINDOWS_MOBILE
...
@@ -92,7 +92,7 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
...
@@ -92,7 +92,7 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
.
string
();
.
string
();
const
std
::
string
&
output_file
=
const
std
::
string
&
output_file
=
UnitTestOptions
::
GetAbsolutePathToOutputFile
();
UnitTestOptions
::
GetAbsolutePathToOutputFile
();
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
EXPECT_STRCASEEQ
(
expected_output_file
.
c_str
(),
output_file
.
c_str
());
EXPECT_STRCASEEQ
(
expected_output_file
.
c_str
(),
output_file
.
c_str
());
#else
#else
EXPECT_EQ
(
expected_output_file
,
output_file
.
c_str
());
EXPECT_EQ
(
expected_output_file
,
output_file
.
c_str
());
...
@@ -101,19 +101,19 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
...
@@ -101,19 +101,19 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
TEST
(
OutputFileHelpersTest
,
GetCurrentExecutableName
)
{
TEST
(
OutputFileHelpersTest
,
GetCurrentExecutableName
)
{
const
std
::
string
exe_str
=
GetCurrentExecutableName
().
string
();
const
std
::
string
exe_str
=
GetCurrentExecutableName
().
string
();
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
const
bool
success
=
const
bool
success
=
_strcmpi
(
"googletest-options-test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"googletest-options-test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"gtest-options-ex_test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"gtest-options-ex_test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"gtest_all_test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"gtest_all_test"
,
exe_str
.
c_str
())
==
0
||
_strcmpi
(
"gtest_dll_test"
,
exe_str
.
c_str
())
==
0
;
_strcmpi
(
"gtest_dll_test"
,
exe_str
.
c_str
())
==
0
;
#elif GTEST_OS_OS2
#elif
defined(
GTEST_OS_OS2
)
const
bool
success
=
const
bool
success
=
strcasecmp
(
"googletest-options-test"
,
exe_str
.
c_str
())
==
0
||
strcasecmp
(
"googletest-options-test"
,
exe_str
.
c_str
())
==
0
||
strcasecmp
(
"gtest-options-ex_test"
,
exe_str
.
c_str
())
==
0
||
strcasecmp
(
"gtest-options-ex_test"
,
exe_str
.
c_str
())
==
0
||
strcasecmp
(
"gtest_all_test"
,
exe_str
.
c_str
())
==
0
||
strcasecmp
(
"gtest_all_test"
,
exe_str
.
c_str
())
==
0
||
strcasecmp
(
"gtest_dll_test"
,
exe_str
.
c_str
())
==
0
;
strcasecmp
(
"gtest_dll_test"
,
exe_str
.
c_str
())
==
0
;
#elif GTEST_OS_FUCHSIA
#elif
defined(
GTEST_OS_FUCHSIA
)
const
bool
success
=
exe_str
==
"app"
;
const
bool
success
=
exe_str
==
"app"
;
#else
#else
const
bool
success
=
const
bool
success
=
...
@@ -123,7 +123,7 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
...
@@ -123,7 +123,7 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
if
(
!
success
)
FAIL
()
<<
"GetCurrentExecutableName() returns "
<<
exe_str
;
if
(
!
success
)
FAIL
()
<<
"GetCurrentExecutableName() returns "
<<
exe_str
;
}
}
#if
!
GTEST_OS_FUCHSIA
#if
ndef
GTEST_OS_FUCHSIA
class
XmlOutputChangeDirTest
:
public
Test
{
class
XmlOutputChangeDirTest
:
public
Test
{
protected:
protected:
...
@@ -176,7 +176,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
...
@@ -176,7 +176,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
.
string
();
.
string
();
const
std
::
string
&
output_file
=
const
std
::
string
&
output_file
=
UnitTestOptions
::
GetAbsolutePathToOutputFile
();
UnitTestOptions
::
GetAbsolutePathToOutputFile
();
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
EXPECT_STRCASEEQ
(
expected_output_file
.
c_str
(),
output_file
.
c_str
());
EXPECT_STRCASEEQ
(
expected_output_file
.
c_str
(),
output_file
.
c_str
());
#else
#else
EXPECT_EQ
(
expected_output_file
,
output_file
.
c_str
());
EXPECT_EQ
(
expected_output_file
,
output_file
.
c_str
());
...
@@ -184,7 +184,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
...
@@ -184,7 +184,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
}
}
TEST_F
(
XmlOutputChangeDirTest
,
PreserveOriginalWorkingDirWithAbsoluteFile
)
{
TEST_F
(
XmlOutputChangeDirTest
,
PreserveOriginalWorkingDirWithAbsoluteFile
)
{
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
GTEST_FLAG_SET
(
output
,
"xml:c:
\\
tmp
\\
filename.abc"
);
GTEST_FLAG_SET
(
output
,
"xml:c:
\\
tmp
\\
filename.abc"
);
EXPECT_EQ
(
FilePath
(
"c:
\\
tmp
\\
filename.abc"
).
string
(),
EXPECT_EQ
(
FilePath
(
"c:
\\
tmp
\\
filename.abc"
).
string
(),
UnitTestOptions
::
GetAbsolutePathToOutputFile
());
UnitTestOptions
::
GetAbsolutePathToOutputFile
());
...
@@ -196,7 +196,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
...
@@ -196,7 +196,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
}
}
TEST_F
(
XmlOutputChangeDirTest
,
PreserveOriginalWorkingDirWithAbsolutePath
)
{
TEST_F
(
XmlOutputChangeDirTest
,
PreserveOriginalWorkingDirWithAbsolutePath
)
{
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
const
std
::
string
path
=
"c:
\\
tmp
\\
"
;
const
std
::
string
path
=
"c:
\\
tmp
\\
"
;
#else
#else
const
std
::
string
path
=
"/tmp/"
;
const
std
::
string
path
=
"/tmp/"
;
...
@@ -208,7 +208,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
...
@@ -208,7 +208,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
const
std
::
string
&
output_file
=
const
std
::
string
&
output_file
=
UnitTestOptions
::
GetAbsolutePathToOutputFile
();
UnitTestOptions
::
GetAbsolutePathToOutputFile
();
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
EXPECT_STRCASEEQ
(
expected_output_file
.
c_str
(),
output_file
.
c_str
());
EXPECT_STRCASEEQ
(
expected_output_file
.
c_str
(),
output_file
.
c_str
());
#else
#else
EXPECT_EQ
(
expected_output_file
,
output_file
.
c_str
());
EXPECT_EQ
(
expected_output_file
,
output_file
.
c_str
());
...
...
googletest/test/googletest-output-test.py
View file @
76bce79a
...
@@ -132,7 +132,7 @@ def RemoveStackTraces(output):
...
@@ -132,7 +132,7 @@ def RemoveStackTraces(output):
"""Removes all traces of stack traces from a Google Test program's output."""
"""Removes all traces of stack traces from a Google Test program's output."""
# *? means "find the shortest string that matches".
# *? means "find the shortest string that matches".
return
re
.
sub
(
r
'Stack trace:(.|\n)*?\n
\n
'
,
''
,
output
)
return
re
.
sub
(
r
'Stack trace:(.|\n)*?\n'
,
''
,
output
)
def
RemoveTime
(
output
):
def
RemoveTime
(
output
):
...
...
googletest/test/googletest-output-test_.cc
View file @
76bce79a
...
@@ -35,13 +35,16 @@
...
@@ -35,13 +35,16 @@
#include <stdlib.h>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include "gtest/gtest-spi.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
GTEST_DISABLE_MSC_WARNINGS_PUSH_
(
4127
/* conditional expression is constant */
)
GTEST_DISABLE_MSC_WARNINGS_PUSH_
(
4127
/* conditional expression is constant */
)
#if GTEST_IS_THREADSAFE
#if
def
GTEST_IS_THREADSAFE
using
testing
::
ScopedFakeTestPartResultReporter
;
using
testing
::
ScopedFakeTestPartResultReporter
;
using
testing
::
TestPartResultArray
;
using
testing
::
TestPartResultArray
;
...
@@ -247,7 +250,7 @@ TEST(SCOPED_TRACETest, CanBeRepeated) {
...
@@ -247,7 +250,7 @@ TEST(SCOPED_TRACETest, CanBeRepeated) {
<<
"contain trace point A, B, and D."
;
<<
"contain trace point A, B, and D."
;
}
}
#if GTEST_IS_THREADSAFE
#if
def
GTEST_IS_THREADSAFE
// Tests that SCOPED_TRACE()s can be used concurrently from multiple
// Tests that SCOPED_TRACE()s can be used concurrently from multiple
// threads. Namely, an assertion should be affected by
// threads. Namely, an assertion should be affected by
// SCOPED_TRACE()s in its own thread only.
// SCOPED_TRACE()s in its own thread only.
...
@@ -773,7 +776,7 @@ REGISTER_TYPED_TEST_SUITE_P(DetectNotInstantiatedTypesTest, Used);
...
@@ -773,7 +776,7 @@ REGISTER_TYPED_TEST_SUITE_P(DetectNotInstantiatedTypesTest, Used);
// typedef ::testing::Types<char, int, unsigned int> MyTypes;
// typedef ::testing::Types<char, int, unsigned int> MyTypes;
// INSTANTIATE_TYPED_TEST_SUITE_P(All, DetectNotInstantiatedTypesTest, MyTypes);
// INSTANTIATE_TYPED_TEST_SUITE_P(All, DetectNotInstantiatedTypesTest, MyTypes);
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
// We rely on the golden file to verify that tests whose test case
// We rely on the golden file to verify that tests whose test case
// name ends with DeathTest are run first.
// name ends with DeathTest are run first.
...
@@ -851,7 +854,7 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailure) {
...
@@ -851,7 +854,7 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailure) {
"failure."
);
"failure."
);
}
}
#if GTEST_IS_THREADSAFE
#if
def
GTEST_IS_THREADSAFE
class
ExpectFailureWithThreadsTest
:
public
ExpectFailureTest
{
class
ExpectFailureWithThreadsTest
:
public
ExpectFailureTest
{
protected:
protected:
...
@@ -1024,11 +1027,11 @@ int main(int argc, char** argv) {
...
@@ -1024,11 +1027,11 @@ int main(int argc, char** argv) {
std
::
count
(
argv
,
argv
+
argc
,
std
::
count
(
argv
,
argv
+
argc
,
std
::
string
(
"internal_skip_environment_and_ad_hoc_tests"
))
>
0
;
std
::
string
(
"internal_skip_environment_and_ad_hoc_tests"
))
>
0
;
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
if
(
GTEST_FLAG_GET
(
internal_run_death_test
)
!=
""
)
{
if
(
!
GTEST_FLAG_GET
(
internal_run_death_test
)
.
empty
()
)
{
// Skip the usual output capturing if we're running as the child
// Skip the usual output capturing if we're running as the child
// process of an threadsafe-style death test.
// process of an threadsafe-style death test.
#if GTEST_OS_WINDOWS
#if
defined(
GTEST_OS_WINDOWS
)
posix
::
FReopen
(
"nul:"
,
"w"
,
stdout
);
posix
::
FReopen
(
"nul:"
,
"w"
,
stdout
);
#else
#else
posix
::
FReopen
(
"/dev/null"
,
"w"
,
stdout
);
posix
::
FReopen
(
"/dev/null"
,
"w"
,
stdout
);
...
...
googletest/test/googletest-param-test-invalid-name2-test_.cc
View file @
76bce79a
...
@@ -27,6 +27,8 @@
...
@@ -27,6 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string>
#include "gtest/gtest.h"
#include "gtest/gtest.h"
namespace
{
namespace
{
...
...
googletest/test/googletest-param-test-test.cc
View file @
76bce79a
...
@@ -221,7 +221,7 @@ class DogAdder {
...
@@ -221,7 +221,7 @@ class DogAdder {
}
}
DogAdder
operator
+
(
const
DogAdder
&
other
)
const
{
DogAdder
operator
+
(
const
DogAdder
&
other
)
const
{
Message
msg
;
Message
msg
;
msg
<<
value_
.
c_str
()
<<
other
.
value_
.
c_str
()
;
msg
<<
value_
<<
other
.
value_
;
return
DogAdder
(
msg
.
GetString
().
c_str
());
return
DogAdder
(
msg
.
GetString
().
c_str
());
}
}
bool
operator
<
(
const
DogAdder
&
other
)
const
{
return
value_
<
other
.
value_
;
}
bool
operator
<
(
const
DogAdder
&
other
)
const
{
return
value_
<
other
.
value_
;
}
...
...
googletest/test/googletest-port-test.cc
View file @
76bce79a
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-port.h"
#if GTEST_OS_MAC
#if
def
GTEST_OS_MAC
#include <time.h>
#include <time.h>
#endif // GTEST_OS_MAC
#endif // GTEST_OS_MAC
...
@@ -97,7 +97,7 @@ class Base {
...
@@ -97,7 +97,7 @@ class Base {
explicit
Base
(
int
n
)
:
member_
(
n
)
{}
explicit
Base
(
int
n
)
:
member_
(
n
)
{}
Base
(
const
Base
&
)
=
default
;
Base
(
const
Base
&
)
=
default
;
Base
&
operator
=
(
const
Base
&
)
=
default
;
Base
&
operator
=
(
const
Base
&
)
=
default
;
virtual
~
Base
()
{}
virtual
~
Base
()
=
default
;
int
member
()
{
return
member_
;
}
int
member
()
{
return
member_
;
}
private:
private:
...
@@ -281,9 +281,11 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
...
@@ -281,9 +281,11 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
EXPECT_EQ
(
"unknown file"
,
FormatCompilerIndependentFileLocation
(
nullptr
,
-
1
));
EXPECT_EQ
(
"unknown file"
,
FormatCompilerIndependentFileLocation
(
nullptr
,
-
1
));
}
}
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA || \
#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC) || \
GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
defined(GTEST_OS_QNX) || defined(GTEST_OS_FUCHSIA) || \
GTEST_OS_NETBSD || GTEST_OS_OPENBSD || GTEST_OS_GNU_HURD
defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
defined(GTEST_OS_GNU_KFREEBSD) || defined(GTEST_OS_NETBSD) || \
defined(GTEST_OS_OPENBSD) || defined(GTEST_OS_GNU_HURD)
void
*
ThreadFunc
(
void
*
data
)
{
void
*
ThreadFunc
(
void
*
data
)
{
internal
::
Mutex
*
mutex
=
static_cast
<
internal
::
Mutex
*>
(
data
);
internal
::
Mutex
*
mutex
=
static_cast
<
internal
::
Mutex
*>
(
data
);
mutex
->
Lock
();
mutex
->
Lock
();
...
@@ -359,7 +361,7 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
...
@@ -359,7 +361,7 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
const
char
regex
[]
=
const
char
regex
[]
=
#ifdef _MSC_VER
#ifdef _MSC_VER
"googletest-port-test
\\
.cc
\\
(
\\
d+
\\
):"
"googletest-port-test
\\
.cc
\\
(
\\
d+
\\
):"
#elif GTEST_USES_POSIX_RE
#elif
defined(
GTEST_USES_POSIX_RE
)
"googletest-port-test
\\
.cc:[0-9]+"
"googletest-port-test
\\
.cc:[0-9]+"
#else
#else
"googletest-port-test
\\
.cc:
\\
d+"
"googletest-port-test
\\
.cc:
\\
d+"
...
@@ -370,7 +372,7 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
...
@@ -370,7 +372,7 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
regex
);
regex
);
}
}
#if GTEST_HAS_DEATH_TEST
#if
def
GTEST_HAS_DEATH_TEST
TEST
(
GtestCheckDeathTest
,
LivesSilentlyOnSuccess
)
{
TEST
(
GtestCheckDeathTest
,
LivesSilentlyOnSuccess
)
{
EXPECT_EXIT
(
EXPECT_EXIT
(
...
@@ -388,7 +390,7 @@ TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) {
...
@@ -388,7 +390,7 @@ TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) {
// the platform. The test will produce compiler errors in case of failure.
// the platform. The test will produce compiler errors in case of failure.
// For simplicity, we only cover the most important platforms here.
// For simplicity, we only cover the most important platforms here.
TEST
(
RegexEngineSelectionTest
,
SelectsCorrectRegexEngine
)
{
TEST
(
RegexEngineSelectionTest
,
SelectsCorrectRegexEngine
)
{
#if GTEST_HAS_ABSL
#if
def
GTEST_HAS_ABSL
EXPECT_TRUE
(
GTEST_USES_RE2
);
EXPECT_TRUE
(
GTEST_USES_RE2
);
#elif GTEST_HAS_POSIX_RE
#elif GTEST_HAS_POSIX_RE
EXPECT_TRUE
(
GTEST_USES_POSIX_RE
);
EXPECT_TRUE
(
GTEST_USES_POSIX_RE
);
...
@@ -397,7 +399,7 @@ TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) {
...
@@ -397,7 +399,7 @@ TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) {
#endif
#endif
}
}
#if GTEST_USES_POSIX_RE
#if
def
GTEST_USES_POSIX_RE
template
<
typename
Str
>
template
<
typename
Str
>
class
RETest
:
public
::
testing
::
Test
{};
class
RETest
:
public
::
testing
::
Test
{};
...
@@ -454,7 +456,7 @@ TYPED_TEST(RETest, PartialMatchWorks) {
...
@@ -454,7 +456,7 @@ TYPED_TEST(RETest, PartialMatchWorks) {
EXPECT_FALSE
(
RE
::
PartialMatch
(
TypeParam
(
"zza"
),
re
));
EXPECT_FALSE
(
RE
::
PartialMatch
(
TypeParam
(
"zza"
),
re
));
}
}
#elif GTEST_USES_SIMPLE_RE
#elif
defined(
GTEST_USES_SIMPLE_RE
)
TEST
(
IsInSetTest
,
NulCharIsNotInAnySet
)
{
TEST
(
IsInSetTest
,
NulCharIsNotInAnySet
)
{
EXPECT_FALSE
(
IsInSet
(
'\0'
,
""
));
EXPECT_FALSE
(
IsInSet
(
'\0'
,
""
));
...
@@ -916,7 +918,7 @@ TEST(RETest, PartialMatchWorks) {
...
@@ -916,7 +918,7 @@ TEST(RETest, PartialMatchWorks) {
#endif // GTEST_USES_POSIX_RE
#endif // GTEST_USES_POSIX_RE
#if
!
GTEST_OS_WINDOWS_MOBILE
#if
ndef
GTEST_OS_WINDOWS_MOBILE
TEST
(
CaptureTest
,
CapturesStdout
)
{
TEST
(
CaptureTest
,
CapturesStdout
)
{
CaptureStdout
();
CaptureStdout
();
...
@@ -977,14 +979,14 @@ TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {
...
@@ -977,14 +979,14 @@ TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {
EXPECT_EQ
(
&
i
,
t2
.
get
());
EXPECT_EQ
(
&
i
,
t2
.
get
());
}
}
class
NoDefaultContructor
{
class
NoDefaultCon
s
tructor
{
public:
public:
explicit
NoDefaultContructor
(
const
char
*
)
{}
explicit
NoDefaultCon
s
tructor
(
const
char
*
)
{}
NoDefaultContructor
(
const
NoDefaultContructor
&
)
{}
NoDefaultCon
s
tructor
(
const
NoDefaultCon
s
tructor
&
)
=
default
;
};
};
TEST
(
ThreadLocalTest
,
ValueDefaultContructorIsNotRequiredForParamVersion
)
{
TEST
(
ThreadLocalTest
,
ValueDefaultContructorIsNotRequiredForParamVersion
)
{
ThreadLocal
<
NoDefaultContructor
>
bar
(
NoDefaultContructor
(
"foo"
));
ThreadLocal
<
NoDefaultCon
s
tructor
>
bar
(
NoDefaultCon
s
tructor
(
"foo"
));
bar
.
pointer
();
bar
.
pointer
();
}
}
...
@@ -1009,7 +1011,7 @@ TEST(ThreadLocalTest, PointerAndConstPointerReturnSameValue) {
...
@@ -1009,7 +1011,7 @@ TEST(ThreadLocalTest, PointerAndConstPointerReturnSameValue) {
EXPECT_EQ
(
thread_local_string
.
pointer
(),
const_thread_local_string
.
pointer
());
EXPECT_EQ
(
thread_local_string
.
pointer
(),
const_thread_local_string
.
pointer
());
}
}
#if GTEST_IS_THREADSAFE
#if
def
GTEST_IS_THREADSAFE
void
AddTwo
(
int
*
param
)
{
*
param
+=
2
;
}
void
AddTwo
(
int
*
param
)
{
*
param
+=
2
;
}
...
@@ -1064,7 +1066,7 @@ class AtomicCounterWithMutex {
...
@@ -1064,7 +1066,7 @@ class AtomicCounterWithMutex {
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_unlock
(
&
memory_barrier_mutex
));
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_unlock
(
&
memory_barrier_mutex
));
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_destroy
(
&
memory_barrier_mutex
));
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_destroy
(
&
memory_barrier_mutex
));
#elif GTEST_OS_WINDOWS
#elif
defined(
GTEST_OS_WINDOWS
)
// On Windows, performing an interlocked access puts up a memory barrier.
// On Windows, performing an interlocked access puts up a memory barrier.
volatile
LONG
dummy
=
0
;
volatile
LONG
dummy
=
0
;
::
InterlockedIncrement
(
&
dummy
);
::
InterlockedIncrement
(
&
dummy
);
...
@@ -1102,9 +1104,9 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) {
...
@@ -1102,9 +1104,9 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) {
// Creates and runs kThreadCount threads that increment locked_counter
// Creates and runs kThreadCount threads that increment locked_counter
// kCycleCount times each.
// kCycleCount times each.
for
(
int
i
=
0
;
i
<
kThreadCount
;
++
i
)
{
for
(
int
i
=
0
;
i
<
kThreadCount
;
++
i
)
{
counting_threads
[
i
]
.
reset
(
new
ThreadType
(
counting_threads
[
i
]
=
std
::
make_unique
<
ThreadType
>
(
&
CountingThreadFunc
,
make_pair
(
&
locked_counter
,
kCycleCount
),
&
CountingThreadFunc
,
make_pair
(
&
locked_counter
,
kCycleCount
),
&
threads_can_start
)
)
;
&
threads_can_start
);
}
}
threads_can_start
.
Notify
();
threads_can_start
.
Notify
();
for
(
int
i
=
0
;
i
<
kThreadCount
;
++
i
)
counting_threads
[
i
]
->
Join
();
for
(
int
i
=
0
;
i
<
kThreadCount
;
++
i
)
counting_threads
[
i
]
->
Join
();
...
@@ -1146,14 +1148,14 @@ class DestructorCall {
...
@@ -1146,14 +1148,14 @@ class DestructorCall {
public:
public:
DestructorCall
()
{
DestructorCall
()
{
invoked_
=
false
;
invoked_
=
false
;
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
wait_event_
.
Reset
(
::
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
));
wait_event_
.
Reset
(
::
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
));
GTEST_CHECK_
(
wait_event_
.
Get
()
!=
NULL
);
GTEST_CHECK_
(
wait_event_
.
Get
()
!=
NULL
);
#endif
#endif
}
}
bool
CheckDestroyed
()
const
{
bool
CheckDestroyed
()
const
{
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
if
(
::
WaitForSingleObject
(
wait_event_
.
Get
(),
1000
)
!=
WAIT_OBJECT_0
)
if
(
::
WaitForSingleObject
(
wait_event_
.
Get
(),
1000
)
!=
WAIT_OBJECT_0
)
return
false
;
return
false
;
#endif
#endif
...
@@ -1162,7 +1164,7 @@ class DestructorCall {
...
@@ -1162,7 +1164,7 @@ class DestructorCall {
void
ReportDestroyed
()
{
void
ReportDestroyed
()
{
invoked_
=
true
;
invoked_
=
true
;
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
::
SetEvent
(
wait_event_
.
Get
());
::
SetEvent
(
wait_event_
.
Get
());
#endif
#endif
}
}
...
@@ -1178,7 +1180,7 @@ class DestructorCall {
...
@@ -1178,7 +1180,7 @@ class DestructorCall {
private:
private:
bool
invoked_
;
bool
invoked_
;
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
AutoHandle
wait_event_
;
AutoHandle
wait_event_
;
#endif
#endif
static
std
::
vector
<
DestructorCall
*>*
const
list_
;
static
std
::
vector
<
DestructorCall
*>*
const
list_
;
...
@@ -1278,12 +1280,12 @@ TEST(ThreadLocalTest, ThreadLocalMutationsAffectOnlyCurrentThread) {
...
@@ -1278,12 +1280,12 @@ TEST(ThreadLocalTest, ThreadLocalMutationsAffectOnlyCurrentThread) {
#endif // GTEST_IS_THREADSAFE
#endif // GTEST_IS_THREADSAFE
#if GTEST_OS_WINDOWS
#if
def
GTEST_OS_WINDOWS
TEST
(
WindowsTypesTest
,
HANDLEIsVoidStar
)
{
TEST
(
WindowsTypesTest
,
HANDLEIsVoidStar
)
{
StaticAssertTypeEq
<
HANDLE
,
void
*>
();
StaticAssertTypeEq
<
HANDLE
,
void
*>
();
}
}
#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR)
#if
defined(
GTEST_OS_WINDOWS_MINGW
)
&& !defined(__MINGW64_VERSION_MAJOR)
TEST
(
WindowsTypesTest
,
_CRITICAL_SECTIONIs_CRITICAL_SECTION
)
{
TEST
(
WindowsTypesTest
,
_CRITICAL_SECTIONIs_CRITICAL_SECTION
)
{
StaticAssertTypeEq
<
CRITICAL_SECTION
,
_CRITICAL_SECTION
>
();
StaticAssertTypeEq
<
CRITICAL_SECTION
,
_CRITICAL_SECTION
>
();
}
}
...
...
googletest/test/googletest-printers-test.cc
View file @
76bce79a
...
@@ -42,9 +42,11 @@
...
@@ -42,9 +42,11 @@
#include <list>
#include <list>
#include <map>
#include <map>
#include <memory>
#include <memory>
#include <ostream>
#include <set>
#include <set>
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <utility>
#include <utility>
...
@@ -106,7 +108,7 @@ class UnprintableTemplateInGlobal {
...
@@ -106,7 +108,7 @@ class UnprintableTemplateInGlobal {
// A user-defined streamable type in the global namespace.
// A user-defined streamable type in the global namespace.
class
StreamableInGlobal
{
class
StreamableInGlobal
{
public:
public:
virtual
~
StreamableInGlobal
()
{}
virtual
~
StreamableInGlobal
()
=
default
;
};
};
inline
void
operator
<<
(
::
std
::
ostream
&
os
,
const
StreamableInGlobal
&
/* x */
)
{
inline
void
operator
<<
(
::
std
::
ostream
&
os
,
const
StreamableInGlobal
&
/* x */
)
{
...
@@ -214,7 +216,7 @@ class PathLike {
...
@@ -214,7 +216,7 @@ class PathLike {
using
value_type
=
char
;
using
value_type
=
char
;
using
const_iterator
=
iterator
;
using
const_iterator
=
iterator
;
PathLike
()
{}
PathLike
()
=
default
;
iterator
begin
()
const
{
return
iterator
();
}
iterator
begin
()
const
{
return
iterator
();
}
iterator
end
()
const
{
return
iterator
();
}
iterator
end
()
const
{
return
iterator
();
}
...
@@ -266,7 +268,6 @@ using ::std::set;
...
@@ -266,7 +268,6 @@ using ::std::set;
using
::
std
::
vector
;
using
::
std
::
vector
;
using
::
testing
::
PrintToString
;
using
::
testing
::
PrintToString
;
using
::
testing
::
internal
::
FormatForComparisonFailureMessage
;
using
::
testing
::
internal
::
FormatForComparisonFailureMessage
;
using
::
testing
::
internal
::
ImplicitCast_
;
using
::
testing
::
internal
::
NativeArray
;
using
::
testing
::
internal
::
NativeArray
;
using
::
testing
::
internal
::
RelationToSourceReference
;
using
::
testing
::
internal
::
RelationToSourceReference
;
using
::
testing
::
internal
::
Strings
;
using
::
testing
::
internal
::
Strings
;
...
@@ -360,7 +361,7 @@ TEST(PrintCharTest, Char16) { EXPECT_EQ("U+0041", Print(u'A')); }
...
@@ -360,7 +361,7 @@ TEST(PrintCharTest, Char16) { EXPECT_EQ("U+0041", Print(u'A')); }
TEST
(
PrintCharTest
,
Char32
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
U'A'
));
}
TEST
(
PrintCharTest
,
Char32
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
U'A'
));
}
#ifdef __cpp_char8_t
#ifdef __cpp_
lib_
char8_t
TEST
(
PrintCharTest
,
Char8
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
u8'A'
));
}
TEST
(
PrintCharTest
,
Char8
)
{
EXPECT_EQ
(
"U+0041"
,
Print
(
u8'A'
));
}
#endif
#endif
...
@@ -413,7 +414,7 @@ TEST(PrintBuiltInTypeTest, Integer) {
...
@@ -413,7 +414,7 @@ TEST(PrintBuiltInTypeTest, Integer) {
Print
(
std
::
numeric_limits
<
uint64_t
>::
max
()));
// uint64
Print
(
std
::
numeric_limits
<
uint64_t
>::
max
()));
// uint64
EXPECT_EQ
(
"-9223372036854775808"
,
EXPECT_EQ
(
"-9223372036854775808"
,
Print
(
std
::
numeric_limits
<
int64_t
>::
min
()));
// int64
Print
(
std
::
numeric_limits
<
int64_t
>::
min
()));
// int64
#ifdef __cpp_char8_t
#ifdef __cpp_
lib_
char8_t
EXPECT_EQ
(
"U+0000"
,
EXPECT_EQ
(
"U+0000"
,
Print
(
std
::
numeric_limits
<
char8_t
>::
min
()));
// char8_t
Print
(
std
::
numeric_limits
<
char8_t
>::
min
()));
// char8_t
EXPECT_EQ
(
"U+00FF"
,
EXPECT_EQ
(
"U+00FF"
,
...
@@ -432,7 +433,7 @@ TEST(PrintBuiltInTypeTest, Integer) {
...
@@ -432,7 +433,7 @@ TEST(PrintBuiltInTypeTest, Integer) {
// Size types.
// Size types.
TEST
(
PrintBuiltInTypeTest
,
Size_t
)
{
TEST
(
PrintBuiltInTypeTest
,
Size_t
)
{
EXPECT_EQ
(
"1"
,
Print
(
sizeof
(
'a'
)));
// size_t.
EXPECT_EQ
(
"1"
,
Print
(
sizeof
(
'a'
)));
// size_t.
#if
!
GTEST_OS_WINDOWS
#if
ndef
GTEST_OS_WINDOWS
// Windows has no ssize_t type.
// Windows has no ssize_t type.
EXPECT_EQ
(
"-2"
,
Print
(
static_cast
<
ssize_t
>
(
-
2
)));
// ssize_t.
EXPECT_EQ
(
"-2"
,
Print
(
static_cast
<
ssize_t
>
(
-
2
)));
// ssize_t.
#endif // !GTEST_OS_WINDOWS
#endif // !GTEST_OS_WINDOWS
...
@@ -519,7 +520,7 @@ TEST(PrintCStringTest, EscapesProperly) {
...
@@ -519,7 +520,7 @@ TEST(PrintCStringTest, EscapesProperly) {
Print
(
p
));
Print
(
p
));
}
}
#ifdef __cpp_char8_t
#ifdef __cpp_
lib_
char8_t
// const char8_t*.
// const char8_t*.
TEST
(
PrintU8StringTest
,
Const
)
{
TEST
(
PrintU8StringTest
,
Const
)
{
const
char8_t
*
p
=
u8"界"
;
const
char8_t
*
p
=
u8"界"
;
...
@@ -748,7 +749,7 @@ AssertionResult HasPrefix(const StringType& str, const StringType& prefix) {
...
@@ -748,7 +749,7 @@ AssertionResult HasPrefix(const StringType& str, const StringType& prefix) {
struct
Foo
{
struct
Foo
{
public:
public:
virtual
~
Foo
()
{}
virtual
~
Foo
()
=
default
;
int
MyMethod
(
char
x
)
{
return
x
+
1
;
}
int
MyMethod
(
char
x
)
{
return
x
+
1
;
}
virtual
char
MyVirtualMethod
(
int
/* n */
)
{
return
'a'
;
}
virtual
char
MyVirtualMethod
(
int
/* n */
)
{
return
'a'
;
}
...
@@ -816,7 +817,7 @@ TEST(PrintArrayTest, CharArrayWithTerminatingNul) {
...
@@ -816,7 +817,7 @@ TEST(PrintArrayTest, CharArrayWithTerminatingNul) {
EXPECT_EQ
(
"
\"\\
0Hi
\"
"
,
PrintArrayHelper
(
a
));
EXPECT_EQ
(
"
\"\\
0Hi
\"
"
,
PrintArrayHelper
(
a
));
}
}
#ifdef __cpp_char8_t
#ifdef __cpp_
lib_
char8_t
// char_t array without terminating NUL.
// char_t array without terminating NUL.
TEST
(
PrintArrayTest
,
Char8ArrayWithNoTerminatingNul
)
{
TEST
(
PrintArrayTest
,
Char8ArrayWithNoTerminatingNul
)
{
// Array a contains '\0' in the middle and doesn't end with '\0'.
// Array a contains '\0' in the middle and doesn't end with '\0'.
...
@@ -936,7 +937,7 @@ TEST(PrintWideStringTest, StringAmbiguousHex) {
...
@@ -936,7 +937,7 @@ TEST(PrintWideStringTest, StringAmbiguousHex) {
}
}
#endif // GTEST_HAS_STD_WSTRING
#endif // GTEST_HAS_STD_WSTRING
#ifdef __cpp_char8_t
#ifdef __cpp_
lib_
char8_t
TEST
(
PrintStringTest
,
U8String
)
{
TEST
(
PrintStringTest
,
U8String
)
{
std
::
u8string
str
=
u8"Hello, 世界"
;
std
::
u8string
str
=
u8"Hello, 世界"
;
EXPECT_EQ
(
str
,
str
);
// Verify EXPECT_EQ compiles with this type.
EXPECT_EQ
(
str
,
str
);
// Verify EXPECT_EQ compiles with this type.
...
@@ -1796,7 +1797,8 @@ TEST(UniversalPrintTest, SmartPointers) {
...
@@ -1796,7 +1797,8 @@ TEST(UniversalPrintTest, SmartPointers) {
std
::
shared_ptr
<
int
>
p3
(
new
int
(
1979
));
std
::
shared_ptr
<
int
>
p3
(
new
int
(
1979
));
EXPECT_EQ
(
"(ptr = "
+
PrintPointer
(
p3
.
get
())
+
", value = 1979)"
,
EXPECT_EQ
(
"(ptr = "
+
PrintPointer
(
p3
.
get
())
+
", value = 1979)"
,
PrintToString
(
p3
));
PrintToString
(
p3
));
#if __cpp_lib_shared_ptr_arrays >= 201611L
#if defined(__cpp_lib_shared_ptr_arrays) && \
(__cpp_lib_shared_ptr_arrays >= 201611L)
std
::
shared_ptr
<
int
[]
>
p4
(
new
int
[
2
]);
std
::
shared_ptr
<
int
[]
>
p4
(
new
int
[
2
]);
EXPECT_EQ
(
"("
+
PrintPointer
(
p4
.
get
())
+
")"
,
PrintToString
(
p4
));
EXPECT_EQ
(
"("
+
PrintPointer
(
p4
.
get
())
+
")"
,
PrintToString
(
p4
));
#endif
#endif
...
@@ -1815,7 +1817,8 @@ TEST(UniversalPrintTest, SmartPointers) {
...
@@ -1815,7 +1817,8 @@ TEST(UniversalPrintTest, SmartPointers) {
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
const
int
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
const
int
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
volatile
int
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
volatile
int
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
volatile
const
int
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
volatile
const
int
>
()));
#if __cpp_lib_shared_ptr_arrays >= 201611L
#if defined(__cpp_lib_shared_ptr_arrays) && \
(__cpp_lib_shared_ptr_arrays >= 201611L)
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
int
[]
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
int
[]
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
const
int
[]
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
const
int
[]
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
volatile
int
[]
>
()));
EXPECT_EQ
(
"(nullptr)"
,
PrintToString
(
std
::
shared_ptr
<
volatile
int
[]
>
()));
...
...
googletest/test/googletest-shuffle-test_.cc
View file @
76bce79a
...
@@ -35,7 +35,6 @@ namespace {
...
@@ -35,7 +35,6 @@ namespace {
using
::
testing
::
EmptyTestEventListener
;
using
::
testing
::
EmptyTestEventListener
;
using
::
testing
::
InitGoogleTest
;
using
::
testing
::
InitGoogleTest
;
using
::
testing
::
Message
;
using
::
testing
::
Test
;
using
::
testing
::
Test
;
using
::
testing
::
TestEventListeners
;
using
::
testing
::
TestEventListeners
;
using
::
testing
::
TestInfo
;
using
::
testing
::
TestInfo
;
...
...
Prev
1
2
3
4
5
Next
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