Merge 92c604f9f3
into a6ce08abf7
This commit is contained in:
commit
7a4cb3942f
@ -1523,6 +1523,52 @@ GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
|
|||||||
const char* s2_expression,
|
const char* s2_expression,
|
||||||
const wchar_t* s1, const wchar_t* s2);
|
const wchar_t* s1, const wchar_t* s2);
|
||||||
|
|
||||||
|
#if GTEST_INTERNAL_HAS_STRING_VIEW
|
||||||
|
GTEST_ATTRIBUTE_UNUSED_ static inline AssertionResult CmpHelperSTREQ(
|
||||||
|
const char* s1_expression, const char* s2_expression,
|
||||||
|
const internal::StringView& s1, const internal::StringView& s2) {
|
||||||
|
return CmpHelperSTREQ(s1_expression, s2_expression, std::string(s1).c_str(),
|
||||||
|
std::string(s2).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
GTEST_ATTRIBUTE_UNUSED_ static inline AssertionResult CmpHelperSTRCASEEQ(
|
||||||
|
const char* s1_expression, const char* s2_expression,
|
||||||
|
const internal::StringView& s1, const internal::StringView& s2) {
|
||||||
|
return CmpHelperSTRCASEEQ(s1_expression, s2_expression,
|
||||||
|
std::string(s1).c_str(), std::string(s2).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
GTEST_ATTRIBUTE_UNUSED_ static inline AssertionResult CmpHelperSTRNE(
|
||||||
|
const char* s1_expression, const char* s2_expression,
|
||||||
|
const internal::StringView& s1, const internal::StringView& s2) {
|
||||||
|
return CmpHelperSTRNE(s1_expression, s2_expression, std::string(s1).c_str(),
|
||||||
|
std::string(s2).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
GTEST_ATTRIBUTE_UNUSED_ static inline AssertionResult CmpHelperSTRCASENE(
|
||||||
|
const char* s1_expression, const char* s2_expression,
|
||||||
|
const internal::StringView& s1, const internal::StringView& s2) {
|
||||||
|
return CmpHelperSTRCASENE(s1_expression, s2_expression,
|
||||||
|
std::string(s1).c_str(), std::string(s2).c_str());
|
||||||
|
}
|
||||||
|
#endif // GTEST_INTERNAL_HAS_STRING_VIEW
|
||||||
|
|
||||||
|
#if __cpp_lib_string_view >= 201803L
|
||||||
|
GTEST_ATTRIBUTE_UNUSED_ static inline AssertionResult CmpHelperSTREQ(
|
||||||
|
const char* s1_expression, const char* s2_expression,
|
||||||
|
const std::wstring_view& s1, const std::wstring_view& s2) {
|
||||||
|
return CmpHelperSTREQ(s1_expression, s2_expression, std::wstring(s1).c_str(),
|
||||||
|
std::wstring(s2).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
GTEST_ATTRIBUTE_UNUSED_ static inline AssertionResult CmpHelperSTRNE(
|
||||||
|
const char* s1_expression, const char* s2_expression,
|
||||||
|
const std::wstring_view& s1, const std::wstring_view& s2) {
|
||||||
|
return CmpHelperSTRNE(s1_expression, s2_expression, std::wstring(s1).c_str(),
|
||||||
|
std::wstring(s2).c_str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
// IsSubstring() and IsNotSubstring() are intended to be used as the
|
// IsSubstring() and IsNotSubstring() are intended to be used as the
|
||||||
|
@ -286,6 +286,10 @@ using testing::internal::GetCapturedStdout;
|
|||||||
using testing::internal::ThreadWithParam;
|
using testing::internal::ThreadWithParam;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GTEST_INTERNAL_HAS_STRING_VIEW
|
||||||
|
using testing::internal::StringView;
|
||||||
|
#endif
|
||||||
|
|
||||||
class TestingVector : public std::vector<int> {};
|
class TestingVector : public std::vector<int> {};
|
||||||
|
|
||||||
::std::ostream& operator<<(::std::ostream& os, const TestingVector& vector) {
|
::std::ostream& operator<<(::std::ostream& os, const TestingVector& vector) {
|
||||||
@ -2553,6 +2557,17 @@ TEST(StringAssertionTest, ASSERT_STRCASENE) {
|
|||||||
EXPECT_FATAL_FAILURE(ASSERT_STRCASENE("Hi", "hi"), "(ignoring case)");
|
EXPECT_FATAL_FAILURE(ASSERT_STRCASENE("Hi", "hi"), "(ignoring case)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GTEST_INTERNAL_HAS_STRING_VIEW
|
||||||
|
// Tests correct mapping to the C-String functions
|
||||||
|
TEST(StringAssertionTest, StringView) {
|
||||||
|
ASSERT_STREQ(StringView("hi"), StringView("hi"));
|
||||||
|
ASSERT_STREQ(StringView("hi"), "hi");
|
||||||
|
ASSERT_STRNE("hi", StringView("hi2"));
|
||||||
|
ASSERT_STRCASEEQ(StringView("hi"), "Hi");
|
||||||
|
ASSERT_STRCASENE("hi1", StringView("Hi2"));
|
||||||
|
}
|
||||||
|
#endif // GTEST_INTERNAL_HAS_STRING_VIEW
|
||||||
|
|
||||||
// Tests *_STREQ on wide strings.
|
// Tests *_STREQ on wide strings.
|
||||||
TEST(StringAssertionTest, STREQ_Wide) {
|
TEST(StringAssertionTest, STREQ_Wide) {
|
||||||
// NULL strings.
|
// NULL strings.
|
||||||
@ -2609,6 +2624,16 @@ TEST(StringAssertionTest, STRNE_Wide) {
|
|||||||
ASSERT_STRNE(L"abc\x8119", L"abc\x8120") << "This shouldn't happen";
|
ASSERT_STRNE(L"abc\x8119", L"abc\x8120") << "This shouldn't happen";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cpp_lib_string_view >= 201803L
|
||||||
|
// Tests correct mapping to the C-String functions
|
||||||
|
TEST(StringAssertionTest, StringView_Wide) {
|
||||||
|
using std::wstring_view;
|
||||||
|
ASSERT_STREQ(wstring_view(L"hi"), wstring_view(L"hi"));
|
||||||
|
ASSERT_STREQ(wstring_view(L"hi"), L"hi");
|
||||||
|
ASSERT_STRNE(L"hi", wstring_view(L"hi2"));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Tests for ::testing::IsSubstring().
|
// Tests for ::testing::IsSubstring().
|
||||||
|
|
||||||
// Tests that IsSubstring() returns the correct result when the input
|
// Tests that IsSubstring() returns the correct result when the input
|
||||||
|
Loading…
Reference in New Issue
Block a user