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
3b49be07
Commit
3b49be07
authored
Sep 30, 2021
by
Abseil Team
Committed by
CJ Johnson
Sep 30, 2021
Browse files
Googletest export
googletest: Add printer for {std,absl}::nullopt. PiperOrigin-RevId: 399928554
parent
ab36804e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
0 deletions
+11
-0
googletest/include/gtest/gtest-printers.h
googletest/include/gtest/gtest-printers.h
+8
-0
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+2
-0
googletest/test/googletest-printers-test.cc
googletest/test/googletest-printers-test.cc
+1
-0
No files found.
googletest/include/gtest/gtest-printers.h
View file @
3b49be07
...
...
@@ -742,6 +742,14 @@ class UniversalPrinter<Optional<T>> {
}
};
template
<>
class
UniversalPrinter
<
decltype
(
Nullopt
())
>
{
public:
static
void
Print
(
decltype
(
Nullopt
()),
::
std
::
ostream
*
os
)
{
*
os
<<
"(nullopt)"
;
}
};
#endif // GTEST_INTERNAL_HAS_OPTIONAL
#if GTEST_INTERNAL_HAS_VARIANT
...
...
googletest/include/gtest/internal/gtest-port.h
View file @
3b49be07
...
...
@@ -2325,6 +2325,7 @@ namespace testing {
namespace
internal
{
template
<
typename
T
>
using
Optional
=
::
absl
::
optional
<
T
>
;
inline
::
absl
::
nullopt_t
Nullopt
()
{
return
::
absl
::
nullopt
;
}
}
// namespace internal
}
// namespace testing
#else
...
...
@@ -2338,6 +2339,7 @@ namespace testing {
namespace
internal
{
template
<
typename
T
>
using
Optional
=
::
std
::
optional
<
T
>
;
inline
::
std
::
nullopt_t
Nullopt
()
{
return
::
std
::
nullopt
;
}
}
// namespace internal
}
// namespace testing
// The case where absl is configured NOT to alias std::optional is not
...
...
googletest/test/googletest-printers-test.cc
View file @
3b49be07
...
...
@@ -1873,6 +1873,7 @@ TEST_F(PrintAnyTest, NonEmpty) {
#if GTEST_INTERNAL_HAS_OPTIONAL
TEST
(
PrintOptionalTest
,
Basic
)
{
EXPECT_EQ
(
"(nullopt)"
,
PrintToString
(
internal
::
Nullopt
()));
internal
::
Optional
<
int
>
value
;
EXPECT_EQ
(
"(nullopt)"
,
PrintToString
(
value
));
value
=
{
7
};
...
...
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