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
55d166a2
Commit
55d166a2
authored
May 17, 2010
by
zhanyong.wan
Browse files
Adds GTEST_REMOVE_REFERENCE_AND_CONST_.
parent
65f2fd59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
include/gtest/internal/gtest-internal.h
include/gtest/internal/gtest-internal.h
+5
-1
test/gtest_unittest.cc
test/gtest_unittest.cc
+15
-0
No files found.
include/gtest/internal/gtest-internal.h
View file @
55d166a2
...
@@ -842,6 +842,10 @@ struct RemoveConst<T[N]> {
...
@@ -842,6 +842,10 @@ struct RemoveConst<T[N]> {
#define GTEST_REMOVE_CONST_(T) \
#define GTEST_REMOVE_CONST_(T) \
typename ::testing::internal::RemoveConst<T>::type
typename ::testing::internal::RemoveConst<T>::type
// Turns const U&, U&, const U, and U all into U.
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
// Adds reference to a type if it is not a reference type,
// Adds reference to a type if it is not a reference type,
// otherwise leaves it unchanged. This is the same as
// otherwise leaves it unchanged. This is the same as
// tr1::add_reference, which is not widely available yet.
// tr1::add_reference, which is not widely available yet.
...
@@ -1046,7 +1050,7 @@ class NativeArray {
...
@@ -1046,7 +1050,7 @@ class NativeArray {
// Ensures that the user doesn't instantiate NativeArray with a
// Ensures that the user doesn't instantiate NativeArray with a
// const or reference type.
// const or reference type.
static_cast
<
void
>
(
StaticAssertTypeEqHelper
<
Element
,
static_cast
<
void
>
(
StaticAssertTypeEqHelper
<
Element
,
GTEST_REMOVE_
CONST_
(
GTEST_REMOVE_REFERENCE
_
(
Element
)
)
>
());
GTEST_REMOVE_
REFERENCE_AND_CONST
_
(
Element
)
>
());
if
(
relation_to_source_
==
kCopy
)
if
(
relation_to_source_
==
kCopy
)
delete
[]
array_
;
delete
[]
array_
;
}
}
...
...
test/gtest_unittest.cc
View file @
55d166a2
...
@@ -6834,6 +6834,21 @@ TEST(RemoveConstTest, MacroVersion) {
...
@@ -6834,6 +6834,21 @@ TEST(RemoveConstTest, MacroVersion) {
TestGTestRemoveConst
<
char
,
const
char
>
();
TestGTestRemoveConst
<
char
,
const
char
>
();
}
}
// Tests GTEST_REMOVE_REFERENCE_AND_CONST_.
template
<
typename
T1
,
typename
T2
>
void
TestGTestRemoveReferenceAndConst
()
{
CompileAssertTypesEqual
<
T1
,
GTEST_REMOVE_REFERENCE_AND_CONST_
(
T2
)
>
();
}
TEST
(
RemoveReferenceToConstTest
,
Works
)
{
TestGTestRemoveReferenceAndConst
<
int
,
int
>
();
TestGTestRemoveReferenceAndConst
<
double
,
double
&>
();
TestGTestRemoveReferenceAndConst
<
char
,
const
char
>
();
TestGTestRemoveReferenceAndConst
<
char
,
const
char
&>
();
TestGTestRemoveReferenceAndConst
<
const
char
*
,
const
char
*>
();
}
// Tests that AddReference does not affect reference types.
// Tests that AddReference does not affect reference types.
TEST
(
AddReferenceTest
,
DoesNotAffectReferenceType
)
{
TEST
(
AddReferenceTest
,
DoesNotAffectReferenceType
)
{
CompileAssertTypesEqual
<
int
&
,
AddReference
<
int
&>::
type
>
();
CompileAssertTypesEqual
<
int
&
,
AddReference
<
int
&>::
type
>
();
...
...
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