aboutsummaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2020-02-11 11:22:17 -0500
committerMark Barolak <mbar@google.com>2020-02-11 15:50:26 -0500
commit6f5fd0d7199b9a19faa9f499ecc266e6ae0329e7 (patch)
treefb5032ab088488cf7d897da6fbc9a28d2581aedd /googletest/include/gtest/internal
parentd0930731d601e4a061886bd78ca3d438ca19451d (diff)
downloadgoogletest-6f5fd0d7199b9a19faa9f499ecc266e6ae0329e7.tar.gz
googletest-6f5fd0d7199b9a19faa9f499ecc266e6ae0329e7.tar.bz2
googletest-6f5fd0d7199b9a19faa9f499ecc266e6ae0329e7.zip
Googletest export
Add gmock Matcher<std::string_view> specialization. PiperOrigin-RevId: 294443240
Diffstat (limited to 'googletest/include/gtest/internal')
-rw-r--r--googletest/include/gtest/internal/gtest-port.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 0543da54..60ff4716 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -199,6 +199,9 @@
// suppressed (constant conditional).
// GTEST_INTENTIONAL_CONST_COND_POP_ - finish code section where MSVC C4127
// is suppressed.
+// GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher<std::string_view> or
+// Matcher<absl::string_view>
+// specializations.
//
// Synchronization:
// Mutex, MutexLock, ThreadLocal, GetThreadCount()
@@ -2220,4 +2223,32 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val);
#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_