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
4327d95b
Commit
4327d95b
authored
Oct 07, 2018
by
Jerry Turcios
Browse files
Merge branch 'master' of
https://github.com/google/googletest
parents
7caf5ffd
40f82ce5
Changes
59
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
380 additions
and
689 deletions
+380
-689
googletest/src/gtest-typed-test.cc
googletest/src/gtest-typed-test.cc
+1
-1
googletest/src/gtest.cc
googletest/src/gtest.cc
+103
-121
googletest/test/googletest-catch-exceptions-test_.cc
googletest/test/googletest-catch-exceptions-test_.cc
+1
-1
googletest/test/googletest-death-test-test.cc
googletest/test/googletest-death-test-test.cc
+10
-11
googletest/test/googletest-linked-ptr-test.cc
googletest/test/googletest-linked-ptr-test.cc
+10
-10
googletest/test/googletest-listener-test.cc
googletest/test/googletest-listener-test.cc
+1
-1
googletest/test/googletest-message-test.cc
googletest/test/googletest-message-test.cc
+2
-2
googletest/test/googletest-output-test_.cc
googletest/test/googletest-output-test_.cc
+5
-6
googletest/test/googletest-port-test.cc
googletest/test/googletest-port-test.cc
+13
-13
googletest/test/googletest-printers-test.cc
googletest/test/googletest-printers-test.cc
+14
-14
googletest/test/googletest-throw-on-failure-test_.cc
googletest/test/googletest-throw-on-failure-test_.cc
+1
-1
googletest/test/googletest-tuple-test.cc
googletest/test/googletest-tuple-test.cc
+1
-1
googletest/test/gtest-typed-test_test.cc
googletest/test/gtest-typed-test_test.cc
+4
-4
googletest/test/gtest-unittest-api_test.cc
googletest/test/gtest-unittest-api_test.cc
+6
-6
googletest/test/gtest_assert_by_exception_test.cc
googletest/test/gtest_assert_by_exception_test.cc
+1
-2
googletest/test/gtest_premature_exit_test.cc
googletest/test/gtest_premature_exit_test.cc
+2
-2
googletest/test/gtest_stress_test.cc
googletest/test/gtest_stress_test.cc
+1
-1
googletest/test/gtest_throw_on_failure_ex_test.cc
googletest/test/gtest_throw_on_failure_ex_test.cc
+1
-2
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+203
-490
No files found.
googletest/src/gtest-typed-test.cc
View file @
4327d95b
...
...
@@ -48,7 +48,7 @@ static const char* SkipSpaces(const char* str) {
static
std
::
vector
<
std
::
string
>
SplitIntoTestNames
(
const
char
*
src
)
{
std
::
vector
<
std
::
string
>
name_vec
;
src
=
SkipSpaces
(
src
);
for
(;
src
!=
NULL
;
src
=
SkipComma
(
src
))
{
for
(;
src
!=
nullptr
;
src
=
SkipComma
(
src
))
{
name_vec
.
push_back
(
StripTrailingSpaces
(
GetPrefixUntilComma
(
src
)));
}
return
name_vec
;
...
...
googletest/src/gtest.cc
View file @
4327d95b
This diff is collapsed.
Click to expand it.
googletest/test/googletest-catch-exceptions-test_.cc
View file @
4327d95b
...
...
@@ -277,7 +277,7 @@ TEST(CxxExceptionTest, ThrowsNonStdCxxException) {
// ones.
void
TerminateHandler
()
{
fprintf
(
stderr
,
"%s
\n
"
,
"Unhandled C++ exception terminating the program."
);
fflush
(
NULL
);
fflush
(
nullptr
);
exit
(
3
);
}
...
...
googletest/test/googletest-death-test-test.cc
View file @
4327d95b
...
...
@@ -370,13 +370,13 @@ void SetSigprofActionAndTimer() {
timer
.
it_interval
.
tv_sec
=
0
;
timer
.
it_interval
.
tv_usec
=
1
;
timer
.
it_value
=
timer
.
it_interval
;
ASSERT_EQ
(
0
,
setitimer
(
ITIMER_PROF
,
&
timer
,
NULL
));
ASSERT_EQ
(
0
,
setitimer
(
ITIMER_PROF
,
&
timer
,
nullptr
));
struct
sigaction
signal_action
;
memset
(
&
signal_action
,
0
,
sizeof
(
signal_action
));
sigemptyset
(
&
signal_action
.
sa_mask
);
signal_action
.
sa_sigaction
=
SigprofAction
;
signal_action
.
sa_flags
=
SA_RESTART
|
SA_SIGINFO
;
ASSERT_EQ
(
0
,
sigaction
(
SIGPROF
,
&
signal_action
,
NULL
));
ASSERT_EQ
(
0
,
sigaction
(
SIGPROF
,
&
signal_action
,
nullptr
));
}
// Disables ITIMER_PROF timer and ignores SIGPROF signal.
...
...
@@ -385,7 +385,7 @@ void DisableSigprofActionAndTimer(struct sigaction* old_signal_action) {
timer
.
it_interval
.
tv_sec
=
0
;
timer
.
it_interval
.
tv_usec
=
0
;
timer
.
it_value
=
timer
.
it_interval
;
ASSERT_EQ
(
0
,
setitimer
(
ITIMER_PROF
,
&
timer
,
NULL
));
ASSERT_EQ
(
0
,
setitimer
(
ITIMER_PROF
,
&
timer
,
nullptr
));
struct
sigaction
signal_action
;
memset
(
&
signal_action
,
0
,
sizeof
(
signal_action
));
sigemptyset
(
&
signal_action
.
sa_mask
);
...
...
@@ -466,7 +466,7 @@ TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
if
(
!
testing
::
GTEST_FLAG
(
death_test_use_fork
))
{
testing
::
GTEST_FLAG
(
death_test_style
)
=
"threadsafe"
;
pthread_flag
=
false
;
ASSERT_EQ
(
0
,
pthread_atfork
(
&
SetPthreadFlag
,
NULL
,
NULL
));
ASSERT_EQ
(
0
,
pthread_atfork
(
&
SetPthreadFlag
,
nullptr
,
nullptr
));
ASSERT_DEATH
(
_exit
(
1
),
""
);
ASSERT_FALSE
(
pthread_flag
);
}
...
...
@@ -1001,7 +1001,7 @@ bool MockDeathTestFactory::Create(const char* /*statement*/,
if
(
create_
)
{
*
test
=
new
MockDeathTest
(
this
,
role_
,
status_
,
passed_
);
}
else
{
*
test
=
NULL
;
*
test
=
nullptr
;
}
return
true
;
}
...
...
@@ -1021,9 +1021,9 @@ class MacroLogicDeathTest : public testing::Test {
static
void
TearDownTestCase
()
{
delete
replacer_
;
replacer_
=
NULL
;
replacer_
=
nullptr
;
delete
factory_
;
factory_
=
NULL
;
factory_
=
nullptr
;
}
// Runs a death test that breaks the rules by returning. Such a death
...
...
@@ -1037,10 +1037,9 @@ class MacroLogicDeathTest : public testing::Test {
}
};
testing
::
internal
::
ReplaceDeathTestFactory
*
MacroLogicDeathTest
::
replacer_
=
NULL
;
MockDeathTestFactory
*
MacroLogicDeathTest
::
factory_
=
NULL
;
testing
::
internal
::
ReplaceDeathTestFactory
*
MacroLogicDeathTest
::
replacer_
=
nullptr
;
MockDeathTestFactory
*
MacroLogicDeathTest
::
factory_
=
nullptr
;
// Test that nothing happens when the factory doesn't return a DeathTest:
TEST_F
(
MacroLogicDeathTest
,
NothingHappens
)
{
...
...
googletest/test/googletest-linked-ptr-test.cc
View file @
4327d95b
...
...
@@ -38,7 +38,7 @@ using testing::Message;
using
testing
::
internal
::
linked_ptr
;
int
num
;
Message
*
history
=
NULL
;
Message
*
history
=
nullptr
;
// Class which tracks allocation/deallocation
class
A
{
...
...
@@ -67,7 +67,7 @@ class LinkedPtrTest : public testing::Test {
virtual
~
LinkedPtrTest
()
{
delete
history
;
history
=
NULL
;
history
=
nullptr
;
}
};
...
...
@@ -77,18 +77,18 @@ TEST_F(LinkedPtrTest, GeneralTest) {
// Use explicit function call notation here to suppress self-assign warning.
a0
.
operator
=
(
a0
);
a1
=
a2
;
ASSERT_EQ
(
a0
.
get
(),
static_cast
<
A
*>
(
NULL
));
ASSERT_EQ
(
a1
.
get
(),
static_cast
<
A
*>
(
NULL
));
ASSERT_EQ
(
a2
.
get
(),
static_cast
<
A
*>
(
NULL
));
ASSERT_TRUE
(
a0
==
NULL
);
ASSERT_TRUE
(
a1
==
NULL
);
ASSERT_TRUE
(
a2
==
NULL
);
ASSERT_EQ
(
a0
.
get
(),
static_cast
<
A
*>
(
nullptr
));
ASSERT_EQ
(
a1
.
get
(),
static_cast
<
A
*>
(
nullptr
));
ASSERT_EQ
(
a2
.
get
(),
static_cast
<
A
*>
(
nullptr
));
ASSERT_TRUE
(
a0
==
nullptr
);
ASSERT_TRUE
(
a1
==
nullptr
);
ASSERT_TRUE
(
a2
==
nullptr
);
{
linked_ptr
<
A
>
a3
(
new
A
);
a0
=
a3
;
ASSERT_TRUE
(
a0
==
a3
);
ASSERT_TRUE
(
a0
!=
NULL
);
ASSERT_TRUE
(
a0
!=
nullptr
);
ASSERT_TRUE
(
a0
.
get
()
==
a3
);
ASSERT_TRUE
(
a0
==
a3
.
get
());
linked_ptr
<
A
>
a4
(
a0
);
...
...
@@ -101,7 +101,7 @@ TEST_F(LinkedPtrTest, GeneralTest) {
linked_ptr
<
A
>
a6
(
b0
);
ASSERT_TRUE
(
b0
==
a6
);
ASSERT_TRUE
(
a6
==
b0
);
ASSERT_TRUE
(
b0
!=
NULL
);
ASSERT_TRUE
(
b0
!=
nullptr
);
a5
=
b0
;
a5
=
b0
;
a3
->
Use
();
...
...
googletest/test/googletest-listener-test.cc
View file @
4327d95b
...
...
@@ -47,7 +47,7 @@ using ::testing::TestPartResult;
using
::
testing
::
UnitTest
;
// Used by tests to register their events.
std
::
vector
<
std
::
string
>*
g_events
=
NULL
;
std
::
vector
<
std
::
string
>*
g_events
=
nullptr
;
namespace
testing
{
namespace
internal
{
...
...
googletest/test/googletest-message-test.cc
View file @
4327d95b
...
...
@@ -85,7 +85,7 @@ TEST(MessageTest, StreamsPointer) {
// Tests streaming a NULL non-char pointer.
TEST
(
MessageTest
,
StreamsNullPointer
)
{
int
*
p
=
NULL
;
int
*
p
=
nullptr
;
EXPECT_EQ
(
"(null)"
,
(
Message
()
<<
p
).
GetString
());
}
...
...
@@ -96,7 +96,7 @@ TEST(MessageTest, StreamsCString) {
// Tests streaming a NULL C string.
TEST
(
MessageTest
,
StreamsNullCString
)
{
char
*
p
=
NULL
;
char
*
p
=
nullptr
;
EXPECT_EQ
(
"(null)"
,
(
Message
()
<<
p
).
GetString
());
}
...
...
googletest/test/googletest-output-test_.cc
View file @
4327d95b
...
...
@@ -174,7 +174,7 @@ TEST(SCOPED_TRACETest, AcceptedValues) {
SCOPED_TRACE
(
"literal string"
);
SCOPED_TRACE
(
std
::
string
(
"std::string"
));
SCOPED_TRACE
(
1337
);
// streamable type
const
char
*
null_value
=
NULL
;
const
char
*
null_value
=
nullptr
;
SCOPED_TRACE
(
null_value
);
ADD_FAILURE
()
<<
"Just checking that all these values work fine."
;
...
...
@@ -306,9 +306,8 @@ TEST(SCOPED_TRACETest, WorksConcurrently) {
printf
(
"(expecting 6 failures)
\n
"
);
CheckPoints
check_points
;
ThreadWithParam
<
CheckPoints
*>
thread
(
&
ThreadWithScopedTrace
,
&
check_points
,
NULL
);
ThreadWithParam
<
CheckPoints
*>
thread
(
&
ThreadWithScopedTrace
,
&
check_points
,
nullptr
);
check_points
.
n1
.
WaitForNotification
();
{
...
...
@@ -511,7 +510,7 @@ class DeathTestAndMultiThreadsTest : public testing::Test {
// Starts a thread and waits for it to begin.
virtual
void
SetUp
()
{
thread_
.
reset
(
new
ThreadWithParam
<
SpawnThreadNotifications
*>
(
&
ThreadRoutine
,
&
notifications_
,
NULL
));
&
ThreadRoutine
,
&
notifications_
,
nullptr
));
notifications_
.
spawn_thread_started
.
WaitForNotification
();
}
// Tells the thread to finish, and reaps it.
...
...
@@ -966,7 +965,7 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailure) {
class
ExpectFailureWithThreadsTest
:
public
ExpectFailureTest
{
protected:
static
void
AddFailureInOtherThread
(
FailureMode
failure
)
{
ThreadWithParam
<
FailureMode
>
thread
(
&
AddFailure
,
failure
,
NULL
);
ThreadWithParam
<
FailureMode
>
thread
(
&
AddFailure
,
failure
,
nullptr
);
thread
.
Join
();
}
};
...
...
googletest/test/googletest-port-test.cc
View file @
4327d95b
...
...
@@ -262,9 +262,9 @@ TEST(FormatFileLocationTest, FormatsFileLocation) {
}
TEST
(
FormatFileLocationTest
,
FormatsUnknownFile
)
{
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"unknown file"
,
FormatFileLocation
(
NULL
,
42
));
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"42"
,
FormatFileLocation
(
NULL
,
42
));
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"unknown file"
,
FormatFileLocation
(
nullptr
,
42
));
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"42"
,
FormatFileLocation
(
nullptr
,
42
));
}
TEST
(
FormatFileLocationTest
,
FormatsUknownLine
)
{
...
...
@@ -272,7 +272,7 @@ TEST(FormatFileLocationTest, FormatsUknownLine) {
}
TEST
(
FormatFileLocationTest
,
FormatsUknownFileAndLine
)
{
EXPECT_EQ
(
"unknown file:"
,
FormatFileLocation
(
NULL
,
-
1
));
EXPECT_EQ
(
"unknown file:"
,
FormatFileLocation
(
nullptr
,
-
1
));
}
// Verifies behavior of FormatCompilerIndependentFileLocation.
...
...
@@ -282,7 +282,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsFileLocation) {
TEST
(
FormatCompilerIndependentFileLocationTest
,
FormatsUknownFile
)
{
EXPECT_EQ
(
"unknown file:42"
,
FormatCompilerIndependentFileLocation
(
NULL
,
42
));
FormatCompilerIndependentFileLocation
(
nullptr
,
42
));
}
TEST
(
FormatCompilerIndependentFileLocationTest
,
FormatsUknownLine
)
{
...
...
@@ -290,7 +290,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) {
}
TEST
(
FormatCompilerIndependentFileLocationTest
,
FormatsUknownFileAndLine
)
{
EXPECT_EQ
(
"unknown file"
,
FormatCompilerIndependentFileLocation
(
NULL
,
-
1
));
EXPECT_EQ
(
"unknown file"
,
FormatCompilerIndependentFileLocation
(
nullptr
,
-
1
));
}
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA
...
...
@@ -298,7 +298,7 @@ void* ThreadFunc(void* data) {
internal
::
Mutex
*
mutex
=
static_cast
<
internal
::
Mutex
*>
(
data
);
mutex
->
Lock
();
mutex
->
Unlock
();
return
NULL
;
return
nullptr
;
}
TEST
(
GetThreadCountTest
,
ReturnsCorrectValue
)
{
...
...
@@ -965,7 +965,7 @@ TEST(ThreadLocalTest, DefaultConstructorInitializesToDefaultValues) {
EXPECT_EQ
(
0
,
t1
.
get
());
ThreadLocal
<
void
*>
t2
;
EXPECT_TRUE
(
t2
.
get
()
==
NULL
);
EXPECT_TRUE
(
t2
.
get
()
==
nullptr
);
}
TEST
(
ThreadLocalTest
,
SingleParamConstructorInitializesToParam
)
{
...
...
@@ -1015,7 +1015,7 @@ void AddTwo(int* param) { *param += 2; }
TEST
(
ThreadWithParamTest
,
ConstructorExecutesThreadFunc
)
{
int
i
=
40
;
ThreadWithParam
<
int
*>
thread
(
&
AddTwo
,
&
i
,
NULL
);
ThreadWithParam
<
int
*>
thread
(
&
AddTwo
,
&
i
,
nullptr
);
thread
.
Join
();
EXPECT_EQ
(
42
,
i
);
}
...
...
@@ -1055,7 +1055,7 @@ class AtomicCounterWithMutex {
// functionality as we are testing them here.
pthread_mutex_t
memory_barrier_mutex
;
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_init
(
&
memory_barrier_mutex
,
NULL
));
pthread_mutex_init
(
&
memory_barrier_mutex
,
nullptr
));
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_lock
(
&
memory_barrier_mutex
));
SleepMilliseconds
(
random_
.
Generate
(
30
));
...
...
@@ -1118,7 +1118,7 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) {
template
<
typename
T
>
void
RunFromThread
(
void
(
func
)(
T
),
T
param
)
{
ThreadWithParam
<
T
>
thread
(
func
,
param
,
NULL
);
ThreadWithParam
<
T
>
thread
(
func
,
param
,
nullptr
);
thread
.
Join
();
}
...
...
@@ -1250,8 +1250,8 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {
ASSERT_EQ
(
0U
,
DestructorCall
::
List
().
size
());
// This creates another DestructorTracker object in the new thread.
ThreadWithParam
<
ThreadParam
>
thread
(
&
CallThreadLocalGet
,
&
thread_local_tracker
,
NULL
);
ThreadWithParam
<
ThreadParam
>
thread
(
&
CallThreadLocalGet
,
&
thread_local_tracker
,
nullptr
);
thread
.
Join
();
// The thread has exited, and we should have a DestroyedTracker
...
...
googletest/test/googletest-printers-test.cc
View file @
4327d95b
...
...
@@ -405,7 +405,7 @@ TEST(PrintCStringTest, NonConst) {
// NULL C string.
TEST
(
PrintCStringTest
,
Null
)
{
const
char
*
p
=
NULL
;
const
char
*
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -440,7 +440,7 @@ TEST(PrintWideCStringTest, NonConst) {
// NULL wide C string.
TEST
(
PrintWideCStringTest
,
Null
)
{
const
wchar_t
*
p
=
NULL
;
const
wchar_t
*
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -460,7 +460,7 @@ TEST(PrintWideCStringTest, EscapesProperly) {
TEST
(
PrintCharPointerTest
,
SignedChar
)
{
signed
char
*
p
=
reinterpret_cast
<
signed
char
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
NULL
;
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -468,7 +468,7 @@ TEST(PrintCharPointerTest, SignedChar) {
TEST
(
PrintCharPointerTest
,
ConstSignedChar
)
{
signed
char
*
p
=
reinterpret_cast
<
signed
char
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
NULL
;
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -476,7 +476,7 @@ TEST(PrintCharPointerTest, ConstSignedChar) {
TEST
(
PrintCharPointerTest
,
UnsignedChar
)
{
unsigned
char
*
p
=
reinterpret_cast
<
unsigned
char
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
NULL
;
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -484,7 +484,7 @@ TEST(PrintCharPointerTest, UnsignedChar) {
TEST
(
PrintCharPointerTest
,
ConstUnsignedChar
)
{
const
unsigned
char
*
p
=
reinterpret_cast
<
const
unsigned
char
*>
(
0x1234
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
NULL
;
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -494,7 +494,7 @@ TEST(PrintCharPointerTest, ConstUnsignedChar) {
TEST
(
PrintPointerToBuiltInTypeTest
,
Bool
)
{
bool
*
p
=
reinterpret_cast
<
bool
*>
(
0xABCD
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
NULL
;
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -502,7 +502,7 @@ TEST(PrintPointerToBuiltInTypeTest, Bool) {
TEST
(
PrintPointerToBuiltInTypeTest
,
Void
)
{
void
*
p
=
reinterpret_cast
<
void
*>
(
0xABCD
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
NULL
;
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -510,7 +510,7 @@ TEST(PrintPointerToBuiltInTypeTest, Void) {
TEST
(
PrintPointerToBuiltInTypeTest
,
ConstVoid
)
{
const
void
*
p
=
reinterpret_cast
<
const
void
*>
(
0xABCD
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
NULL
;
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -518,7 +518,7 @@ TEST(PrintPointerToBuiltInTypeTest, ConstVoid) {
TEST
(
PrintPointerToPointerTest
,
IntPointerPointer
)
{
int
**
p
=
reinterpret_cast
<
int
**>
(
0xABCD
);
EXPECT_EQ
(
PrintPointer
(
p
),
Print
(
p
));
p
=
NULL
;
p
=
nullptr
;
EXPECT_EQ
(
"NULL"
,
Print
(
p
));
}
...
...
@@ -1398,7 +1398,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsStdWString) {
// char array vs pointer
TEST
(
FormatForComparisonFailureMessageTest
,
WorksForCharArrayVsPointer
)
{
char
str
[]
=
"hi
\"
world
\"
"
;
char
*
p
=
NULL
;
char
*
p
=
nullptr
;
EXPECT_EQ
(
PrintPointer
(
str
),
FormatForComparisonFailureMessage
(
str
,
p
).
c_str
());
}
...
...
@@ -1413,7 +1413,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsCharArray) {
// wchar_t array vs pointer
TEST
(
FormatForComparisonFailureMessageTest
,
WorksForWCharArrayVsPointer
)
{
wchar_t
str
[]
=
L"hi
\"
world
\"
"
;
wchar_t
*
p
=
NULL
;
wchar_t
*
p
=
nullptr
;
EXPECT_EQ
(
PrintPointer
(
str
),
FormatForComparisonFailureMessage
(
str
,
p
).
c_str
());
}
...
...
@@ -1614,7 +1614,7 @@ TEST(UniversalTersePrintTest, WorksForCString) {
UniversalTersePrint
(
s2
,
&
ss2
);
EXPECT_EQ
(
"
\"
abc
\"
"
,
ss2
.
str
());
const
char
*
s3
=
NULL
;
const
char
*
s3
=
nullptr
;
::
std
::
stringstream
ss3
;
UniversalTersePrint
(
s3
,
&
ss3
);
EXPECT_EQ
(
"NULL"
,
ss3
.
str
());
...
...
@@ -1644,7 +1644,7 @@ TEST(UniversalPrintTest, WorksForCString) {
UniversalPrint
(
s2
,
&
ss2
);
EXPECT_EQ
(
PrintPointer
(
s2
)
+
" pointing to
\"
abc
\"
"
,
std
::
string
(
ss2
.
str
()));
const
char
*
s3
=
NULL
;
const
char
*
s3
=
nullptr
;
::
std
::
stringstream
ss3
;
UniversalPrint
(
s3
,
&
ss3
);
EXPECT_EQ
(
"NULL"
,
ss3
.
str
());
...
...
googletest/test/googletest-throw-on-failure-test_.cc
View file @
4327d95b
...
...
@@ -45,7 +45,7 @@
// ones.
void
TerminateHandler
()
{
fprintf
(
stderr
,
"%s
\n
"
,
"Unhandled C++ exception terminating the program."
);
fflush
(
NULL
);
fflush
(
nullptr
);
exit
(
1
);
}
...
...
googletest/test/googletest-tuple-test.cc
View file @
4327d95b
...
...
@@ -158,7 +158,7 @@ TEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) {
b3
=
a3
;
EXPECT_EQ
(
0.0
,
get
<
0
>
(
b3
));
EXPECT_EQ
(
'\0'
,
get
<
1
>
(
b3
));
EXPECT_TRUE
(
get
<
2
>
(
b3
)
==
NULL
);
EXPECT_TRUE
(
get
<
2
>
(
b3
)
==
nullptr
);
tuple
<
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
>
a10
,
b10
;
b10
=
a10
;
...
...
googletest/test/gtest-typed-test_test.cc
View file @
4327d95b
...
...
@@ -55,7 +55,7 @@ class CommonTest : public Test {
static
void
TearDownTestCase
()
{
delete
shared_
;
shared_
=
NULL
;
shared_
=
nullptr
;
}
// This 'protected:' is optional. There's no harm in making all
...
...
@@ -85,7 +85,7 @@ class CommonTest : public Test {
};
template
<
typename
T
>
T
*
CommonTest
<
T
>::
shared_
=
NULL
;
T
*
CommonTest
<
T
>::
shared_
=
nullptr
;
// This #ifdef block tests typed tests.
#if GTEST_HAS_TYPED_TEST
...
...
@@ -121,7 +121,7 @@ TYPED_TEST(CommonTest, ValuesAreCorrect) {
TYPED_TEST
(
CommonTest
,
ValuesAreStillCorrect
)
{
// Static members of the fixture class template can also be visited
// via 'this'.
ASSERT_TRUE
(
this
->
shared_
!=
NULL
);
ASSERT_TRUE
(
this
->
shared_
!=
nullptr
);
EXPECT_EQ
(
5
,
*
this
->
shared_
);
// TypeParam can be used to refer to the type parameter.
...
...
@@ -292,7 +292,7 @@ TYPED_TEST_P(DerivedTest, ValuesAreCorrect) {
TYPED_TEST_P
(
DerivedTest
,
ValuesAreStillCorrect
)
{
// Static members of the fixture class template can also be visited
// via 'this'.
ASSERT_TRUE
(
this
->
shared_
!=
NULL
);
ASSERT_TRUE
(
this
->
shared_
!=
nullptr
);
EXPECT_EQ
(
5
,
*
this
->
shared_
);
EXPECT_EQ
(
2
,
this
->
value_
);
}
...
...
googletest/test/gtest-unittest-api_test.cc
View file @
4327d95b
...
...
@@ -76,7 +76,7 @@ class UnitTestHelper {
if
(
0
==
strcmp
(
test_case
->
name
(),
name
))
return
test_case
;
}
return
NULL
;
return
nullptr
;
}
// Returns the array of pointers to all tests in a particular test case
...
...
@@ -137,7 +137,7 @@ TEST(ApiTest, UnitTestImmutableAccessorsWork) {
}
AssertionResult
IsNull
(
const
char
*
str
)
{
if
(
str
!=
NULL
)
{
if
(
str
!=
nullptr
)
{
return
testing
::
AssertionFailure
()
<<
"argument is "
<<
str
;
}
return
AssertionSuccess
();
...
...
@@ -145,7 +145,7 @@ AssertionResult IsNull(const char* str) {
TEST
(
ApiTest
,
TestCaseImmutableAccessorsWork
)
{
const
TestCase
*
test_case
=
UnitTestHelper
::
FindTestCase
(
"ApiTest"
);
ASSERT_TRUE
(
test_case
!=
NULL
);
ASSERT_TRUE
(
test_case
!=
nullptr
);
EXPECT_STREQ
(
"ApiTest"
,
test_case
->
name
());
EXPECT_TRUE
(
IsNull
(
test_case
->
type_param
()));
...
...
@@ -181,11 +181,11 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) {
EXPECT_TRUE
(
tests
[
3
]
->
should_run
());
delete
[]
tests
;
tests
=
NULL
;
tests
=
nullptr
;
#if GTEST_HAS_TYPED_TEST
test_case
=
UnitTestHelper
::
FindTestCase
(
"TestCaseWithCommentTest/0"
);
ASSERT_TRUE
(
test_case
!=
NULL
);
ASSERT_TRUE
(
test_case
!=
nullptr
);
EXPECT_STREQ
(
"TestCaseWithCommentTest/0"
,
test_case
->
name
());
EXPECT_STREQ
(
GetTypeName
<
int
>
().
c_str
(),
test_case
->
type_param
());
...
...
@@ -208,7 +208,7 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) {
TEST
(
ApiTest
,
TestCaseDisabledAccessorsWork
)
{
const
TestCase
*
test_case
=
UnitTestHelper
::
FindTestCase
(
"DISABLED_Test"
);
ASSERT_TRUE
(
test_case
!=
NULL
);
ASSERT_TRUE
(
test_case
!=
nullptr
);
EXPECT_STREQ
(
"DISABLED_Test"
,
test_case
->
name
());
EXPECT_TRUE
(
IsNull
(
test_case
->
type_param
()));
...
...
googletest/test/gtest_assert_by_exception_test.cc
View file @
4327d95b
...
...
@@ -80,8 +80,7 @@ TEST(Test, Test) {
try
{
AssertFalse
();
}
catch
(
const
testing
::
AssertionException
&
e
)
{
if
(
strstr
(
e
.
what
(),
"Expected failure"
)
!=
NULL
)
throw
;
if
(
strstr
(
e
.
what
(),
"Expected failure"
)
!=
nullptr
)
throw
;
printf
(
"%s"
,
"A failed assertion did throw an exception of the right type, "
...
...
googletest/test/gtest_premature_exit_test.cc
View file @
4327d95b
...
...
@@ -56,7 +56,7 @@ class PrematureExitTest : public Test {
premature_exit_file_path_
=
GetEnv
(
"TEST_PREMATURE_EXIT_FILE"
);
// Normalize NULL to "" for ease of handling.
if
(
premature_exit_file_path_
==
NULL
)
{
if
(
premature_exit_file_path_
==
nullptr
)
{
premature_exit_file_path_
=
""
;
}
}
...
...
@@ -113,7 +113,7 @@ int main(int argc, char **argv) {
// Test that the premature-exit file is deleted upon return from
// RUN_ALL_TESTS().
const
char
*
const
filepath
=
GetEnv
(
"TEST_PREMATURE_EXIT_FILE"
);
if
(
filepath
!=
NULL
&&
*
filepath
!=
'\0'
)
{
if
(
filepath
!=
nullptr
&&
*
filepath
!=
'\0'
)
{
if
(
PrematureExitTest
::
FileExists
(
filepath
))
{
printf
(
"File %s shouldn't exist after the test program finishes, but does."
,
...
...
googletest/test/gtest_stress_test.cc
View file @
4327d95b
...
...
@@ -163,7 +163,7 @@ void FailingThread(bool is_fatal) {
}
void
GenerateFatalFailureInAnotherThread
(
bool
is_fatal
)
{
ThreadWithParam
<
bool
>
thread
(
&
FailingThread
,
is_fatal
,
NULL
);
ThreadWithParam
<
bool
>
thread
(
&
FailingThread
,
is_fatal
,
nullptr
);
thread
.
Join
();
}
...
...
googletest/test/gtest_throw_on_failure_ex_test.cc
View file @
4327d95b
...
...
@@ -63,8 +63,7 @@ void TestFailureThrowsRuntimeError() {
try
{
EXPECT_EQ
(
2
,
3
)
<<
"Expected failure"
;
}
catch
(
const
std
::
runtime_error
&
e
)
{
if
(
strstr
(
e
.
what
(),
"Expected failure"
)
!=
NULL
)
return
;
if
(
strstr
(
e
.
what
(),
"Expected failure"
)
!=
nullptr
)
return
;
printf
(
"%s"
,
"A failed assertion did throw an exception of the right type, "
...
...
googletest/test/gtest_unittest.cc
View file @
4327d95b
This diff is collapsed.
Click to expand it.
Prev
1
2
3
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