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
1814bed8
Unverified
Commit
1814bed8
authored
May 22, 2018
by
Gennadiy Civil
Committed by
GitHub
May 22, 2018
Browse files
Merge pull request #1601 from jdennett/StdLibVersioning
Std lib versioning
parents
08d5b1f3
49ecebd1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
2 deletions
+59
-2
googletest/include/gtest/internal/gtest-type-util.h
googletest/include/gtest/internal/gtest-type-util.h
+17
-1
googletest/include/gtest/internal/gtest-type-util.h.pump
googletest/include/gtest/internal/gtest-type-util.h.pump
+17
-1
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+25
-0
No files found.
googletest/include/gtest/internal/gtest-type-util.h
View file @
1814bed8
...
@@ -56,6 +56,22 @@
...
@@ -56,6 +56,22 @@
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
// Canonicalizes a given name with respect to the Standard C++ Library.
// This handles removing the inline namespace within `std` that is
// used by various standard libraries (e.g., `std::__1`). Names outside
// of namespace std are returned unmodified.
inline
std
::
string
CanonicalizeForStdLibVersioning
(
std
::
string
s
)
{
static
const
char
prefix
[]
=
"std::__"
;
if
(
s
.
compare
(
0
,
strlen
(
prefix
),
prefix
)
==
0
)
{
std
::
string
::
size_type
end
=
s
.
find
(
"::"
,
strlen
(
prefix
));
if
(
end
!=
s
.
npos
)
{
// Erase everything between the initial `std` and the second `::`.
s
.
erase
(
strlen
(
"std"
),
end
-
strlen
(
"std"
));
}
}
return
s
;
}
// GetTypeName<T>() returns a human-readable name of type T.
// GetTypeName<T>() returns a human-readable name of type T.
// NB: This function is also used in Google Mock, so don't move it inside of
// NB: This function is also used in Google Mock, so don't move it inside of
...
@@ -75,7 +91,7 @@ std::string GetTypeName() {
...
@@ -75,7 +91,7 @@ std::string GetTypeName() {
char
*
const
readable_name
=
__cxa_demangle
(
name
,
0
,
0
,
&
status
);
char
*
const
readable_name
=
__cxa_demangle
(
name
,
0
,
0
,
&
status
);
const
std
::
string
name_str
(
status
==
0
?
readable_name
:
name
);
const
std
::
string
name_str
(
status
==
0
?
readable_name
:
name
);
free
(
readable_name
);
free
(
readable_name
);
return
name_str
;
return
CanonicalizeForStdLibVersioning
(
name_str
)
;
# else
# else
return
name
;
return
name
;
# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
...
...
googletest/include/gtest/internal/gtest-type-util.h.pump
View file @
1814bed8
...
@@ -54,6 +54,22 @@ $var n = 50 $$ Maximum length of type lists we want to support.
...
@@ -54,6 +54,22 @@ $var n = 50 $$ Maximum length of type lists we want to support.
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
// Canonicalizes a given name with respect to the Standard C++ Library.
// This handles removing the inline namespace within `std` that is
// used by various standard libraries (e.g., `std::__1`). Names outside
// of namespace std are returned unmodified.
inline
std
::
string
CanonicalizeForStdLibVersioning
(
std
::
string
s
)
{
static
const
char
prefix
[]
=
"std::__"
;
if
(
s
.
compare
(
0
,
strlen
(
prefix
),
prefix
)
==
0
)
{
std
::
string
::
size_type
end
=
s
.
find
(
"::"
,
strlen
(
prefix
));
if
(
end
!=
s
.
npos
)
{
// Erase everything between the initial `std` and the second `::`.
s
.
erase
(
strlen
(
"std"
),
end
-
strlen
(
"std"
));
}
}
return
s
;
}
// GetTypeName<T>() returns a human-readable name of type T.
// GetTypeName<T>() returns a human-readable name of type T.
// NB: This function is also used in Google Mock, so don't move it inside of
// NB: This function is also used in Google Mock, so don't move it inside of
...
@@ -73,7 +89,7 @@ std::string GetTypeName() {
...
@@ -73,7 +89,7 @@ std::string GetTypeName() {
char
*
const
readable_name
=
__cxa_demangle
(
name
,
0
,
0
,
&
status
);
char
*
const
readable_name
=
__cxa_demangle
(
name
,
0
,
0
,
&
status
);
const
std
::
string
name_str
(
status
==
0
?
readable_name
:
name
);
const
std
::
string
name_str
(
status
==
0
?
readable_name
:
name
);
free
(
readable_name
);
free
(
readable_name
);
return
name_str
;
return
CanonicalizeForStdLibVersioning
(
name_str
)
;
# else
# else
return
name
;
return
name
;
# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC
...
...
googletest/test/gtest_unittest.cc
View file @
1814bed8
...
@@ -380,6 +380,31 @@ TEST(GetTestTypeIdTest, ReturnsTheSameValueInsideOrOutsideOfGoogleTest) {
...
@@ -380,6 +380,31 @@ TEST(GetTestTypeIdTest, ReturnsTheSameValueInsideOrOutsideOfGoogleTest) {
EXPECT_EQ
(
kTestTypeIdInGoogleTest
,
GetTestTypeId
());
EXPECT_EQ
(
kTestTypeIdInGoogleTest
,
GetTestTypeId
());
}
}
// Tests CanonicalizeForStdLibVersioning.
using
::
testing
::
internal
::
CanonicalizeForStdLibVersioning
;
TEST
(
CanonicalizeForStdLibVersioning
,
LeavesUnversionedNamesUnchanged
)
{
EXPECT_EQ
(
"std::bind"
,
CanonicalizeForStdLibVersioning
(
"std::bind"
));
EXPECT_EQ
(
"std::_"
,
CanonicalizeForStdLibVersioning
(
"std::_"
));
EXPECT_EQ
(
"std::__foo"
,
CanonicalizeForStdLibVersioning
(
"std::__foo"
));
EXPECT_EQ
(
"gtl::__1::x"
,
CanonicalizeForStdLibVersioning
(
"gtl::__1::x"
));
EXPECT_EQ
(
"__1::x"
,
CanonicalizeForStdLibVersioning
(
"__1::x"
));
EXPECT_EQ
(
"::__1::x"
,
CanonicalizeForStdLibVersioning
(
"::__1::x"
));
}
TEST
(
CanonicalizeForStdLibVersioning
,
ElidesDoubleUnderNames
)
{
EXPECT_EQ
(
"std::bind"
,
CanonicalizeForStdLibVersioning
(
"std::__1::bind"
));
EXPECT_EQ
(
"std::_"
,
CanonicalizeForStdLibVersioning
(
"std::__1::_"
));
EXPECT_EQ
(
"std::bind"
,
CanonicalizeForStdLibVersioning
(
"std::__g::bind"
));
EXPECT_EQ
(
"std::_"
,
CanonicalizeForStdLibVersioning
(
"std::__g::_"
));
EXPECT_EQ
(
"std::bind"
,
CanonicalizeForStdLibVersioning
(
"std::__google::bind"
));
EXPECT_EQ
(
"std::_"
,
CanonicalizeForStdLibVersioning
(
"std::__google::_"
));
}
// Tests FormatTimeInMillisAsSeconds().
// Tests FormatTimeInMillisAsSeconds().
TEST
(
FormatTimeInMillisAsSecondsTest
,
FormatsZero
)
{
TEST
(
FormatTimeInMillisAsSecondsTest
,
FormatsZero
)
{
...
...
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