Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
1b2e5099
Commit
1b2e5099
authored
Sep 26, 2011
by
vladlosev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes C++0x compatibility problems.
parent
2ca4d215
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
29 deletions
+31
-29
gtest-param-util-generated.h
include/gtest/internal/gtest-param-util-generated.h
+0
-0
gtest-param-util-generated.h.pump
include/gtest/internal/gtest-param-util-generated.h.pump
+1
-1
gtest-port_test.cc
test/gtest-port_test.cc
+30
-28
No files found.
include/gtest/internal/gtest-param-util-generated.h
View file @
1b2e5099
This diff is collapsed.
Click to expand it.
include/gtest/internal/gtest-param-util-generated.h.pump
View file @
1b2e5099
...
@@ -98,7 +98,7 @@ class ValueArray$i {
...
@@ -98,7 +98,7 @@ class ValueArray$i {
template
<
typename
T
>
template
<
typename
T
>
operator
ParamGenerator
<
T
>
()
const
{
operator
ParamGenerator
<
T
>
()
const
{
const
T
array
[]
=
{
$
for
j
,
[[
v
$
(
j
)
_
]]};
const
T
array
[]
=
{
$
for
j
,
[[
static_cast
<
T
>
(
v
$
(
j
)
_
)
]]};
return
ValuesIn
(
array
);
return
ValuesIn
(
array
);
}
}
...
...
test/gtest-port_test.cc
View file @
1b2e5099
...
@@ -968,23 +968,23 @@ TEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) {
...
@@ -968,23 +968,23 @@ TEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) {
}
}
TEST
(
ThreadLocalTest
,
GetAndPointerReturnSameValue
)
{
TEST
(
ThreadLocalTest
,
GetAndPointerReturnSameValue
)
{
ThreadLocal
<
String
>
thread_local
;
ThreadLocal
<
String
>
thread_local
_string
;
EXPECT_EQ
(
thread_local
.
pointer
(),
&
(
thread_local
.
get
()));
EXPECT_EQ
(
thread_local
_string
.
pointer
(),
&
(
thread_local_string
.
get
()));
// Verifies the condition still holds after calling set.
// Verifies the condition still holds after calling set.
thread_local
.
set
(
"foo"
);
thread_local
_string
.
set
(
"foo"
);
EXPECT_EQ
(
thread_local
.
pointer
(),
&
(
thread_local
.
get
()));
EXPECT_EQ
(
thread_local
_string
.
pointer
(),
&
(
thread_local_string
.
get
()));
}
}
TEST
(
ThreadLocalTest
,
PointerAndConstPointerReturnSameValue
)
{
TEST
(
ThreadLocalTest
,
PointerAndConstPointerReturnSameValue
)
{
ThreadLocal
<
String
>
thread_local
;
ThreadLocal
<
String
>
thread_local
_string
;
const
ThreadLocal
<
String
>&
const_thread_local
=
thread_local
;
const
ThreadLocal
<
String
>&
const_thread_local
_string
=
thread_local_string
;
EXPECT_EQ
(
thread_local
.
pointer
(),
const_thread_local
.
pointer
());
EXPECT_EQ
(
thread_local
_string
.
pointer
(),
const_thread_local_string
.
pointer
());
thread_local
.
set
(
"foo"
);
thread_local
_string
.
set
(
"foo"
);
EXPECT_EQ
(
thread_local
.
pointer
(),
const_thread_local
.
pointer
());
EXPECT_EQ
(
thread_local
_string
.
pointer
(),
const_thread_local_string
.
pointer
());
}
}
#if GTEST_IS_THREADSAFE
#if GTEST_IS_THREADSAFE
...
@@ -1094,14 +1094,15 @@ void RetrieveThreadLocalValue(pair<ThreadLocal<String>*, String*> param) {
...
@@ -1094,14 +1094,15 @@ void RetrieveThreadLocalValue(pair<ThreadLocal<String>*, String*> param) {
}
}
TEST
(
ThreadLocalTest
,
ParameterizedConstructorSetsDefault
)
{
TEST
(
ThreadLocalTest
,
ParameterizedConstructorSetsDefault
)
{
ThreadLocal
<
String
>
thread_local
(
"foo"
);
ThreadLocal
<
String
>
thread_local
_string
(
"foo"
);
EXPECT_STREQ
(
"foo"
,
thread_local
.
get
().
c_str
());
EXPECT_STREQ
(
"foo"
,
thread_local
_string
.
get
().
c_str
());
thread_local
.
set
(
"bar"
);
thread_local
_string
.
set
(
"bar"
);
EXPECT_STREQ
(
"bar"
,
thread_local
.
get
().
c_str
());
EXPECT_STREQ
(
"bar"
,
thread_local
_string
.
get
().
c_str
());
String
result
;
String
result
;
RunFromThread
(
&
RetrieveThreadLocalValue
,
make_pair
(
&
thread_local
,
&
result
));
RunFromThread
(
&
RetrieveThreadLocalValue
,
make_pair
(
&
thread_local_string
,
&
result
));
EXPECT_STREQ
(
"foo"
,
result
.
c_str
());
EXPECT_STREQ
(
"foo"
,
result
.
c_str
());
}
}
...
@@ -1130,8 +1131,8 @@ class DestructorTracker {
...
@@ -1130,8 +1131,8 @@ class DestructorTracker {
typedef
ThreadLocal
<
DestructorTracker
>*
ThreadParam
;
typedef
ThreadLocal
<
DestructorTracker
>*
ThreadParam
;
void
CallThreadLocalGet
(
ThreadParam
thread_local
)
{
void
CallThreadLocalGet
(
ThreadParam
thread_local
_param
)
{
thread_local
->
get
();
thread_local
_param
->
get
();
}
}
// Tests that when a ThreadLocal object dies in a thread, it destroys
// Tests that when a ThreadLocal object dies in a thread, it destroys
...
@@ -1141,19 +1142,19 @@ TEST(ThreadLocalTest, DestroysManagedObjectForOwnThreadWhenDying) {
...
@@ -1141,19 +1142,19 @@ TEST(ThreadLocalTest, DestroysManagedObjectForOwnThreadWhenDying) {
{
{
// The next line default constructs a DestructorTracker object as
// The next line default constructs a DestructorTracker object as
// the default value of objects managed by thread_local.
// the default value of objects managed by thread_local
_tracker
.
ThreadLocal
<
DestructorTracker
>
thread_local
;
ThreadLocal
<
DestructorTracker
>
thread_local
_tracker
;
ASSERT_EQ
(
1U
,
g_destroyed
.
size
());
ASSERT_EQ
(
1U
,
g_destroyed
.
size
());
ASSERT_FALSE
(
g_destroyed
[
0
]);
ASSERT_FALSE
(
g_destroyed
[
0
]);
// This creates another DestructorTracker object for the main thread.
// This creates another DestructorTracker object for the main thread.
thread_local
.
get
();
thread_local
_tracker
.
get
();
ASSERT_EQ
(
2U
,
g_destroyed
.
size
());
ASSERT_EQ
(
2U
,
g_destroyed
.
size
());
ASSERT_FALSE
(
g_destroyed
[
0
]);
ASSERT_FALSE
(
g_destroyed
[
0
]);
ASSERT_FALSE
(
g_destroyed
[
1
]);
ASSERT_FALSE
(
g_destroyed
[
1
]);
}
}
// Now thread_local has died. It should have destroyed both the
// Now thread_local
_tracker
has died. It should have destroyed both the
// default value shared by all threads and the value for the main
// default value shared by all threads and the value for the main
// thread.
// thread.
ASSERT_EQ
(
2U
,
g_destroyed
.
size
());
ASSERT_EQ
(
2U
,
g_destroyed
.
size
());
...
@@ -1170,14 +1171,14 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {
...
@@ -1170,14 +1171,14 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {
{
{
// The next line default constructs a DestructorTracker object as
// The next line default constructs a DestructorTracker object as
// the default value of objects managed by thread_local.
// the default value of objects managed by thread_local
_tracker
.
ThreadLocal
<
DestructorTracker
>
thread_local
;
ThreadLocal
<
DestructorTracker
>
thread_local
_tracker
;
ASSERT_EQ
(
1U
,
g_destroyed
.
size
());
ASSERT_EQ
(
1U
,
g_destroyed
.
size
());
ASSERT_FALSE
(
g_destroyed
[
0
]);
ASSERT_FALSE
(
g_destroyed
[
0
]);
// This creates another DestructorTracker object in the new thread.
// This creates another DestructorTracker object in the new thread.
ThreadWithParam
<
ThreadParam
>
thread
(
ThreadWithParam
<
ThreadParam
>
thread
(
&
CallThreadLocalGet
,
&
thread_local
,
NULL
);
&
CallThreadLocalGet
,
&
thread_local
_tracker
,
NULL
);
thread
.
Join
();
thread
.
Join
();
// Now the new thread has exited. The per-thread object for it
// Now the new thread has exited. The per-thread object for it
...
@@ -1187,7 +1188,7 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {
...
@@ -1187,7 +1188,7 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {
ASSERT_TRUE
(
g_destroyed
[
1
]);
ASSERT_TRUE
(
g_destroyed
[
1
]);
}
}
// Now thread_local has died. The default value should have been
// Now thread_local
_tracker
has died. The default value should have been
// destroyed too.
// destroyed too.
ASSERT_EQ
(
2U
,
g_destroyed
.
size
());
ASSERT_EQ
(
2U
,
g_destroyed
.
size
());
EXPECT_TRUE
(
g_destroyed
[
0
]);
EXPECT_TRUE
(
g_destroyed
[
0
]);
...
@@ -1197,12 +1198,13 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {
...
@@ -1197,12 +1198,13 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {
}
}
TEST
(
ThreadLocalTest
,
ThreadLocalMutationsAffectOnlyCurrentThread
)
{
TEST
(
ThreadLocalTest
,
ThreadLocalMutationsAffectOnlyCurrentThread
)
{
ThreadLocal
<
String
>
thread_local
;
ThreadLocal
<
String
>
thread_local
_string
;
thread_local
.
set
(
"Foo"
);
thread_local
_string
.
set
(
"Foo"
);
EXPECT_STREQ
(
"Foo"
,
thread_local
.
get
().
c_str
());
EXPECT_STREQ
(
"Foo"
,
thread_local
_string
.
get
().
c_str
());
String
result
;
String
result
;
RunFromThread
(
&
RetrieveThreadLocalValue
,
make_pair
(
&
thread_local
,
&
result
));
RunFromThread
(
&
RetrieveThreadLocalValue
,
make_pair
(
&
thread_local_string
,
&
result
));
EXPECT_TRUE
(
result
.
c_str
()
==
NULL
);
EXPECT_TRUE
(
result
.
c_str
()
==
NULL
);
}
}
...
...
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