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
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
94 additions
and
116 deletions
+94
-116
googletest/include/gtest/internal/gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+5
-18
googletest/include/gtest/internal/gtest-linked_ptr.h
googletest/include/gtest/internal/gtest-linked_ptr.h
+2
-2
googletest/include/gtest/internal/gtest-param-util.h
googletest/include/gtest/internal/gtest-param-util.h
+7
-11
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+13
-14
googletest/include/gtest/internal/gtest-type-util.h
googletest/include/gtest/internal/gtest-type-util.h
+1
-1
googletest/samples/sample10_unittest.cc
googletest/samples/sample10_unittest.cc
+1
-1
googletest/samples/sample2.cc
googletest/samples/sample2.cc
+1
-1
googletest/samples/sample2.h
googletest/samples/sample2.h
+4
-6
googletest/samples/sample2_unittest.cc
googletest/samples/sample2_unittest.cc
+3
-3
googletest/samples/sample3-inl.h
googletest/samples/sample3-inl.h
+9
-7
googletest/samples/sample3_unittest.cc
googletest/samples/sample3_unittest.cc
+5
-5
googletest/samples/sample5_unittest.cc
googletest/samples/sample5_unittest.cc
+5
-7
googletest/samples/sample7_unittest.cc
googletest/samples/sample7_unittest.cc
+1
-1
googletest/samples/sample8_unittest.cc
googletest/samples/sample8_unittest.cc
+6
-5
googletest/src/gtest-death-test.cc
googletest/src/gtest-death-test.cc
+9
-11
googletest/src/gtest-filepath.cc
googletest/src/gtest-filepath.cc
+2
-2
googletest/src/gtest-internal-inl.h
googletest/src/gtest-internal-inl.h
+3
-4
googletest/src/gtest-port.cc
googletest/src/gtest-port.cc
+14
-13
googletest/src/gtest-printers.cc
googletest/src/gtest-printers.cc
+2
-2
googletest/src/gtest-test-part.cc
googletest/src/gtest-test-part.cc
+1
-2
No files found.
googletest/include/gtest/internal/gtest-internal.h
View file @
4327d95b
...
...
@@ -587,8 +587,8 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
// returns NULL if no comma is found in 'str'.
inline
const
char
*
SkipComma
(
const
char
*
str
)
{
const
char
*
comma
=
strchr
(
str
,
','
);
if
(
comma
==
NULL
)
{
return
NULL
;
if
(
comma
==
nullptr
)
{
return
nullptr
;
}
while
(
IsSpace
(
*
(
++
comma
)))
{}
return
comma
;
...
...
@@ -598,7 +598,7 @@ inline const char* SkipComma(const char* str) {
// the entire string if it contains no comma.
inline
std
::
string
GetPrefixUntilComma
(
const
char
*
str
)
{
const
char
*
comma
=
strchr
(
str
,
','
);
return
comma
==
NULL
?
str
:
std
::
string
(
str
,
comma
);
return
comma
==
nullptr
?
str
:
std
::
string
(
str
,
comma
);
}
// Splits a given string on a given delimiter, populating a given
...
...
@@ -667,7 +667,7 @@ class TypeParameterizedTest {
.
c_str
(),
StripTrailingSpaces
(
GetPrefixUntilComma
(
test_names
)).
c_str
(),
GetTypeName
<
Type
>
().
c_str
(),
NULL
,
// No value parameter.
nullptr
,
// No value parameter.
code_location
,
GetTypeId
<
FixtureClass
>
(),
TestClass
::
SetUpTestCase
,
TestClass
::
TearDownTestCase
,
new
TestFactoryImpl
<
TestClass
>
);
...
...
@@ -942,7 +942,6 @@ struct IsAProtocolMessage
// IsContainerTest(typename C::const_iterator*) and
// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.
typedef
int
IsContainer
;
#if GTEST_LANG_CXX11
template
<
class
C
,
class
Iterator
=
decltype
(
::
std
::
declval
<
const
C
&
>().
begin
()),
class
=
decltype
(
::
std
::
declval
<
const
C
&>
().
end
()),
...
...
@@ -952,14 +951,6 @@ template <class C,
IsContainer
IsContainerTest
(
int
/* dummy */
)
{
return
0
;
}
#else
template
<
class
C
>
IsContainer
IsContainerTest
(
int
/* dummy */
,
typename
C
::
iterator
*
/* it */
=
NULL
,
typename
C
::
const_iterator
*
/* const_it */
=
NULL
)
{
return
0
;
}
#endif // GTEST_LANG_CXX11
typedef
char
IsNotContainer
;
template
<
class
C
>
...
...
@@ -980,7 +971,7 @@ struct IsHashTable {
static
char
test
(...);
public:
static
const
bool
value
=
sizeof
(
test
<
T
>
(
0
,
0
))
==
sizeof
(
int
);
static
const
bool
value
=
sizeof
(
test
<
T
>
(
nullptr
,
nullptr
))
==
sizeof
(
int
);
};
template
<
typename
T
>
...
...
@@ -1014,12 +1005,8 @@ struct IsRecursiveContainerImpl<C, true, false> : public false_type {};
template
<
typename
C
>
struct
IsRecursiveContainerImpl
<
C
,
true
,
true
>
{
#if GTEST_LANG_CXX11
typedef
typename
IteratorTraits
<
typename
C
::
const_iterator
>::
value_type
value_type
;
#else
typedef
typename
IteratorTraits
<
typename
C
::
iterator
>::
value_type
value_type
;
#endif
typedef
is_same
<
value_type
,
C
>
type
;
};
...
...
googletest/include/gtest/internal/gtest-linked_ptr.h
View file @
4327d95b
...
...
@@ -149,7 +149,7 @@ class linked_ptr {
// Take over ownership of a raw pointer. This should happen as soon as
// possible after the object is created.
explicit
linked_ptr
(
T
*
ptr
=
NULL
)
{
capture
(
ptr
);
}
explicit
linked_ptr
(
T
*
ptr
=
nullptr
)
{
capture
(
ptr
);
}
~
linked_ptr
()
{
depart
();
}
// Copy an existing linked_ptr<>, adding ourselves to the list of references.
...
...
@@ -175,7 +175,7 @@ class linked_ptr {
}
// Smart pointer members.
void
reset
(
T
*
ptr
=
NULL
)
{
void
reset
(
T
*
ptr
=
nullptr
)
{
depart
();
capture
(
ptr
);
}
...
...
googletest/include/gtest/internal/gtest-param-util.h
View file @
4327d95b
...
...
@@ -327,8 +327,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
// detect that fact. The client code, on the other hand, is
// responsible for not calling Current() on an out-of-range iterator.
virtual
const
T
*
Current
()
const
{
if
(
value_
.
get
()
==
NULL
)
value_
.
reset
(
new
T
(
*
iterator_
));
if
(
value_
.
get
()
==
nullptr
)
value_
.
reset
(
new
T
(
*
iterator_
));
return
value_
.
get
();
}
virtual
bool
Equals
(
const
ParamIteratorInterface
<
T
>&
other
)
const
{
...
...
@@ -579,13 +578,10 @@ class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {
test_name_stream
<<
test_info
->
test_base_name
<<
"/"
<<
param_name
;
MakeAndRegisterTestInfo
(
test_case_name
.
c_str
(),
test_name_stream
.
GetString
().
c_str
(),
NULL
,
// No type parameter.
PrintToString
(
*
param_it
).
c_str
(),
code_location_
,
GetTestCaseTypeId
(),
TestCase
::
SetUpTestCase
,
test_case_name
.
c_str
(),
test_name_stream
.
GetString
().
c_str
(),
nullptr
,
// No type parameter.
PrintToString
(
*
param_it
).
c_str
(),
code_location_
,
GetTestCaseTypeId
(),
TestCase
::
SetUpTestCase
,
TestCase
::
TearDownTestCase
,
test_info
->
test_meta_factory
->
CreateTestFactory
(
*
param_it
));
}
// for param_it
...
...
@@ -676,7 +672,7 @@ class ParameterizedTestCaseRegistry {
ParameterizedTestCaseInfo
<
TestCase
>*
GetTestCasePatternHolder
(
const
char
*
test_case_name
,
CodeLocation
code_location
)
{
ParameterizedTestCaseInfo
<
TestCase
>*
typed_test_info
=
NULL
;
ParameterizedTestCaseInfo
<
TestCase
>*
typed_test_info
=
nullptr
;
for
(
TestCaseInfoContainer
::
iterator
it
=
test_case_infos_
.
begin
();
it
!=
test_case_infos_
.
end
();
++
it
)
{
if
((
*
it
)
->
GetTestCaseName
()
==
test_case_name
)
{
...
...
@@ -696,7 +692,7 @@ class ParameterizedTestCaseRegistry {
break
;
}
}
if
(
typed_test_info
==
NULL
)
{
if
(
typed_test_info
==
nullptr
)
{
typed_test_info
=
new
ParameterizedTestCaseInfo
<
TestCase
>
(
test_case_name
,
code_location
);
test_case_infos_
.
push_back
(
typed_test_info
);
...
...
googletest/include/gtest/internal/gtest-port.h
View file @
4327d95b
...
...
@@ -1197,7 +1197,7 @@ class scoped_ptr {
public:
typedef
T
element_type
;
explicit
scoped_ptr
(
T
*
p
=
NULL
)
:
ptr_
(
p
)
{}
explicit
scoped_ptr
(
T
*
p
=
nullptr
)
:
ptr_
(
p
)
{}
~
scoped_ptr
()
{
reset
();
}
T
&
operator
*
()
const
{
return
*
ptr_
;
}
...
...
@@ -1206,11 +1206,11 @@ class scoped_ptr {
T
*
release
()
{
T
*
const
ptr
=
ptr_
;
ptr_
=
NULL
;
ptr_
=
nullptr
;
return
ptr
;
}
void
reset
(
T
*
p
=
NULL
)
{
void
reset
(
T
*
p
=
nullptr
)
{
if
(
p
!=
ptr_
)
{
if
(
IsTrue
(
sizeof
(
T
)
>
0
))
{
// Makes sure T is a complete type.
delete
ptr_
;
...
...
@@ -1360,7 +1360,7 @@ class GTEST_API_ GTestLog {
__FILE__, __LINE__).GetStream()
inline
void
LogToStderr
()
{}
inline
void
FlushInfoLog
()
{
fflush
(
NULL
);
}
inline
void
FlushInfoLog
()
{
fflush
(
nullptr
);
}
#endif // !defined(GTEST_LOG_)
...
...
@@ -1511,7 +1511,7 @@ inline To DownCast_(From* f) { // so we only accept pointers
#if GTEST_HAS_RTTI
// RTTI: debug mode only!
GTEST_CHECK_
(
f
==
NULL
||
dynamic_cast
<
To
>
(
f
)
!=
NULL
);
GTEST_CHECK_
(
f
==
nullptr
||
dynamic_cast
<
To
>
(
f
)
!=
NULL
);
#endif
return
static_cast
<
To
>
(
f
);
}
...
...
@@ -1583,7 +1583,7 @@ inline void SleepMilliseconds(int n) {
0
,
// 0 seconds.
n
*
1000L
*
1000L
,
// And n ms.
};
nanosleep
(
&
time
,
NULL
);
nanosleep
(
&
time
,
nullptr
);
}
# endif // GTEST_HAS_PTHREAD
...
...
@@ -1601,7 +1601,7 @@ inline void SleepMilliseconds(int n) {
class
Notification
{
public:
Notification
()
:
notified_
(
false
)
{
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_init
(
&
mutex_
,
NULL
));
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_init
(
&
mutex_
,
nullptr
));
}
~
Notification
()
{
pthread_mutex_destroy
(
&
mutex_
);
...
...
@@ -1710,7 +1710,7 @@ class ThreadWithParamBase {
// pass into pthread_create().
extern
"C"
inline
void
*
ThreadFuncWithCLinkage
(
void
*
thread
)
{
static_cast
<
ThreadWithParamBase
*>
(
thread
)
->
Run
();
return
NULL
;
return
nullptr
;
}
// Helper class for testing Google Test's multi-threading constructs.
...
...
@@ -1739,20 +1739,19 @@ class ThreadWithParam : public ThreadWithParamBase {
// The thread can be created only after all fields except thread_
// have been initialized.
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_create
(
&
thread_
,
0
,
&
ThreadFuncWithCLinkage
,
base
));
pthread_create
(
&
thread_
,
nullptr
,
&
ThreadFuncWithCLinkage
,
base
));
}
~
ThreadWithParam
()
{
Join
();
}
void
Join
()
{
if
(
!
finished_
)
{
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_join
(
thread_
,
0
));
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_join
(
thread_
,
nullptr
));
finished_
=
true
;
}
}
virtual
void
Run
()
{
if
(
thread_can_start_
!=
NULL
)
thread_can_start_
->
WaitForNotification
();
if
(
thread_can_start_
!=
nullptr
)
thread_can_start_
->
WaitForNotification
();
func_
(
param_
);
}
...
...
@@ -2115,7 +2114,7 @@ class MutexBase {
class
Mutex
:
public
MutexBase
{
public:
Mutex
()
{
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_init
(
&
mutex_
,
NULL
));
GTEST_CHECK_POSIX_SUCCESS_
(
pthread_mutex_init
(
&
mutex_
,
nullptr
));
has_owner_
=
false
;
}
~
Mutex
()
{
...
...
@@ -2213,7 +2212,7 @@ class GTEST_API_ ThreadLocal {
T
*
GetOrCreateValue
()
const
{
ThreadLocalValueHolderBase
*
const
holder
=
static_cast
<
ThreadLocalValueHolderBase
*>
(
pthread_getspecific
(
key_
));
if
(
holder
!=
NULL
)
{
if
(
holder
!=
nullptr
)
{
return
CheckedDowncastToActualType
<
ValueHolder
>
(
holder
)
->
pointer
();
}
...
...
googletest/include/gtest/internal/gtest-type-util.h
View file @
4327d95b
...
...
@@ -89,7 +89,7 @@ std::string GetTypeName() {
# if GTEST_HAS_CXXABI_H_
using
abi
::
__cxa_demangle
;
# endif // GTEST_HAS_CXXABI_H_
char
*
const
readable_name
=
__cxa_demangle
(
name
,
0
,
0
,
&
status
);
char
*
const
readable_name
=
__cxa_demangle
(
name
,
nullptr
,
nullptr
,
&
status
);
const
std
::
string
name_str
(
status
==
0
?
readable_name
:
name
);
free
(
readable_name
);
return
CanonicalizeForStdLibVersioning
(
name_str
);
...
...
googletest/samples/sample10_unittest.cc
View file @
4327d95b
...
...
@@ -100,7 +100,7 @@ TEST(ListenersTest, DoesNotLeak) {
// specified.
TEST
(
ListenersTest
,
LeaksWater
)
{
Water
*
water
=
new
Water
;
EXPECT_TRUE
(
water
!=
NULL
);
EXPECT_TRUE
(
water
!=
nullptr
);
}
}
// namespace
...
...
googletest/samples/sample2.cc
View file @
4327d95b
...
...
@@ -35,7 +35,7 @@
// Clones a 0-terminated C string, allocating memory using new.
const
char
*
MyString
::
CloneCString
(
const
char
*
a_c_string
)
{
if
(
a_c_string
==
NULL
)
return
NULL
;
if
(
a_c_string
==
nullptr
)
return
nullptr
;
const
size_t
len
=
strlen
(
a_c_string
);
char
*
const
clone
=
new
char
[
len
+
1
];
...
...
googletest/samples/sample2.h
View file @
4327d95b
...
...
@@ -50,15 +50,15 @@ class MyString {
// C'tors
// The default c'tor constructs a NULL string.
MyString
()
:
c_string_
(
NULL
)
{}
MyString
()
:
c_string_
(
nullptr
)
{}
// Constructs a MyString by cloning a 0-terminated C string.
explicit
MyString
(
const
char
*
a_c_string
)
:
c_string_
(
NULL
)
{
explicit
MyString
(
const
char
*
a_c_string
)
:
c_string_
(
nullptr
)
{
Set
(
a_c_string
);
}
// Copy c'tor
MyString
(
const
MyString
&
string
)
:
c_string_
(
NULL
)
{
MyString
(
const
MyString
&
string
)
:
c_string_
(
nullptr
)
{
Set
(
string
.
c_string_
);
}
...
...
@@ -71,9 +71,7 @@ class MyString {
// Gets the 0-terminated C string this MyString object represents.
const
char
*
c_string
()
const
{
return
c_string_
;
}
size_t
Length
()
const
{
return
c_string_
==
NULL
?
0
:
strlen
(
c_string_
);
}
size_t
Length
()
const
{
return
c_string_
==
nullptr
?
0
:
strlen
(
c_string_
);
}
// Sets the 0-terminated C string this MyString object represents.
void
Set
(
const
char
*
c_string
);
...
...
googletest/samples/sample2_unittest.cc
View file @
4327d95b
...
...
@@ -66,7 +66,7 @@ TEST(MyString, DefaultConstructor) {
// we have to live with this fact.
//
// </TechnicalDetails>
EXPECT_STREQ
(
NULL
,
s
.
c_string
());
EXPECT_STREQ
(
nullptr
,
s
.
c_string
());
EXPECT_EQ
(
0u
,
s
.
Length
());
}
...
...
@@ -101,7 +101,7 @@ TEST(MyString, Set) {
EXPECT_EQ
(
0
,
strcmp
(
s
.
c_string
(),
kHelloString
));
// Can we set the MyString to NULL?
s
.
Set
(
NULL
);
EXPECT_STREQ
(
NULL
,
s
.
c_string
());
s
.
Set
(
nullptr
);
EXPECT_STREQ
(
nullptr
,
s
.
c_string
());
}
}
// namespace
googletest/samples/sample3-inl.h
View file @
4327d95b
...
...
@@ -58,7 +58,8 @@ class QueueNode {
private:
// Creates a node with a given element value. The next pointer is
// set to NULL.
explicit
QueueNode
(
const
E
&
an_element
)
:
element_
(
an_element
),
next_
(
NULL
)
{}
explicit
QueueNode
(
const
E
&
an_element
)
:
element_
(
an_element
),
next_
(
nullptr
)
{}
// We disable the default assignment operator and copy c'tor.
const
QueueNode
&
operator
=
(
const
QueueNode
&
);
...
...
@@ -72,7 +73,7 @@ template <typename E> // E is the element type.
class
Queue
{
public:
// Creates an empty queue.
Queue
()
:
head_
(
NULL
),
last_
(
NULL
),
size_
(
0
)
{}
Queue
()
:
head_
(
nullptr
),
last_
(
nullptr
),
size_
(
0
)
{}
// D'tor. Clears the queue.
~
Queue
()
{
Clear
();
}
...
...
@@ -86,12 +87,12 @@ class Queue {
for
(;
;)
{
delete
node
;
node
=
next
;
if
(
node
==
NULL
)
break
;
if
(
node
==
nullptr
)
break
;
next
=
node
->
next
();
}
// 2. Resets the member variables.
head_
=
last_
=
NULL
;
head_
=
last_
=
nullptr
;
size_
=
0
;
}
}
...
...
@@ -128,14 +129,14 @@ class Queue {
// the queue is empty.
E
*
Dequeue
()
{
if
(
size_
==
0
)
{
return
NULL
;
return
nullptr
;
}
const
QueueNode
<
E
>*
const
old_head
=
head_
;
head_
=
head_
->
next_
;
size_
--
;
if
(
size_
==
0
)
{
last_
=
NULL
;
last_
=
nullptr
;
}
E
*
element
=
new
E
(
old_head
->
element
());
...
...
@@ -150,7 +151,8 @@ class Queue {
template
<
typename
F
>
Queue
*
Map
(
F
function
)
const
{
Queue
*
new_queue
=
new
Queue
();
for
(
const
QueueNode
<
E
>*
node
=
head_
;
node
!=
NULL
;
node
=
node
->
next_
)
{
for
(
const
QueueNode
<
E
>*
node
=
head_
;
node
!=
nullptr
;
node
=
node
->
next_
)
{
new_queue
->
Enqueue
(
function
(
node
->
element
()));
}
...
...
googletest/samples/sample3_unittest.cc
View file @
4327d95b
...
...
@@ -99,8 +99,8 @@ class QueueTestSmpl3 : public testing::Test {
ASSERT_EQ
(
q
->
Size
(),
new_q
->
Size
());
// Verifies the relationship between the elements of the two queues.
for
(
const
QueueNode
<
int
>
*
n1
=
q
->
Head
(),
*
n2
=
new_q
->
Head
();
n1
!=
NULL
;
n1
=
n1
->
next
(),
n2
=
n2
->
next
()
)
{
for
(
const
QueueNode
<
int
>
*
n1
=
q
->
Head
(),
*
n2
=
new_q
->
Head
();
n1
!=
nullptr
;
n1
=
n1
->
next
(),
n2
=
n2
->
next
())
{
EXPECT_EQ
(
2
*
n1
->
element
(),
n2
->
element
());
}
...
...
@@ -125,16 +125,16 @@ TEST_F(QueueTestSmpl3, DefaultConstructor) {
// Tests Dequeue().
TEST_F
(
QueueTestSmpl3
,
Dequeue
)
{
int
*
n
=
q0_
.
Dequeue
();
EXPECT_TRUE
(
n
==
NULL
);
EXPECT_TRUE
(
n
==
nullptr
);
n
=
q1_
.
Dequeue
();
ASSERT_TRUE
(
n
!=
NULL
);
ASSERT_TRUE
(
n
!=
nullptr
);
EXPECT_EQ
(
1
,
*
n
);
EXPECT_EQ
(
0u
,
q1_
.
Size
());
delete
n
;
n
=
q2_
.
Dequeue
();
ASSERT_TRUE
(
n
!=
NULL
);
ASSERT_TRUE
(
n
!=
nullptr
);
EXPECT_EQ
(
2
,
*
n
);
EXPECT_EQ
(
1u
,
q2_
.
Size
());
delete
n
;
...
...
googletest/samples/sample5_unittest.cc
View file @
4327d95b
...
...
@@ -63,15 +63,13 @@ class QuickTest : public testing::Test {
protected:
// Remember that SetUp() is run immediately before a test starts.
// This is a good place to record the start time.
virtual
void
SetUp
()
{
start_time_
=
time
(
NULL
);
}
virtual
void
SetUp
()
{
start_time_
=
time
(
nullptr
);
}
// TearDown() is invoked immediately after a test finishes. Here we
// check if the test was too slow.
virtual
void
TearDown
()
{
// Gets the time when the test finishes
const
time_t
end_time
=
time
(
NULL
);
const
time_t
end_time
=
time
(
nullptr
);
// Asserts that the test took no more than ~5 seconds. Did you
// know that you can use assertions in SetUp() and TearDown() as
...
...
@@ -176,16 +174,16 @@ TEST_F(QueueTest, DefaultConstructor) {
// Tests Dequeue().
TEST_F
(
QueueTest
,
Dequeue
)
{
int
*
n
=
q0_
.
Dequeue
();
EXPECT_TRUE
(
n
==
NULL
);
EXPECT_TRUE
(
n
==
nullptr
);
n
=
q1_
.
Dequeue
();
EXPECT_TRUE
(
n
!=
NULL
);
EXPECT_TRUE
(
n
!=
nullptr
);
EXPECT_EQ
(
1
,
*
n
);
EXPECT_EQ
(
0u
,
q1_
.
Size
());
delete
n
;
n
=
q2_
.
Dequeue
();
EXPECT_TRUE
(
n
!=
NULL
);
EXPECT_TRUE
(
n
!=
nullptr
);
EXPECT_EQ
(
2
,
*
n
);
EXPECT_EQ
(
1u
,
q2_
.
Size
());
delete
n
;
...
...
googletest/samples/sample7_unittest.cc
View file @
4327d95b
...
...
@@ -69,7 +69,7 @@ class PrimeTableTestSmpl7 : public TestWithParam<CreatePrimeTableFunc*> {
virtual
void
SetUp
()
{
table_
=
(
*
GetParam
())();
}
virtual
void
TearDown
()
{
delete
table_
;
table_
=
NULL
;
table_
=
nullptr
;
}
protected:
...
...
googletest/samples/sample8_unittest.cc
View file @
4327d95b
...
...
@@ -50,8 +50,9 @@ class HybridPrimeTable : public PrimeTable {
public:
HybridPrimeTable
(
bool
force_on_the_fly
,
int
max_precalculated
)
:
on_the_fly_impl_
(
new
OnTheFlyPrimeTable
),
precalc_impl_
(
force_on_the_fly
?
NULL
:
new
PreCalculatedPrimeTable
(
max_precalculated
)),
precalc_impl_
(
force_on_the_fly
?
nullptr
:
new
PreCalculatedPrimeTable
(
max_precalculated
)),
max_precalculated_
(
max_precalculated
)
{}
virtual
~
HybridPrimeTable
()
{
delete
on_the_fly_impl_
;
...
...
@@ -59,7 +60,7 @@ class HybridPrimeTable : public PrimeTable {
}
virtual
bool
IsPrime
(
int
n
)
const
{
if
(
precalc_impl_
!=
NULL
&&
n
<
max_precalculated_
)
if
(
precalc_impl_
!=
nullptr
&&
n
<
max_precalculated_
)
return
precalc_impl_
->
IsPrime
(
n
);
else
return
on_the_fly_impl_
->
IsPrime
(
n
);
...
...
@@ -67,7 +68,7 @@ class HybridPrimeTable : public PrimeTable {
virtual
int
GetNextPrime
(
int
p
)
const
{
int
next_prime
=
-
1
;
if
(
precalc_impl_
!=
NULL
&&
p
<
max_precalculated_
)
if
(
precalc_impl_
!=
nullptr
&&
p
<
max_precalculated_
)
next_prime
=
precalc_impl_
->
GetNextPrime
(
p
);
return
next_prime
!=
-
1
?
next_prime
:
on_the_fly_impl_
->
GetNextPrime
(
p
);
...
...
@@ -106,7 +107,7 @@ class PrimeTableTest : public TestWithParam< ::testing::tuple<bool, int> > {
}
virtual
void
TearDown
()
{
delete
table_
;
table_
=
NULL
;
table_
=
nullptr
;
}
HybridPrimeTable
*
table_
;
};
...
...
googletest/src/gtest-death-test.cc
View file @
4327d95b
...
...
@@ -281,7 +281,7 @@ static void DeathTestAbort(const std::string& message) {
// the heap for any additional non-minuscule memory requirements.
const
InternalRunDeathTestFlag
*
const
flag
=
GetUnitTestImpl
()
->
internal_run_death_test_flag
();
if
(
flag
!=
NULL
)
{
if
(
flag
!=
nullptr
)
{
FILE
*
parent
=
posix
::
FDOpen
(
flag
->
write_fd
(),
"w"
);
fputc
(
kDeathTestInternalError
,
parent
);
fprintf
(
parent
,
"%s"
,
message
.
c_str
());
...
...
@@ -361,7 +361,7 @@ static void FailFromInternalError(int fd) {
// for the current test.
DeathTest
::
DeathTest
()
{
TestInfo
*
const
info
=
GetUnitTestImpl
()
->
current_test_info
();
if
(
info
==
NULL
)
{
if
(
info
==
nullptr
)
{
DeathTestAbort
(
"Cannot run a death test outside of a TEST or "
"TEST_F construct"
);
}
...
...
@@ -1115,9 +1115,7 @@ class ExecDeathTest : public ForkingDeathTest {
// Utility class for accumulating command-line arguments.
class
Arguments
{
public:
Arguments
()
{
args_
.
push_back
(
NULL
);
}
Arguments
()
{
args_
.
push_back
(
nullptr
);
}
~
Arguments
()
{
for
(
std
::
vector
<
char
*>::
iterator
i
=
args_
.
begin
();
i
!=
args_
.
end
();
...
...
@@ -1288,7 +1286,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
static
const
bool
stack_grows_down
=
StackGrowsDown
();
const
size_t
stack_size
=
getpagesize
();
// MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.
void
*
const
stack
=
mmap
(
NULL
,
stack_size
,
PROT_READ
|
PROT_WRITE
,
void
*
const
stack
=
mmap
(
nullptr
,
stack_size
,
PROT_READ
|
PROT_WRITE
,
MAP_ANON
|
MAP_PRIVATE
,
-
1
,
0
);
GTEST_DEATH_TEST_CHECK_
(
stack
!=
MAP_FAILED
);
...
...
@@ -1320,7 +1318,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
# endif // GTEST_OS_QNX
# if GTEST_OS_LINUX
GTEST_DEATH_TEST_CHECK_SYSCALL_
(
sigaction
(
SIGPROF
,
&
saved_sigprof_action
,
NULL
));
sigaction
(
SIGPROF
,
&
saved_sigprof_action
,
nullptr
));
# endif // GTEST_OS_LINUX
GTEST_DEATH_TEST_CHECK_
(
child_pid
!=
-
1
);
...
...
@@ -1338,7 +1336,7 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {
const
TestInfo
*
const
info
=
impl
->
current_test_info
();
const
int
death_test_index
=
info
->
result
()
->
death_test_count
();
if
(
flag
!=
NULL
)
{
if
(
flag
!=
nullptr
)
{
set_write_fd
(
flag
->
write_fd
());
return
EXECUTE_TEST
;
}
...
...
@@ -1393,7 +1391,7 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
const
int
death_test_index
=
impl
->
current_test_info
()
->
increment_death_test_count
();
if
(
flag
!=
NULL
)
{
if
(
flag
!=
nullptr
)
{
if
(
death_test_index
>
flag
->
index
())
{
DeathTest
::
set_last_death_test_message
(
"Death test count ("
+
StreamableToString
(
death_test_index
)
...
...
@@ -1404,7 +1402,7 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
if
(
!
(
flag
->
file
()
==
file
&&
flag
->
line
()
==
line
&&
flag
->
index
()
==
death_test_index
))
{
*
test
=
NULL
;
*
test
=
nullptr
;
return
true
;
}
}
...
...
@@ -1515,7 +1513,7 @@ static int GetStatusFileDescriptor(unsigned int parent_process_id,
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
// the flag is specified; otherwise returns NULL.
InternalRunDeathTestFlag
*
ParseInternalRunDeathTestFlag
()
{
if
(
GTEST_FLAG
(
internal_run_death_test
)
==
""
)
return
NULL
;
if
(
GTEST_FLAG
(
internal_run_death_test
)
==
""
)
return
nullptr
;
// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
// can use it here.
...
...
googletest/src/gtest-filepath.cc
View file @
4327d95b
...
...
@@ -111,7 +111,7 @@ FilePath FilePath::GetCurrentDir() {
// however, so fallback only when failure is detected.
return
FilePath
(
result
==
NULL
?
kCurrentDirectoryString
:
cwd
);
# endif // GTEST_OS_NACL
return
FilePath
(
result
==
NULL
?
""
:
cwd
);
return
FilePath
(
result
==
nullptr
?
""
:
cwd
);
#endif // GTEST_OS_WINDOWS_MOBILE
}
...
...
@@ -352,7 +352,7 @@ FilePath FilePath::RemoveTrailingPathSeparator() const {
// redundancies that might be in a pathname involving "." or "..".
// FIXME: handle Windows network shares (e.g. \\server\share).
void
FilePath
::
Normalize
()
{
if
(
pathname_
.
c_str
()
==
NULL
)
{
if
(
pathname_
.
c_str
()
==
nullptr
)
{
pathname_
=
""
;
return
;
}
...
...
googletest/src/gtest-internal-inl.h
View file @
4327d95b
...
...
@@ -585,14 +585,14 @@ class GTEST_API_ UnitTestImpl {
// total_test_case_count() - 1. If i is not in that range, returns NULL.
const
TestCase
*
GetTestCase
(
int
i
)
const
{
const
int
index
=
GetElementOr
(
test_case_indices_
,
i
,
-
1
);
return
index
<
0
?
NULL
:
test_cases_
[
i
];
return
index
<
0
?
nullptr
:
test_cases_
[
i
];
}
// Gets the i-th test case among all the test cases. i can range from 0 to
// total_test_case_count() - 1. If i is not in that range, returns NULL.
TestCase
*
GetMutableTestCase
(
int
i
)
{
const
int
index
=
GetElementOr
(
test_case_indices_
,
i
,
-
1
);
return
index
<
0
?
NULL
:
test_cases_
[
index
];
return
index
<
0
?
nullptr
:
test_cases_
[
index
];
}
// Provides access to the event listener list.
...
...
@@ -1158,8 +1158,7 @@ class StreamingListener : public EmptyTestEventListener {
void
OnTestPartResult
(
const
TestPartResult
&
test_part_result
)
{
const
char
*
file_name
=
test_part_result
.
file_name
();
if
(
file_name
==
NULL
)
file_name
=
""
;
if
(
file_name
==
nullptr
)
file_name
=
""
;
SendLn
(
"event=TestPartResult&file="
+
UrlEncode
(
file_name
)
+
"&line="
+
StreamableToString
(
test_part_result
.
line_number
())
+
"&message="
+
UrlEncode
(
test_part_result
.
message
()));
...
...
googletest/src/gtest-port.cc
View file @
4327d95b
...
...
@@ -935,7 +935,7 @@ const char kUnknownFile[] = "unknown file";
// Formats a source file path and a line number as they would appear
// in an error message from the compiler used to compile this code.
GTEST_API_
::
std
::
string
FormatFileLocation
(
const
char
*
file
,
int
line
)
{
const
std
::
string
file_name
(
file
==
NULL
?
kUnknownFile
:
file
);
const
std
::
string
file_name
(
file
==
nullptr
?
kUnknownFile
:
file
);
if
(
line
<
0
)
{
return
file_name
+
":"
;
...
...
@@ -954,7 +954,7 @@ GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {
// to the file location it produces, unlike FormatFileLocation().
GTEST_API_
::
std
::
string
FormatCompilerIndependentFileLocation
(
const
char
*
file
,
int
line
)
{
const
std
::
string
file_name
(
file
==
NULL
?
kUnknownFile
:
file
);
const
std
::
string
file_name
(
file
==
nullptr
?
kUnknownFile
:
file
);
if
(
line
<
0
)
return
file_name
;
...
...
@@ -1034,7 +1034,7 @@ class CapturedStream {
const
int
captured_fd
=
mkstemp
(
name_template
);
filename_
=
name_template
;
# endif // GTEST_OS_WINDOWS
fflush
(
NULL
);
fflush
(
nullptr
);
dup2
(
captured_fd
,
fd_
);
close
(
captured_fd
);
}
...
...
@@ -1046,7 +1046,7 @@ class CapturedStream {
std
::
string
GetCapturedString
()
{
if
(
uncaptured_fd_
!=
-
1
)
{
// Restores the original stream.
fflush
(
NULL
);
fflush
(
nullptr
);
dup2
(
uncaptured_fd_
,
fd_
);
close
(
uncaptured_fd_
);
uncaptured_fd_
=
-
1
;
...
...
@@ -1069,13 +1069,13 @@ class CapturedStream {
GTEST_DISABLE_MSC_DEPRECATED_POP_
()
static
CapturedStream
*
g_captured_stderr
=
NULL
;
static
CapturedStream
*
g_captured_stdout
=
NULL
;
static
CapturedStream
*
g_captured_stderr
=
nullptr
;
static
CapturedStream
*
g_captured_stdout
=
nullptr
;
// Starts capturing an output stream (stdout/stderr).
static
void
CaptureStream
(
int
fd
,
const
char
*
stream_name
,
CapturedStream
**
stream
)
{
if
(
*
stream
!=
NULL
)
{
if
(
*
stream
!=
nullptr
)
{
GTEST_LOG_
(
FATAL
)
<<
"Only one "
<<
stream_name
<<
" capturer can exist at a time."
;
}
...
...
@@ -1087,7 +1087,7 @@ static std::string GetCapturedStream(CapturedStream** captured_stream) {
const
std
::
string
content
=
(
*
captured_stream
)
->
GetCapturedString
();
delete
*
captured_stream
;
*
captured_stream
=
NULL
;
*
captured_stream
=
nullptr
;
return
content
;
}
...
...
@@ -1146,10 +1146,11 @@ std::string ReadEntireFile(FILE* file) {
}
#if GTEST_HAS_DEATH_TEST
static
const
std
::
vector
<
std
::
string
>*
g_injected_test_argvs
=
NULL
;
// Owned.
static
const
std
::
vector
<
std
::
string
>*
g_injected_test_argvs
=
nullptr
;
// Owned.
std
::
vector
<
std
::
string
>
GetInjectableArgvs
()
{
if
(
g_injected_test_argvs
!=
NULL
)
{
if
(
g_injected_test_argvs
!=
nullptr
)
{
return
*
g_injected_test_argvs
;
}
return
GetArgvs
();
...
...
@@ -1174,7 +1175,7 @@ void SetInjectableArgvs(const std::vector< ::string>& new_argvs) {
void
ClearInjectableArgvs
()
{
delete
g_injected_test_argvs
;
g_injected_test_argvs
=
NULL
;
g_injected_test_argvs
=
nullptr
;
}
#endif // GTEST_HAS_DEATH_TEST
...
...
@@ -1207,7 +1208,7 @@ static std::string FlagToEnvVar(const char* flag) {
// unchanged and returns false.
bool
ParseInt32
(
const
Message
&
src_text
,
const
char
*
str
,
Int32
*
value
)
{
// Parses the environment variable as a decimal integer.
char
*
end
=
NULL
;
char
*
end
=
nullptr
;
const
long
long_value
=
strtol
(
str
,
&
end
,
10
);
// NOLINT
// Has strtol() consumed all characters in the string?
...
...
@@ -1296,7 +1297,7 @@ Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
std
::
string
OutputFlagAlsoCheckEnvVar
(){
std
::
string
default_value_for_output_flag
=
""
;
const
char
*
xml_output_file_env
=
posix
::
GetEnv
(
"XML_OUTPUT_FILE"
);
if
(
NULL
!=
xml_output_file_env
)
{
if
(
nullptr
!=
xml_output_file_env
)
{
default_value_for_output_flag
=
std
::
string
(
"xml:"
)
+
xml_output_file_env
;
}
return
default_value_for_output_flag
;
...
...
googletest/src/gtest-printers.cc
View file @
4327d95b
...
...
@@ -327,7 +327,7 @@ void UniversalPrintArray(const wchar_t* begin, size_t len, ostream* os) {
// Prints the given C string to the ostream.
void
PrintTo
(
const
char
*
s
,
ostream
*
os
)
{
if
(
s
==
NULL
)
{
if
(
s
==
nullptr
)
{
*
os
<<
"NULL"
;
}
else
{
*
os
<<
ImplicitCast_
<
const
void
*>
(
s
)
<<
" pointing to "
;
...
...
@@ -344,7 +344,7 @@ void PrintTo(const char* s, ostream* os) {
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
// Prints the given wide C string to the ostream.
void
PrintTo
(
const
wchar_t
*
s
,
ostream
*
os
)
{
if
(
s
==
NULL
)
{
if
(
s
==
nullptr
)
{
*
os
<<
"NULL"
;
}
else
{
*
os
<<
ImplicitCast_
<
const
void
*>
(
s
)
<<
" pointing to "
;
...
...
googletest/src/gtest-test-part.cc
View file @
4327d95b
...
...
@@ -41,8 +41,7 @@ using internal::GetUnitTestImpl;
// in it.
std
::
string
TestPartResult
::
ExtractSummary
(
const
char
*
message
)
{
const
char
*
const
stack_trace
=
strstr
(
message
,
internal
::
kStackTraceMarker
);
return
stack_trace
==
NULL
?
message
:
std
::
string
(
message
,
stack_trace
);
return
stack_trace
==
nullptr
?
message
:
std
::
string
(
message
,
stack_trace
);
}
// Prints a TestPartResult object.
...
...
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