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
6f5fd0d7
Commit
6f5fd0d7
authored
Feb 11, 2020
by
Abseil Team
Committed by
Mark Barolak
Feb 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Googletest export
Add gmock Matcher<std::string_view> specialization. PiperOrigin-RevId: 294443240
parent
d0930731
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
102 additions
and
70 deletions
+102
-70
gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+20
-20
gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+0
-0
gtest-matchers.h
googletest/include/gtest/gtest-matchers.h
+19
-19
gtest-printers.h
googletest/include/gtest/gtest-printers.h
+13
-12
gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+31
-0
gtest-matchers.cc
googletest/src/gtest-matchers.cc
+14
-14
googletest-printers-test.cc
googletest/test/googletest-printers-test.cc
+5
-5
No files found.
googlemock/include/gmock/gmock-matchers.h
View file @
6f5fd0d7
...
@@ -906,15 +906,15 @@ class StrEqualityMatcher {
...
@@ -906,15 +906,15 @@ class StrEqualityMatcher {
bool
case_sensitive
)
bool
case_sensitive
)
:
string_
(
str
),
expect_eq_
(
expect_eq
),
case_sensitive_
(
case_sensitive
)
{}
:
string_
(
str
),
expect_eq_
(
expect_eq
),
case_sensitive_
(
case_sensitive
)
{}
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
bool
MatchAndExplain
(
const
absl
::
string_v
iew
&
s
,
bool
MatchAndExplain
(
const
internal
::
StringV
iew
&
s
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
// This should fail to compile if
absl::string_v
iew is used with wide
// This should fail to compile if
StringV
iew is used with wide
// strings.
// strings.
const
StringType
&
str
=
std
::
string
(
s
);
const
StringType
&
str
=
std
::
string
(
s
);
return
MatchAndExplain
(
str
,
listener
);
return
MatchAndExplain
(
str
,
listener
);
}
}
#endif // GTEST_
HAS_ABSL
#endif // GTEST_
INTERNAL_HAS_STRING_VIEW
// Accepts pointer types, particularly:
// Accepts pointer types, particularly:
// const char*
// const char*
...
@@ -932,7 +932,7 @@ class StrEqualityMatcher {
...
@@ -932,7 +932,7 @@ class StrEqualityMatcher {
// Matches anything that can convert to StringType.
// Matches anything that can convert to StringType.
//
//
// This is a template, not just a plain function with const StringType&,
// This is a template, not just a plain function with const StringType&,
// because
absl::string_v
iew has some interfering non-explicit constructors.
// because
StringV
iew has some interfering non-explicit constructors.
template
<
typename
MatcheeStringType
>
template
<
typename
MatcheeStringType
>
bool
MatchAndExplain
(
const
MatcheeStringType
&
s
,
bool
MatchAndExplain
(
const
MatcheeStringType
&
s
,
MatchResultListener
*
/* listener */
)
const
{
MatchResultListener
*
/* listener */
)
const
{
...
@@ -976,15 +976,15 @@ class HasSubstrMatcher {
...
@@ -976,15 +976,15 @@ class HasSubstrMatcher {
explicit
HasSubstrMatcher
(
const
StringType
&
substring
)
explicit
HasSubstrMatcher
(
const
StringType
&
substring
)
:
substring_
(
substring
)
{}
:
substring_
(
substring
)
{}
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
bool
MatchAndExplain
(
const
absl
::
string_v
iew
&
s
,
bool
MatchAndExplain
(
const
internal
::
StringV
iew
&
s
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
// This should fail to compile if
absl::string_v
iew is used with wide
// This should fail to compile if
StringV
iew is used with wide
// strings.
// strings.
const
StringType
&
str
=
std
::
string
(
s
);
const
StringType
&
str
=
std
::
string
(
s
);
return
MatchAndExplain
(
str
,
listener
);
return
MatchAndExplain
(
str
,
listener
);
}
}
#endif // GTEST_
HAS_ABSL
#endif // GTEST_
INTERNAL_HAS_STRING_VIEW
// Accepts pointer types, particularly:
// Accepts pointer types, particularly:
// const char*
// const char*
...
@@ -999,7 +999,7 @@ class HasSubstrMatcher {
...
@@ -999,7 +999,7 @@ class HasSubstrMatcher {
// Matches anything that can convert to StringType.
// Matches anything that can convert to StringType.
//
//
// This is a template, not just a plain function with const StringType&,
// This is a template, not just a plain function with const StringType&,
// because
absl::string_v
iew has some interfering non-explicit constructors.
// because
StringV
iew has some interfering non-explicit constructors.
template
<
typename
MatcheeStringType
>
template
<
typename
MatcheeStringType
>
bool
MatchAndExplain
(
const
MatcheeStringType
&
s
,
bool
MatchAndExplain
(
const
MatcheeStringType
&
s
,
MatchResultListener
*
/* listener */
)
const
{
MatchResultListener
*
/* listener */
)
const
{
...
@@ -1032,15 +1032,15 @@ class StartsWithMatcher {
...
@@ -1032,15 +1032,15 @@ class StartsWithMatcher {
explicit
StartsWithMatcher
(
const
StringType
&
prefix
)
:
prefix_
(
prefix
)
{
explicit
StartsWithMatcher
(
const
StringType
&
prefix
)
:
prefix_
(
prefix
)
{
}
}
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
bool
MatchAndExplain
(
const
absl
::
string_v
iew
&
s
,
bool
MatchAndExplain
(
const
internal
::
StringV
iew
&
s
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
// This should fail to compile if
absl::string_v
iew is used with wide
// This should fail to compile if
StringV
iew is used with wide
// strings.
// strings.
const
StringType
&
str
=
std
::
string
(
s
);
const
StringType
&
str
=
std
::
string
(
s
);
return
MatchAndExplain
(
str
,
listener
);
return
MatchAndExplain
(
str
,
listener
);
}
}
#endif // GTEST_
HAS_ABSL
#endif // GTEST_
INTERNAL_HAS_STRING_VIEW
// Accepts pointer types, particularly:
// Accepts pointer types, particularly:
// const char*
// const char*
...
@@ -1055,7 +1055,7 @@ class StartsWithMatcher {
...
@@ -1055,7 +1055,7 @@ class StartsWithMatcher {
// Matches anything that can convert to StringType.
// Matches anything that can convert to StringType.
//
//
// This is a template, not just a plain function with const StringType&,
// This is a template, not just a plain function with const StringType&,
// because
absl::string_v
iew has some interfering non-explicit constructors.
// because
StringV
iew has some interfering non-explicit constructors.
template
<
typename
MatcheeStringType
>
template
<
typename
MatcheeStringType
>
bool
MatchAndExplain
(
const
MatcheeStringType
&
s
,
bool
MatchAndExplain
(
const
MatcheeStringType
&
s
,
MatchResultListener
*
/* listener */
)
const
{
MatchResultListener
*
/* listener */
)
const
{
...
@@ -1088,15 +1088,15 @@ class EndsWithMatcher {
...
@@ -1088,15 +1088,15 @@ class EndsWithMatcher {
public
:
public
:
explicit
EndsWithMatcher
(
const
StringType
&
suffix
)
:
suffix_
(
suffix
)
{}
explicit
EndsWithMatcher
(
const
StringType
&
suffix
)
:
suffix_
(
suffix
)
{}
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
bool
MatchAndExplain
(
const
absl
::
string_v
iew
&
s
,
bool
MatchAndExplain
(
const
internal
::
StringV
iew
&
s
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
// This should fail to compile if
absl::string_v
iew is used with wide
// This should fail to compile if
StringV
iew is used with wide
// strings.
// strings.
const
StringType
&
str
=
std
::
string
(
s
);
const
StringType
&
str
=
std
::
string
(
s
);
return
MatchAndExplain
(
str
,
listener
);
return
MatchAndExplain
(
str
,
listener
);
}
}
#endif // GTEST_
HAS_ABSL
#endif // GTEST_
INTERNAL_HAS_STRING_VIEW
// Accepts pointer types, particularly:
// Accepts pointer types, particularly:
// const char*
// const char*
...
@@ -1111,7 +1111,7 @@ class EndsWithMatcher {
...
@@ -1111,7 +1111,7 @@ class EndsWithMatcher {
// Matches anything that can convert to StringType.
// Matches anything that can convert to StringType.
//
//
// This is a template, not just a plain function with const StringType&,
// This is a template, not just a plain function with const StringType&,
// because
absl::string_v
iew has some interfering non-explicit constructors.
// because
StringV
iew has some interfering non-explicit constructors.
template
<
typename
MatcheeStringType
>
template
<
typename
MatcheeStringType
>
bool
MatchAndExplain
(
const
MatcheeStringType
&
s
,
bool
MatchAndExplain
(
const
MatcheeStringType
&
s
,
MatchResultListener
*
/* listener */
)
const
{
MatchResultListener
*
/* listener */
)
const
{
...
...
googlemock/test/gmock-matchers_test.cc
View file @
6f5fd0d7
This diff is collapsed.
Click to expand it.
googletest/include/gtest/gtest-matchers.h
View file @
6f5fd0d7
...
@@ -384,18 +384,18 @@ class GTEST_API_ Matcher<std::string>
...
@@ -384,18 +384,18 @@ class GTEST_API_ Matcher<std::string>
Matcher
(
const
char
*
s
);
// NOLINT
Matcher
(
const
char
*
s
);
// NOLINT
};
};
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
// The following two specializations allow the user to write str
// The following two specializations allow the user to write str
// instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view
// instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view
// matcher is expected.
// matcher is expected.
template
<>
template
<>
class
GTEST_API_
Matcher
<
const
absl
::
string_v
iew
&>
class
GTEST_API_
Matcher
<
const
internal
::
StringV
iew
&>
:
public
internal
::
MatcherBase
<
const
absl
::
string_v
iew
&>
{
:
public
internal
::
MatcherBase
<
const
internal
::
StringV
iew
&>
{
public
:
public
:
Matcher
()
{}
Matcher
()
{}
explicit
Matcher
(
const
MatcherInterface
<
const
absl
::
string_v
iew
&>*
impl
)
explicit
Matcher
(
const
MatcherInterface
<
const
internal
::
StringV
iew
&>*
impl
)
:
internal
::
MatcherBase
<
const
absl
::
string_v
iew
&>
(
impl
)
{}
:
internal
::
MatcherBase
<
const
internal
::
StringV
iew
&>
(
impl
)
{}
// Allows the user to write str instead of Eq(str) sometimes, where
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a std::string object.
// str is a std::string object.
...
@@ -404,20 +404,20 @@ class GTEST_API_ Matcher<const absl::string_view&>
...
@@ -404,20 +404,20 @@ class GTEST_API_ Matcher<const absl::string_view&>
// Allows the user to write "foo" instead of Eq("foo") sometimes.
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher
(
const
char
*
s
);
// NOLINT
Matcher
(
const
char
*
s
);
// NOLINT
// Allows the user to pass absl::string_views directly.
// Allows the user to pass absl::string_views
or std::string_views
directly.
Matcher
(
absl
::
string_v
iew
s
);
// NOLINT
Matcher
(
internal
::
StringV
iew
s
);
// NOLINT
};
};
template
<>
template
<>
class
GTEST_API_
Matcher
<
absl
::
string_v
iew
>
class
GTEST_API_
Matcher
<
internal
::
StringV
iew
>
:
public
internal
::
MatcherBase
<
absl
::
string_v
iew
>
{
:
public
internal
::
MatcherBase
<
internal
::
StringV
iew
>
{
public
:
public
:
Matcher
()
{}
Matcher
()
{}
explicit
Matcher
(
const
MatcherInterface
<
const
absl
::
string_v
iew
&>*
impl
)
explicit
Matcher
(
const
MatcherInterface
<
const
internal
::
StringV
iew
&>*
impl
)
:
internal
::
MatcherBase
<
absl
::
string_v
iew
>
(
impl
)
{}
:
internal
::
MatcherBase
<
internal
::
StringV
iew
>
(
impl
)
{}
explicit
Matcher
(
const
MatcherInterface
<
absl
::
string_v
iew
>*
impl
)
explicit
Matcher
(
const
MatcherInterface
<
internal
::
StringV
iew
>*
impl
)
:
internal
::
MatcherBase
<
absl
::
string_v
iew
>
(
impl
)
{}
:
internal
::
MatcherBase
<
internal
::
StringV
iew
>
(
impl
)
{}
// Allows the user to write str instead of Eq(str) sometimes, where
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a std::string object.
// str is a std::string object.
...
@@ -426,10 +426,10 @@ class GTEST_API_ Matcher<absl::string_view>
...
@@ -426,10 +426,10 @@ class GTEST_API_ Matcher<absl::string_view>
// Allows the user to write "foo" instead of Eq("foo") sometimes.
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher
(
const
char
*
s
);
// NOLINT
Matcher
(
const
char
*
s
);
// NOLINT
// Allows the user to pass absl::string_views directly.
// Allows the user to pass absl::string_views
or std::string_views
directly.
Matcher
(
absl
::
string_v
iew
s
);
// NOLINT
Matcher
(
internal
::
StringV
iew
s
);
// NOLINT
};
};
#endif // GTEST_
HAS_ABSL
#endif // GTEST_
INTERNAL_HAS_STRING_VIEW
// Prints a matcher in a human-readable format.
// Prints a matcher in a human-readable format.
template
<
typename
T
>
template
<
typename
T
>
...
@@ -620,12 +620,12 @@ class MatchesRegexMatcher {
...
@@ -620,12 +620,12 @@ class MatchesRegexMatcher {
MatchesRegexMatcher
(
const
RE
*
regex
,
bool
full_match
)
MatchesRegexMatcher
(
const
RE
*
regex
,
bool
full_match
)
:
regex_
(
regex
),
full_match_
(
full_match
)
{}
:
regex_
(
regex
),
full_match_
(
full_match
)
{}
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
bool
MatchAndExplain
(
const
absl
::
string_v
iew
&
s
,
bool
MatchAndExplain
(
const
internal
::
StringV
iew
&
s
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
return
MatchAndExplain
(
std
::
string
(
s
),
listener
);
return
MatchAndExplain
(
std
::
string
(
s
),
listener
);
}
}
#endif // GTEST_
HAS_ABSL
#endif // GTEST_
INTERNAL_HAS_STRING_VIEW
// Accepts pointer types, particularly:
// Accepts pointer types, particularly:
// const char*
// const char*
...
...
googletest/include/gtest/gtest-printers.h
View file @
6f5fd0d7
...
@@ -135,9 +135,9 @@ enum TypeKind {
...
@@ -135,9 +135,9 @@ enum TypeKind {
kProtobuf
,
// a protobuf type
kProtobuf
,
// a protobuf type
kConvertibleToInteger
,
// a type implicitly convertible to BiggestInt
kConvertibleToInteger
,
// a type implicitly convertible to BiggestInt
// (e.g. a named or unnamed enum type)
// (e.g. a named or unnamed enum type)
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
kConvertibleToStringView
,
// a type implicitly convertible to
kConvertibleToStringView
,
// a type implicitly convertible to
// absl::string_view
// absl::string_view
or std::string_view
#endif
#endif
kOtherType
// anything else
kOtherType
// anything else
};
};
...
@@ -191,12 +191,13 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
...
@@ -191,12 +191,13 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
}
}
};
};
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
template
<
typename
T
>
template
<
typename
T
>
class
TypeWithoutFormatter
<
T
,
kConvertibleToStringView
>
{
class
TypeWithoutFormatter
<
T
,
kConvertibleToStringView
>
{
public
:
public
:
// Since T has neither operator<< nor PrintTo() but can be implicitly
// Since T has neither operator<< nor PrintTo() but can be implicitly
// converted to absl::string_view, we print it as a absl::string_view.
// converted to absl::string_view, we print it as a absl::string_view
// (or std::string_view).
//
//
// Note: the implementation is further below, as it depends on
// Note: the implementation is further below, as it depends on
// internal::PrintTo symbol which is defined later in the file.
// internal::PrintTo symbol which is defined later in the file.
...
@@ -237,9 +238,9 @@ template <typename Char, typename CharTraits, typename T>
...
@@ -237,9 +238,9 @@ template <typename Char, typename CharTraits, typename T>
const
T
&
,
internal
::
BiggestInt
>::
value
const
T
&
,
internal
::
BiggestInt
>::
value
?
kConvertibleToInteger
?
kConvertibleToInteger
:
:
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
std
::
is_convertible
<
std
::
is_convertible
<
const
T
&
,
absl
::
string_v
iew
>::
value
const
T
&
,
internal
::
StringV
iew
>::
value
?
kConvertibleToStringView
?
kConvertibleToStringView
:
:
#endif
#endif
...
@@ -601,12 +602,12 @@ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
...
@@ -601,12 +602,12 @@ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
}
}
#endif // GTEST_HAS_STD_WSTRING
#endif // GTEST_HAS_STD_WSTRING
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
// Overload for
absl::string_v
iew.
// Overload for
internal::StringV
iew.
inline
void
PrintTo
(
absl
::
string_v
iew
sp
,
::
std
::
ostream
*
os
)
{
inline
void
PrintTo
(
internal
::
StringV
iew
sp
,
::
std
::
ostream
*
os
)
{
PrintTo
(
::
std
::
string
(
sp
),
os
);
PrintTo
(
::
std
::
string
(
sp
),
os
);
}
}
#endif // GTEST_
HAS_ABSL
#endif // GTEST_
INTERNAL_HAS_STRING_VIEW
inline
void
PrintTo
(
std
::
nullptr_t
,
::
std
::
ostream
*
os
)
{
*
os
<<
"(nullptr)"
;
}
inline
void
PrintTo
(
std
::
nullptr_t
,
::
std
::
ostream
*
os
)
{
*
os
<<
"(nullptr)"
;
}
...
@@ -899,12 +900,12 @@ Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
...
@@ -899,12 +900,12 @@ Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
}
// namespace internal
}
// namespace internal
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
namespace
internal2
{
namespace
internal2
{
template
<
typename
T
>
template
<
typename
T
>
void
TypeWithoutFormatter
<
T
,
kConvertibleToStringView
>::
PrintValue
(
void
TypeWithoutFormatter
<
T
,
kConvertibleToStringView
>::
PrintValue
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
const
T
&
value
,
::
std
::
ostream
*
os
)
{
internal
::
PrintTo
(
absl
::
string_v
iew
(
value
),
os
);
internal
::
PrintTo
(
internal
::
StringV
iew
(
value
),
os
);
}
}
}
// namespace internal2
}
// namespace internal2
#endif
#endif
...
...
googletest/include/gtest/internal/gtest-port.h
View file @
6f5fd0d7
...
@@ -199,6 +199,9 @@
...
@@ -199,6 +199,9 @@
// suppressed (constant conditional).
// suppressed (constant conditional).
// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127
// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127
// is suppressed.
// is suppressed.
// GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher<std::string_view> or
// Matcher<absl::string_view>
// specializations.
//
//
// Synchronization:
// Synchronization:
// Mutex, MutexLock, ThreadLocal, GetThreadCount()
// Mutex, MutexLock, ThreadLocal, GetThreadCount()
...
@@ -2220,4 +2223,32 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val);
...
@@ -2220,4 +2223,32 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val);
#endif // !defined(GTEST_INTERNAL_DEPRECATED)
#endif // !defined(GTEST_INTERNAL_DEPRECATED)
#if GTEST_HAS_ABSL
// Always use absl::string_view for Matcher<> specializations if googletest
// is built with absl support.
# define GTEST_INTERNAL_HAS_STRING_VIEW 1
#include "absl/strings/string_view.h"
namespace
testing
{
namespace
internal
{
using
StringView
=
::
absl
::
string_view
;
}
// namespace internal
}
// namespace testing
#else
# ifdef __has_include
# if __has_include(<string_view>) && __cplusplus >= 201703L
// Otherwise for C++17 and higher use std::string_view for Matcher<>
// specializations.
# define GTEST_INTERNAL_HAS_STRING_VIEW 1
#include <string_view>
namespace
testing
{
namespace
internal
{
using
StringView
=
::
std
::
string_view
;
}
// namespace internal
}
// namespace testing
// The case where absl is configured NOT to alias std::string_view is not
// supported.
# endif // __has_include(<string_view>) && __cplusplus >= 201703L
# endif // __has_include
#endif // GTEST_HAS_ABSL
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
googletest/src/gtest-matchers.cc
View file @
6f5fd0d7
...
@@ -58,40 +58,40 @@ Matcher<std::string>::Matcher(const std::string& s) { *this = Eq(s); }
...
@@ -58,40 +58,40 @@ Matcher<std::string>::Matcher(const std::string& s) { *this = Eq(s); }
// s.
// s.
Matcher
<
std
::
string
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
Matcher
<
std
::
string
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
// Constructs a matcher that matches a const
absl::string_v
iew& whose value is
// Constructs a matcher that matches a const
StringV
iew& whose value is
// equal to s.
// equal to s.
Matcher
<
const
absl
::
string_v
iew
&>::
Matcher
(
const
std
::
string
&
s
)
{
Matcher
<
const
internal
::
StringV
iew
&>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
*
this
=
Eq
(
s
);
}
}
// Constructs a matcher that matches a const
absl::string_v
iew& whose value is
// Constructs a matcher that matches a const
StringV
iew& whose value is
// equal to s.
// equal to s.
Matcher
<
const
absl
::
string_v
iew
&>::
Matcher
(
const
char
*
s
)
{
Matcher
<
const
internal
::
StringV
iew
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
*
this
=
Eq
(
std
::
string
(
s
));
}
}
// Constructs a matcher that matches a const
absl::string_v
iew& whose value is
// Constructs a matcher that matches a const
StringV
iew& whose value is
// equal to s.
// equal to s.
Matcher
<
const
absl
::
string_view
&>::
Matcher
(
absl
::
string_v
iew
s
)
{
Matcher
<
const
internal
::
StringView
&>::
Matcher
(
internal
::
StringV
iew
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
*
this
=
Eq
(
std
::
string
(
s
));
}
}
// Constructs a matcher that matches a
absl::string_v
iew whose value is equal to
// Constructs a matcher that matches a
StringV
iew whose value is equal to
// s.
// s.
Matcher
<
absl
::
string_v
iew
>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
Matcher
<
internal
::
StringV
iew
>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
// Constructs a matcher that matches a
absl::string_v
iew whose value is equal to
// Constructs a matcher that matches a
StringV
iew whose value is equal to
// s.
// s.
Matcher
<
absl
::
string_v
iew
>::
Matcher
(
const
char
*
s
)
{
Matcher
<
internal
::
StringV
iew
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
*
this
=
Eq
(
std
::
string
(
s
));
}
}
// Constructs a matcher that matches a
absl::string_v
iew whose value is equal to
// Constructs a matcher that matches a
StringV
iew whose value is equal to
// s.
// s.
Matcher
<
absl
::
string_view
>::
Matcher
(
absl
::
string_v
iew
s
)
{
Matcher
<
internal
::
StringView
>::
Matcher
(
internal
::
StringV
iew
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
*
this
=
Eq
(
std
::
string
(
s
));
}
}
#endif // GTEST_
HAS_ABSL
#endif // GTEST_
INTERNAL_HAS_STRING_VIEW
}
// namespace testing
}
// namespace testing
googletest/test/googletest-printers-test.cc
View file @
6f5fd0d7
...
@@ -760,22 +760,22 @@ TEST(PrintTypeWithGenericStreamingTest, TypeImplicitlyConvertible) {
...
@@ -760,22 +760,22 @@ TEST(PrintTypeWithGenericStreamingTest, TypeImplicitlyConvertible) {
EXPECT_EQ
(
"AllowsGenericStreamingAndImplicitConversionTemplate"
,
Print
(
a
));
EXPECT_EQ
(
"AllowsGenericStreamingAndImplicitConversionTemplate"
,
Print
(
a
));
}
}
#if GTEST_
HAS_ABSL
#if GTEST_
INTERNAL_HAS_STRING_VIEW
// Tests printing
::absl::string_v
iew.
// Tests printing
internal::StringV
iew.
TEST
(
PrintStringViewTest
,
SimpleStringView
)
{
TEST
(
PrintStringViewTest
,
SimpleStringView
)
{
const
::
absl
::
string_v
iew
sp
=
"Hello"
;
const
internal
::
StringV
iew
sp
=
"Hello"
;
EXPECT_EQ
(
"
\"
Hello
\"
"
,
Print
(
sp
));
EXPECT_EQ
(
"
\"
Hello
\"
"
,
Print
(
sp
));
}
}
TEST
(
PrintStringViewTest
,
UnprintableCharacters
)
{
TEST
(
PrintStringViewTest
,
UnprintableCharacters
)
{
const
char
str
[]
=
"NUL (
\0
) and
\r\t
"
;
const
char
str
[]
=
"NUL (
\0
) and
\r\t
"
;
const
::
absl
::
string_v
iew
sp
(
str
,
sizeof
(
str
)
-
1
);
const
internal
::
StringV
iew
sp
(
str
,
sizeof
(
str
)
-
1
);
EXPECT_EQ
(
"
\"
NUL (
\\
0) and
\\
r
\\
t
\"
"
,
Print
(
sp
));
EXPECT_EQ
(
"
\"
NUL (
\\
0) and
\\
r
\\
t
\"
"
,
Print
(
sp
));
}
}
#endif // GTEST_
HAS_ABSL
#endif // GTEST_
INTERNAL_HAS_STRING_VIEW
// Tests printing STL containers.
// Tests printing STL containers.
...
...
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