From d9825431313a8ce466489cfc19f93820aee319ee Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 1 Apr 2019 12:06:49 -0400 Subject: Googletest export Remove support for "global" ::string and ::wstring types. This support existed for legacy codebases that existed from before namespaces where a thing. It is no longer necessary. PiperOrigin-RevId: 241335738 --- googlemock/include/gmock/gmock-actions.h | 3 - googlemock/include/gmock/gmock-matchers.h | 12 +- googlemock/test/gmock-actions_test.cc | 8 - googlemock/test/gmock-matchers_test.cc | 278 +-------------------- googletest/include/gtest/gtest-matchers.h | 75 +----- googletest/include/gtest/gtest-message.h | 6 - googletest/include/gtest/gtest-printers.h | 28 +-- googletest/include/gtest/gtest.h | 21 -- .../gtest/internal/gtest-death-test-internal.h | 6 - googletest/include/gtest/internal/gtest-port.h | 51 +--- googletest/src/gtest-matchers.cc | 55 ---- googletest/src/gtest-port.cc | 7 - googletest/src/gtest-printers.cc | 18 -- googletest/src/gtest.cc | 13 +- googletest/test/googletest-death-test-test.cc | 11 - googletest/test/googletest-port-test.cc | 7 +- googletest/test/googletest-printers-test.cc | 73 +----- googletest/test/gtest_unittest.cc | 79 ------ 18 files changed, 20 insertions(+), 731 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 8513e01f..37727c09 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -139,9 +139,6 @@ class BuiltInDefaultValue { } GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT -#if GTEST_HAS_GLOBAL_STRING -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, ""); -#endif // GTEST_HAS_GLOBAL_STRING GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, ""); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\0'); diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index fa24fd2f..3e4ee403 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -661,7 +661,7 @@ class StrEqualityMatcher { MatchResultListener* listener) const { // This should fail to compile if absl::string_view is used with wide // strings. - const StringType& str = string(s); + const StringType& str = std::string(s); return MatchAndExplain(str, listener); } #endif // GTEST_HAS_ABSL @@ -731,7 +731,7 @@ class HasSubstrMatcher { MatchResultListener* listener) const { // This should fail to compile if absl::string_view is used with wide // strings. - const StringType& str = string(s); + const StringType& str = std::string(s); return MatchAndExplain(str, listener); } #endif // GTEST_HAS_ABSL @@ -788,7 +788,7 @@ class StartsWithMatcher { MatchResultListener* listener) const { // This should fail to compile if absl::string_view is used with wide // strings. - const StringType& str = string(s); + const StringType& str = std::string(s); return MatchAndExplain(str, listener); } #endif // GTEST_HAS_ABSL @@ -844,7 +844,7 @@ class EndsWithMatcher { MatchResultListener* listener) const { // This should fail to compile if absl::string_view is used with wide // strings. - const StringType& str = string(s); + const StringType& str = std::string(s); return MatchAndExplain(str, listener); } #endif // GTEST_HAS_ABSL @@ -3852,7 +3852,7 @@ inline PolymorphicMatcher > EndsWith( return MakePolymorphicMatcher(internal::EndsWithMatcher(suffix)); } -#if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING +#if GTEST_HAS_STD_WSTRING // Wide string matchers. // Matches a string equal to str. @@ -3905,7 +3905,7 @@ inline PolymorphicMatcher > EndsWith( internal::EndsWithMatcher(suffix)); } -#endif // GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING +#endif // GTEST_HAS_STD_WSTRING // Creates a polymorphic matcher that matches a 2-tuple where the // first field == the second field. diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index b3fef67a..f761b446 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -172,20 +172,12 @@ TEST(BuiltInDefaultValueTest, BoolExists) { // Tests that BuiltInDefaultValue::Get() returns "" when T is a // string type. TEST(BuiltInDefaultValueTest, IsEmptyStringForString) { -#if GTEST_HAS_GLOBAL_STRING - EXPECT_EQ("", BuiltInDefaultValue< ::string>::Get()); -#endif // GTEST_HAS_GLOBAL_STRING - EXPECT_EQ("", BuiltInDefaultValue< ::std::string>::Get()); } // Tests that BuiltInDefaultValue::Exists() returns true when T is a // string type. TEST(BuiltInDefaultValueTest, ExistsForString) { -#if GTEST_HAS_GLOBAL_STRING - EXPECT_TRUE(BuiltInDefaultValue< ::string>::Exists()); -#endif // GTEST_HAS_GLOBAL_STRING - EXPECT_TRUE(BuiltInDefaultValue< ::std::string>::Exists()); } diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 40ccaf05..8bdad637 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -91,7 +91,6 @@ using testing::internal::MatchMatrix; using testing::internal::PredicateFormatterFromMatcher; using testing::internal::RE; using testing::internal::StreamMatchResultListener; -using testing::internal::string; using testing::internal::Strings; // Helper for testing container-valued matchers in mock method context. It is @@ -348,58 +347,6 @@ TEST(StringMatcherTest, CanBeImplicitlyConstructedFromString) { EXPECT_FALSE(m2.Matches("hello")); } -#if GTEST_HAS_GLOBAL_STRING -// Tests that a ::string object can be implicitly converted to a -// Matcher or Matcher. -TEST(StringMatcherTest, CanBeImplicitlyConstructedFromGlobalString) { - Matcher m1 = ::string("hi"); - EXPECT_TRUE(m1.Matches("hi")); - EXPECT_FALSE(m1.Matches("hello")); - - Matcher m2 = ::string("hi"); - EXPECT_TRUE(m2.Matches("hi")); - EXPECT_FALSE(m2.Matches("hello")); -} -#endif // GTEST_HAS_GLOBAL_STRING - -#if GTEST_HAS_GLOBAL_STRING -// Tests that a C-string literal can be implicitly converted to a -// Matcher<::string> or Matcher. -TEST(GlobalStringMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) { - Matcher< ::string> m1 = "hi"; - EXPECT_TRUE(m1.Matches("hi")); - EXPECT_FALSE(m1.Matches("hello")); - - Matcher m2 = "hi"; - EXPECT_TRUE(m2.Matches("hi")); - EXPECT_FALSE(m2.Matches("hello")); -} - -// Tests that a std::string object can be implicitly converted to a -// Matcher<::string> or Matcher. -TEST(GlobalStringMatcherTest, CanBeImplicitlyConstructedFromString) { - Matcher< ::string> m1 = std::string("hi"); - EXPECT_TRUE(m1.Matches("hi")); - EXPECT_FALSE(m1.Matches("hello")); - - Matcher m2 = std::string("hi"); - EXPECT_TRUE(m2.Matches("hi")); - EXPECT_FALSE(m2.Matches("hello")); -} - -// Tests that a ::string object can be implicitly converted to a -// Matcher<::string> or Matcher. -TEST(GlobalStringMatcherTest, CanBeImplicitlyConstructedFromGlobalString) { - Matcher< ::string> m1 = ::string("hi"); - EXPECT_TRUE(m1.Matches("hi")); - EXPECT_FALSE(m1.Matches("hello")); - - Matcher m2 = ::string("hi"); - EXPECT_TRUE(m2.Matches("hi")); - EXPECT_FALSE(m2.Matches("hello")); -} -#endif // GTEST_HAS_GLOBAL_STRING - #if GTEST_HAS_ABSL // Tests that a C-string literal can be implicitly converted to a // Matcher or Matcher. @@ -425,20 +372,6 @@ TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromString) { EXPECT_FALSE(m2.Matches("dogs")); } -#if GTEST_HAS_GLOBAL_STRING -// Tests that a ::string object can be implicitly converted to a -// Matcher or Matcher. -TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromGlobalString) { - Matcher m1 = ::string("cats"); - EXPECT_TRUE(m1.Matches("cats")); - EXPECT_FALSE(m1.Matches("dogs")); - - Matcher m2 = ::string("cats"); - EXPECT_TRUE(m2.Matches("cats")); - EXPECT_FALSE(m2.Matches("dogs")); -} -#endif // GTEST_HAS_GLOBAL_STRING - // Tests that a absl::string_view object can be implicitly converted to a // Matcher or Matcher. TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromStringView) { @@ -1515,12 +1448,12 @@ struct Tag {}; struct PairWithGet { int member_1; - string member_2; + std::string member_2; using first_type = int; - using second_type = string; + using second_type = std::string; const int& GetImpl(Tag<0>) const { return member_1; } - const string& GetImpl(Tag<1>) const { return member_2; } + const std::string& GetImpl(Tag<1>) const { return member_2; } }; template auto get(const PairWithGet& value) -> decltype(value.GetImpl(Tag())) { @@ -1693,7 +1626,8 @@ TEST(PairTest, UseGetInsteadOfMembers) { EXPECT_THAT(pair, Not(Pair(Lt(7), "ABC"))); std::vector v = {{11, "Foo"}, {29, "gMockIsBestMock"}}; - EXPECT_THAT(v, ElementsAre(Pair(11, string("Foo")), Pair(Ge(10), Not("")))); + EXPECT_THAT(v, + ElementsAre(Pair(11, std::string("Foo")), Pair(Ge(10), Not("")))); } // Tests StartsWith(s). @@ -1739,15 +1673,6 @@ TEST(EndsWithTest, MatchesStringWithGivenSuffix) { EXPECT_FALSE(m2.Matches("i")); EXPECT_FALSE(m2.Matches("Hi ")); -#if GTEST_HAS_GLOBAL_STRING - const Matcher m3 = EndsWith(::string("Hi")); - EXPECT_TRUE(m3.Matches("Hi")); - EXPECT_TRUE(m3.Matches("Wow Hi Hi")); - EXPECT_TRUE(m3.Matches("Super Hi")); - EXPECT_FALSE(m3.Matches("i")); - EXPECT_FALSE(m3.Matches("Hi ")); -#endif // GTEST_HAS_GLOBAL_STRING - #if GTEST_HAS_ABSL const Matcher m4 = EndsWith(""); EXPECT_TRUE(m4.Matches("Hi")); @@ -2030,197 +1955,6 @@ TEST(StdWideEndsWithTest, CanDescribeSelf) { #endif // GTEST_HAS_STD_WSTRING -#if GTEST_HAS_GLOBAL_WSTRING -TEST(GlobalWideStrEqTest, MatchesEqual) { - Matcher m = StrEq(::wstring(L"Hello")); - EXPECT_TRUE(m.Matches(L"Hello")); - EXPECT_FALSE(m.Matches(L"hello")); - EXPECT_FALSE(m.Matches(nullptr)); - - Matcher m2 = StrEq(L"Hello"); - EXPECT_TRUE(m2.Matches(L"Hello")); - EXPECT_FALSE(m2.Matches(L"Hi")); - - Matcher m3 = StrEq(L"\xD3\x576\x8D3\xC74D"); - EXPECT_TRUE(m3.Matches(L"\xD3\x576\x8D3\xC74D")); - EXPECT_FALSE(m3.Matches(L"\xD3\x576\x8D3\xC74E")); - - ::wstring str(L"01204500800"); - str[3] = L'\0'; - Matcher m4 = StrEq(str); - EXPECT_TRUE(m4.Matches(str)); - str[0] = str[6] = str[7] = str[9] = str[10] = L'\0'; - Matcher m5 = StrEq(str); - EXPECT_TRUE(m5.Matches(str)); -} - -TEST(GlobalWideStrEqTest, CanDescribeSelf) { - Matcher< ::wstring> m = StrEq(L"Hi-\'\"?\\\a\b\f\n\r\t\v"); - EXPECT_EQ("is equal to L\"Hi-\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\"", - Describe(m)); - - Matcher< ::wstring> m2 = StrEq(L"\xD3\x576\x8D3\xC74D"); - EXPECT_EQ("is equal to L\"\\xD3\\x576\\x8D3\\xC74D\"", - Describe(m2)); - - ::wstring str(L"01204500800"); - str[3] = L'\0'; - Matcher m4 = StrEq(str); - EXPECT_EQ("is equal to L\"012\\04500800\"", Describe(m4)); - str[0] = str[6] = str[7] = str[9] = str[10] = L'\0'; - Matcher m5 = StrEq(str); - EXPECT_EQ("is equal to L\"\\012\\045\\0\\08\\0\\0\"", Describe(m5)); -} - -TEST(GlobalWideStrNeTest, MatchesUnequalString) { - Matcher m = StrNe(L"Hello"); - EXPECT_TRUE(m.Matches(L"")); - EXPECT_TRUE(m.Matches(nullptr)); - EXPECT_FALSE(m.Matches(L"Hello")); - - Matcher< ::wstring> m2 = StrNe(::wstring(L"Hello")); - EXPECT_TRUE(m2.Matches(L"hello")); - EXPECT_FALSE(m2.Matches(L"Hello")); -} - -TEST(GlobalWideStrNeTest, CanDescribeSelf) { - Matcher m = StrNe(L"Hi"); - EXPECT_EQ("isn't equal to L\"Hi\"", Describe(m)); -} - -TEST(GlobalWideStrCaseEqTest, MatchesEqualStringIgnoringCase) { - Matcher m = StrCaseEq(::wstring(L"Hello")); - EXPECT_TRUE(m.Matches(L"Hello")); - EXPECT_TRUE(m.Matches(L"hello")); - EXPECT_FALSE(m.Matches(L"Hi")); - EXPECT_FALSE(m.Matches(nullptr)); - - Matcher m2 = StrCaseEq(L"Hello"); - EXPECT_TRUE(m2.Matches(L"hello")); - EXPECT_FALSE(m2.Matches(L"Hi")); -} - -TEST(GlobalWideStrCaseEqTest, MatchesEqualStringWith0IgnoringCase) { - ::wstring str1(L"oabocdooeoo"); - ::wstring str2(L"OABOCDOOEOO"); - Matcher m0 = StrCaseEq(str1); - EXPECT_FALSE(m0.Matches(str2 + ::wstring(1, L'\0'))); - - str1[3] = str2[3] = L'\0'; - Matcher m1 = StrCaseEq(str1); - EXPECT_TRUE(m1.Matches(str2)); - - str1[0] = str1[6] = str1[7] = str1[10] = L'\0'; - str2[0] = str2[6] = str2[7] = str2[10] = L'\0'; - Matcher m2 = StrCaseEq(str1); - str1[9] = str2[9] = L'\0'; - EXPECT_FALSE(m2.Matches(str2)); - - Matcher m3 = StrCaseEq(str1); - EXPECT_TRUE(m3.Matches(str2)); - - EXPECT_FALSE(m3.Matches(str2 + L"x")); - str2.append(1, L'\0'); - EXPECT_FALSE(m3.Matches(str2)); - EXPECT_FALSE(m3.Matches(::wstring(str2, 0, 9))); -} - -TEST(GlobalWideStrCaseEqTest, CanDescribeSelf) { - Matcher< ::wstring> m = StrCaseEq(L"Hi"); - EXPECT_EQ("is equal to (ignoring case) L\"Hi\"", Describe(m)); -} - -TEST(GlobalWideStrCaseNeTest, MatchesUnequalStringIgnoringCase) { - Matcher m = StrCaseNe(L"Hello"); - EXPECT_TRUE(m.Matches(L"Hi")); - EXPECT_TRUE(m.Matches(nullptr)); - EXPECT_FALSE(m.Matches(L"Hello")); - EXPECT_FALSE(m.Matches(L"hello")); - - Matcher< ::wstring> m2 = StrCaseNe(::wstring(L"Hello")); - EXPECT_TRUE(m2.Matches(L"")); - EXPECT_FALSE(m2.Matches(L"Hello")); -} - -TEST(GlobalWideStrCaseNeTest, CanDescribeSelf) { - Matcher m = StrCaseNe(L"Hi"); - EXPECT_EQ("isn't equal to (ignoring case) L\"Hi\"", Describe(m)); -} - -// Tests that HasSubstr() works for matching wstring-typed values. -TEST(GlobalWideHasSubstrTest, WorksForStringClasses) { - const Matcher< ::wstring> m1 = HasSubstr(L"foo"); - EXPECT_TRUE(m1.Matches(::wstring(L"I love food."))); - EXPECT_FALSE(m1.Matches(::wstring(L"tofo"))); - - const Matcher m2 = HasSubstr(L"foo"); - EXPECT_TRUE(m2.Matches(::wstring(L"I love food."))); - EXPECT_FALSE(m2.Matches(::wstring(L"tofo"))); -} - -// Tests that HasSubstr() works for matching C-wide-string-typed values. -TEST(GlobalWideHasSubstrTest, WorksForCStrings) { - const Matcher m1 = HasSubstr(L"foo"); - EXPECT_TRUE(m1.Matches(const_cast(L"I love food."))); - EXPECT_FALSE(m1.Matches(const_cast(L"tofo"))); - EXPECT_FALSE(m1.Matches(nullptr)); - - const Matcher m2 = HasSubstr(L"foo"); - EXPECT_TRUE(m2.Matches(L"I love food.")); - EXPECT_FALSE(m2.Matches(L"tofo")); - EXPECT_FALSE(m2.Matches(nullptr)); -} - -// Tests that HasSubstr(s) describes itself properly. -TEST(GlobalWideHasSubstrTest, CanDescribeSelf) { - Matcher< ::wstring> m = HasSubstr(L"foo\n\""); - EXPECT_EQ("has substring L\"foo\\n\\\"\"", Describe(m)); -} - -// Tests StartsWith(s). - -TEST(GlobalWideStartsWithTest, MatchesStringWithGivenPrefix) { - const Matcher m1 = StartsWith(::wstring(L"")); - EXPECT_TRUE(m1.Matches(L"Hi")); - EXPECT_TRUE(m1.Matches(L"")); - EXPECT_FALSE(m1.Matches(nullptr)); - - const Matcher m2 = StartsWith(L"Hi"); - EXPECT_TRUE(m2.Matches(L"Hi")); - EXPECT_TRUE(m2.Matches(L"Hi Hi!")); - EXPECT_TRUE(m2.Matches(L"High")); - EXPECT_FALSE(m2.Matches(L"H")); - EXPECT_FALSE(m2.Matches(L" Hi")); -} - -TEST(GlobalWideStartsWithTest, CanDescribeSelf) { - Matcher m = StartsWith(L"Hi"); - EXPECT_EQ("starts with L\"Hi\"", Describe(m)); -} - -// Tests EndsWith(s). - -TEST(GlobalWideEndsWithTest, MatchesStringWithGivenSuffix) { - const Matcher m1 = EndsWith(L""); - EXPECT_TRUE(m1.Matches(L"Hi")); - EXPECT_TRUE(m1.Matches(L"")); - EXPECT_FALSE(m1.Matches(nullptr)); - - const Matcher m2 = EndsWith(::wstring(L"Hi")); - EXPECT_TRUE(m2.Matches(L"Hi")); - EXPECT_TRUE(m2.Matches(L"Wow Hi Hi")); - EXPECT_TRUE(m2.Matches(L"Super Hi")); - EXPECT_FALSE(m2.Matches(L"i")); - EXPECT_FALSE(m2.Matches(L"Hi ")); -} - -TEST(GlobalWideEndsWithTest, CanDescribeSelf) { - Matcher m = EndsWith(L"Hi"); - EXPECT_EQ("ends with L\"Hi\"", Describe(m)); -} - -#endif // GTEST_HAS_GLOBAL_WSTRING - typedef ::std::tuple Tuple2; // NOLINT // Tests that Eq() matches a 2-tuple where the first field == the @@ -2759,7 +2493,7 @@ TEST(ElementsAreTest, HugeMatcher) { // Tests the variadic version of the UnorderedElementsAreMatcher TEST(ElementsAreTest, HugeMatcherStr) { - vector test_vector{ + vector test_vector{ "literal_string", "", "", "", "", "", "", "", "", "", "", ""}; EXPECT_THAT(test_vector, UnorderedElementsAre("literal_string", _, _, _, _, _, diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index 846b9455..bf500fc8 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -352,12 +352,6 @@ class GTEST_API_ Matcher // str is a std::string object. Matcher(const std::string& s); // NOLINT -#if GTEST_HAS_GLOBAL_STRING - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT -#endif // GTEST_HAS_GLOBAL_STRING - // Allows the user to write "foo" instead of Eq("foo") sometimes. Matcher(const char* s); // NOLINT }; @@ -377,64 +371,9 @@ class GTEST_API_ Matcher // str is a string object. Matcher(const std::string& s); // NOLINT -#if GTEST_HAS_GLOBAL_STRING - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT -#endif // GTEST_HAS_GLOBAL_STRING - - // Allows the user to write "foo" instead of Eq("foo") sometimes. - Matcher(const char* s); // NOLINT -}; - -#if GTEST_HAS_GLOBAL_STRING -// The following two specializations allow the user to write str -// instead of Eq(str) and "foo" instead of Eq("foo") when a ::string -// matcher is expected. -template <> -class GTEST_API_ Matcher - : public internal::MatcherBase { - public: - Matcher() {} - - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase(impl) {} - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a std::string object. - Matcher(const std::string& s); // NOLINT - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT - - // Allows the user to write "foo" instead of Eq("foo") sometimes. - Matcher(const char* s); // NOLINT -}; - -template <> -class GTEST_API_ Matcher< ::string> - : public internal::MatcherBase< ::string> { - public: - Matcher() {} - - explicit Matcher(const MatcherInterface* impl) - : internal::MatcherBase< ::string>(impl) {} - explicit Matcher(const MatcherInterface< ::string>* impl) - : internal::MatcherBase< ::string>(impl) {} - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a std::string object. - Matcher(const std::string& s); // NOLINT - - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT - // Allows the user to write "foo" instead of Eq("foo") sometimes. Matcher(const char* s); // NOLINT }; -#endif // GTEST_HAS_GLOBAL_STRING #if GTEST_HAS_ABSL // The following two specializations allow the user to write str @@ -453,12 +392,6 @@ class GTEST_API_ Matcher // str is a std::string object. Matcher(const std::string& s); // NOLINT -#if GTEST_HAS_GLOBAL_STRING - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT -#endif // GTEST_HAS_GLOBAL_STRING - // Allows the user to write "foo" instead of Eq("foo") sometimes. Matcher(const char* s); // NOLINT @@ -481,12 +414,6 @@ class GTEST_API_ Matcher // str is a std::string object. Matcher(const std::string& s); // NOLINT -#if GTEST_HAS_GLOBAL_STRING - // Allows the user to write str instead of Eq(str) sometimes, where - // str is a ::string object. - Matcher(const ::string& s); // NOLINT -#endif // GTEST_HAS_GLOBAL_STRING - // Allows the user to write "foo" instead of Eq("foo") sometimes. Matcher(const char* s); // NOLINT @@ -687,7 +614,7 @@ class MatchesRegexMatcher { #if GTEST_HAS_ABSL bool MatchAndExplain(const absl::string_view& s, MatchResultListener* listener) const { - return MatchAndExplain(string(s), listener); + return MatchAndExplain(std::string(s), listener); } #endif // GTEST_HAS_ABSL diff --git a/googletest/include/gtest/gtest-message.h b/googletest/include/gtest/gtest-message.h index cd9319d6..4a80e11e 100644 --- a/googletest/include/gtest/gtest-message.h +++ b/googletest/include/gtest/gtest-message.h @@ -179,12 +179,6 @@ class GTEST_API_ Message { Message& operator <<(const ::std::wstring& wstr); #endif // GTEST_HAS_STD_WSTRING -#if GTEST_HAS_GLOBAL_WSTRING - // Converts the given wide string to a narrow string using the UTF-8 - // encoding, and streams the result to this Message object. - Message& operator <<(const ::wstring& wstr); -#endif // GTEST_HAS_GLOBAL_WSTRING - // Gets the text streamed to this object so far as an std::string. // Each '\0' character in the buffer is replaced with "\\0". // diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index ef166b0d..97cdb2a2 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -357,16 +357,6 @@ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t); GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string); GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string); -#if GTEST_HAS_GLOBAL_STRING -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string); -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string); -#endif - -#if GTEST_HAS_GLOBAL_WSTRING -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring); -GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring); -#endif - #if GTEST_HAS_STD_WSTRING GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring); GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring); @@ -598,27 +588,13 @@ void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) { } } -// Overloads for ::string and ::std::string. -#if GTEST_HAS_GLOBAL_STRING -GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os); -inline void PrintTo(const ::string& s, ::std::ostream* os) { - PrintStringTo(s, os); -} -#endif // GTEST_HAS_GLOBAL_STRING - +// Overloads for ::std::string. GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os); inline void PrintTo(const ::std::string& s, ::std::ostream* os) { PrintStringTo(s, os); } -// Overloads for ::wstring and ::std::wstring. -#if GTEST_HAS_GLOBAL_WSTRING -GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os); -inline void PrintTo(const ::wstring& s, ::std::ostream* os) { - PrintWideStringTo(s, os); -} -#endif // GTEST_HAS_GLOBAL_WSTRING - +// Overloads for ::std::wstring. #if GTEST_HAS_STD_WSTRING GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os); inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) { diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 5211a20b..cedef931 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -73,21 +73,6 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ /* class A needs to have dll-interface to be used by clients of class B */) -// Depending on the platform, different string classes are available. -// On Linux, in addition to ::std::string, Google also makes use of -// class ::string, which has the same interface as ::std::string, but -// has a different implementation. -// -// You can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that -// ::string is available AND is a distinct type to ::std::string, or -// define it to 0 to indicate otherwise. -// -// If ::std::string and ::string are the same class on your platform -// due to aliasing, you should define GTEST_HAS_GLOBAL_STRING to 0. -// -// If you do not define GTEST_HAS_GLOBAL_STRING, it is defined -// heuristically. - namespace testing { // Silence C4100 (unreferenced formal parameter) and 4805 @@ -2219,12 +2204,6 @@ class GTEST_API_ ScopedTrace { PushTrace(file, line, message ? message : "(null)"); } -#if GTEST_HAS_GLOBAL_STRING - ScopedTrace(const char* file, int line, const ::string& message) { - PushTrace(file, line, message); - } -#endif - ScopedTrace(const char* file, int line, const std::string& message) { PushTrace(file, line, message); } diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h index 0bf1fcfb..68bd3530 100644 --- a/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -176,12 +176,6 @@ inline Matcher MakeDeathTestMatcher( const ::std::string& regex) { return ContainsRegex(regex); } -#if GTEST_HAS_GLOBAL_STRING -inline Matcher MakeDeathTestMatcher( - const ::string& regex) { - return ContainsRegex(regex); -} -#endif // If a Matcher is passed to EXPECT_DEATH (etc.), it's // used directly. diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 8be36f95..81338246 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -72,10 +72,6 @@ // is/isn't available. // GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions // are enabled. -// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string -// is/isn't available -// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::wstring -// is/isn't available // GTEST_HAS_POSIX_RE - Define it to 1/0 to indicate that POSIX regular // expressions are/aren't available. // GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that @@ -269,12 +265,10 @@ # include #endif -// Brings in the definition of HAS_GLOBAL_STRING. This must be done -// BEFORE we test HAS_GLOBAL_STRING. -#include // NOLINT #include // NOLINT #include // NOLINT #include // NOLINT +#include // NOLINT #include #include #include // NOLINT @@ -458,10 +452,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; # error "::std::string isn't available." #endif // !defined(GTEST_HAS_STD_STRING) -#ifndef GTEST_HAS_GLOBAL_STRING -# define GTEST_HAS_GLOBAL_STRING 0 -#endif // GTEST_HAS_GLOBAL_STRING - #ifndef GTEST_HAS_STD_WSTRING // The user didn't tell us whether ::std::wstring is available, so we need // to figure it out. @@ -473,13 +463,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // GTEST_HAS_STD_WSTRING -#ifndef GTEST_HAS_GLOBAL_WSTRING -// The user didn't tell us whether ::wstring is available, so we need -// to figure it out. -# define GTEST_HAS_GLOBAL_WSTRING \ - (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING) -#endif // GTEST_HAS_GLOBAL_WSTRING - // Determines whether RTTI is available. #ifndef GTEST_HAS_RTTI // The user didn't tell us whether RTTI is enabled, so we need to @@ -885,18 +868,6 @@ struct IsSame { // Evaluates to the number of elements in 'array'. #define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0])) -#if GTEST_HAS_GLOBAL_STRING -typedef ::string string; -#else -typedef ::std::string string; -#endif // GTEST_HAS_GLOBAL_STRING - -#if GTEST_HAS_GLOBAL_WSTRING -typedef ::wstring wstring; -#elif GTEST_HAS_STD_WSTRING -typedef ::std::wstring wstring; -#endif // GTEST_HAS_GLOBAL_WSTRING - // A helper for suppressing warnings on constant condition. It just // returns 'condition'. GTEST_API_ bool IsTrue(bool condition); @@ -918,12 +889,6 @@ class GTEST_API_ RE { // Constructs an RE from a string. RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT -# if GTEST_HAS_GLOBAL_STRING - - RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT - -# endif // GTEST_HAS_GLOBAL_STRING - RE(const char* regex) { Init(regex); } // NOLINT ~RE(); @@ -941,17 +906,6 @@ class GTEST_API_ RE { return PartialMatch(str.c_str(), re); } -# if GTEST_HAS_GLOBAL_STRING - - static bool FullMatch(const ::string& str, const RE& re) { - return FullMatch(str.c_str(), re); - } - static bool PartialMatch(const ::string& str, const RE& re) { - return PartialMatch(str.c_str(), re); - } - -# endif // GTEST_HAS_GLOBAL_STRING - static bool FullMatch(const char* str, const RE& re); static bool PartialMatch(const char* str, const RE& re); @@ -1207,9 +1161,6 @@ std::vector GetInjectableArgvs(); // Deprecated: pass the args vector by value instead. void SetInjectableArgvs(const std::vector* new_argvs); void SetInjectableArgvs(const std::vector& new_argvs); -#if GTEST_HAS_GLOBAL_STRING -void SetInjectableArgvs(const std::vector< ::string>& new_argvs); -#endif // GTEST_HAS_GLOBAL_STRING void ClearInjectableArgvs(); #endif // GTEST_HAS_DEATH_TEST diff --git a/googletest/src/gtest-matchers.cc b/googletest/src/gtest-matchers.cc index de275d36..7d2fb685 100644 --- a/googletest/src/gtest-matchers.cc +++ b/googletest/src/gtest-matchers.cc @@ -44,14 +44,6 @@ namespace testing { // equal to s. Matcher::Matcher(const std::string& s) { *this = Eq(s); } -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a const std::string& whose value is -// equal to s. -Matcher::Matcher(const ::string& s) { - *this = Eq(static_cast(s)); -} -#endif // GTEST_HAS_GLOBAL_STRING - // Constructs a matcher that matches a const std::string& whose value is // equal to s. Matcher::Matcher(const char* s) { @@ -62,45 +54,10 @@ Matcher::Matcher(const char* s) { // s. Matcher::Matcher(const std::string& s) { *this = Eq(s); } -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a std::string whose value is equal to -// s. -Matcher::Matcher(const ::string& s) { - *this = Eq(static_cast(s)); -} -#endif // GTEST_HAS_GLOBAL_STRING - // Constructs a matcher that matches a std::string whose value is equal to // s. Matcher::Matcher(const char* s) { *this = Eq(std::string(s)); } -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a const ::string& whose value is -// equal to s. -Matcher::Matcher(const std::string& s) { - *this = Eq(static_cast<::string>(s)); -} - -// Constructs a matcher that matches a const ::string& whose value is -// equal to s. -Matcher::Matcher(const ::string& s) { *this = Eq(s); } - -// Constructs a matcher that matches a const ::string& whose value is -// equal to s. -Matcher::Matcher(const char* s) { *this = Eq(::string(s)); } - -// Constructs a matcher that matches a ::string whose value is equal to s. -Matcher<::string>::Matcher(const std::string& s) { - *this = Eq(static_cast<::string>(s)); -} - -// Constructs a matcher that matches a ::string whose value is equal to s. -Matcher<::string>::Matcher(const ::string& s) { *this = Eq(s); } - -// Constructs a matcher that matches a string whose value is equal to s. -Matcher<::string>::Matcher(const char* s) { *this = Eq(::string(s)); } -#endif // GTEST_HAS_GLOBAL_STRING - #if GTEST_HAS_ABSL // Constructs a matcher that matches a const absl::string_view& whose value is // equal to s. @@ -108,12 +65,6 @@ Matcher::Matcher(const std::string& s) { *this = Eq(s); } -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a const absl::string_view& whose value is -// equal to s. -Matcher::Matcher(const ::string& s) { *this = Eq(s); } -#endif // GTEST_HAS_GLOBAL_STRING - // Constructs a matcher that matches a const absl::string_view& whose value is // equal to s. Matcher::Matcher(const char* s) { @@ -130,12 +81,6 @@ Matcher::Matcher(absl::string_view s) { // s. Matcher::Matcher(const std::string& s) { *this = Eq(s); } -#if GTEST_HAS_GLOBAL_STRING -// Constructs a matcher that matches a absl::string_view whose value is equal to -// s. -Matcher::Matcher(const ::string& s) { *this = Eq(s); } -#endif // GTEST_HAS_GLOBAL_STRING - // Constructs a matcher that matches a absl::string_view whose value is equal to // s. Matcher::Matcher(const char* s) { diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index 587ca0a5..8f7cd1c0 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -1247,13 +1247,6 @@ void SetInjectableArgvs(const std::vector& new_argvs) { new std::vector(new_argvs.begin(), new_argvs.end())); } -#if GTEST_HAS_GLOBAL_STRING -void SetInjectableArgvs(const std::vector< ::string>& new_argvs) { - SetInjectableArgvs( - new std::vector(new_argvs.begin(), new_argvs.end())); -} -#endif // GTEST_HAS_GLOBAL_STRING - void ClearInjectableArgvs() { delete g_injected_test_argvs; g_injected_test_argvs = nullptr; diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc index f0e8e571..5325ef23 100644 --- a/googletest/src/gtest-printers.cc +++ b/googletest/src/gtest-printers.cc @@ -419,17 +419,6 @@ void ConditionalPrintAsText(const char* str, size_t length, ostream* os) { } // anonymous namespace -// Prints a ::string object. -#if GTEST_HAS_GLOBAL_STRING -void PrintStringTo(const ::string& s, ostream* os) { - if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) { - if (GTEST_FLAG(print_utf8)) { - ConditionalPrintAsText(s.data(), s.size(), os); - } - } -} -#endif // GTEST_HAS_GLOBAL_STRING - void PrintStringTo(const ::std::string& s, ostream* os) { if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) { if (GTEST_FLAG(print_utf8)) { @@ -438,13 +427,6 @@ void PrintStringTo(const ::std::string& s, ostream* os) { } } -// Prints a ::wstring object. -#if GTEST_HAS_GLOBAL_WSTRING -void PrintWideStringTo(const ::wstring& s, ostream* os) { - PrintCharsAsStringTo(s.data(), s.size(), os); -} -#endif // GTEST_HAS_GLOBAL_WSTRING - #if GTEST_HAS_STD_WSTRING void PrintWideStringTo(const ::std::wstring& s, ostream* os) { PrintCharsAsStringTo(s.data(), s.size(), os); diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 0a048603..37cedfb3 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -922,7 +922,7 @@ bool String::CStringEquals(const char * lhs, const char * rhs) { return strcmp(lhs, rhs) == 0; } -#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING +#if GTEST_HAS_STD_WSTRING // Converts an array of wide chars to a narrow string using the UTF-8 // encoding, and streams the result to the given Message object. @@ -940,7 +940,7 @@ static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length, } } -#endif // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING +#endif // GTEST_HAS_STD_WSTRING void SplitString(const ::std::string& str, char delimiter, ::std::vector< ::std::string>* dest) { @@ -990,15 +990,6 @@ Message& Message::operator <<(const ::std::wstring& wstr) { } #endif // GTEST_HAS_STD_WSTRING -#if GTEST_HAS_GLOBAL_WSTRING -// Converts the given wide string to a narrow string using the UTF-8 -// encoding, and streams the result to this Message object. -Message& Message::operator <<(const ::wstring& wstr) { - internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this); - return *this; -} -#endif // GTEST_HAS_GLOBAL_WSTRING - // Gets the text streamed to this object so far as an std::string. // Each '\0' character in the buffer is replaced with "\\0". std::string Message::GetString() const { diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc index 01837ea7..b8645414 100644 --- a/googletest/test/googletest-death-test-test.cc +++ b/googletest/test/googletest-death-test-test.cc @@ -493,17 +493,6 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) { const testing::internal::RE regex(regex_c_str); EXPECT_DEATH(GlobalFunction(), regex); -# if GTEST_HAS_GLOBAL_STRING - - const ::string regex_str(regex_c_str); - EXPECT_DEATH(GlobalFunction(), regex_str); - - // This one is tricky; a temporary pointer into another temporary. Reference - // lifetime extension of the pointer is not sufficient. - EXPECT_DEATH(GlobalFunction(), ::string(regex_c_str).c_str()); - -# endif // GTEST_HAS_GLOBAL_STRING - # if !GTEST_USES_PCRE const ::std::string regex_std_str(regex_c_str); diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index 39b643b6..6cb791e5 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -388,12 +388,7 @@ class RETest : public ::testing::Test {}; // Defines StringTypes as the list of all string types that class RE // supports. -typedef testing::Types< - ::std::string, -# if GTEST_HAS_GLOBAL_STRING - ::string, -# endif // GTEST_HAS_GLOBAL_STRING - const char*> StringTypes; +typedef testing::Types< ::std::string, const char*> StringTypes; TYPED_TEST_SUITE(RETest, StringTypes); diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index 5ce2a770..d896c241 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -656,16 +656,6 @@ TEST(PrintArrayTest, BigArray) { // Tests printing ::string and ::std::string. -#if GTEST_HAS_GLOBAL_STRING -// ::string. -TEST(PrintStringTest, StringInGlobalNamespace) { - const char s[] = "'\"?\\\a\b\f\n\0\r\t\v\x7F\xFF a"; - const ::string str(s, sizeof(s)); - EXPECT_EQ("\"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\x7F\\xFF a\\0\"", - Print(str)); -} -#endif // GTEST_HAS_GLOBAL_STRING - // ::std::string. TEST(PrintStringTest, StringInStdNamespace) { const char s[] = "'\"?\\\a\b\f\n\0\r\t\v\x7F\xFF a"; @@ -688,19 +678,7 @@ TEST(PrintStringTest, StringAmbiguousHex) { EXPECT_EQ("\"!\\x5-!\"", Print(::std::string("!\x5-!"))); } -// Tests printing ::wstring and ::std::wstring. - -#if GTEST_HAS_GLOBAL_WSTRING -// ::wstring. -TEST(PrintWideStringTest, StringInGlobalNamespace) { - const wchar_t s[] = L"'\"?\\\a\b\f\n\0\r\t\v\xD3\x576\x8D3\xC74D a"; - const ::wstring str(s, sizeof(s)/sizeof(wchar_t)); - EXPECT_EQ("L\"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v" - "\\xD3\\x576\\x8D3\\xC74D a\\0\"", - Print(str)); -} -#endif // GTEST_HAS_GLOBAL_WSTRING - +// Tests printing ::std::wstring. #if GTEST_HAS_STD_WSTRING // ::std::wstring. TEST(PrintWideStringTest, StringInStdNamespace) { @@ -1243,21 +1221,6 @@ TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsPointer) { // Tests formatting a char pointer when it's compared to a string object. // In this case we want to print the char pointer as a C string. -#if GTEST_HAS_GLOBAL_STRING -// char pointer vs ::string -TEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsString) { - const char* s = "hello \"world"; - EXPECT_STREQ("\"hello \\\"world\"", // The string content should be escaped. - FormatForComparisonFailureMessage(s, ::string()).c_str()); - - // char* - char str[] = "hi\1"; - char* p = str; - EXPECT_STREQ("\"hi\\x1\"", // The string content should be escaped. - FormatForComparisonFailureMessage(p, ::string()).c_str()); -} -#endif - // char pointer vs std::string TEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsStdString) { const char* s = "hello \"world"; @@ -1271,21 +1234,6 @@ TEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsStdString) { FormatForComparisonFailureMessage(p, ::std::string()).c_str()); } -#if GTEST_HAS_GLOBAL_WSTRING -// wchar_t pointer vs ::wstring -TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsWString) { - const wchar_t* s = L"hi \"world"; - EXPECT_STREQ("L\"hi \\\"world\"", // The string content should be escaped. - FormatForComparisonFailureMessage(s, ::wstring()).c_str()); - - // wchar_t* - wchar_t str[] = L"hi\1"; - wchar_t* p = str; - EXPECT_STREQ("L\"hi\\x1\"", // The string content should be escaped. - FormatForComparisonFailureMessage(p, ::wstring()).c_str()); -} -#endif - #if GTEST_HAS_STD_WSTRING // wchar_t pointer vs std::wstring TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsStdWString) { @@ -1338,16 +1286,6 @@ TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsWCharArray) { // Tests formatting a char array when it's compared with a string object. // In this case we want to print the array as a C string. -#if GTEST_HAS_GLOBAL_STRING -// char array vs string -TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsString) { - const char str[] = "hi \"w\0rld\""; - EXPECT_STREQ("\"hi \\\"w\"", // The content should be escaped. - // Embedded NUL terminates the string. - FormatForComparisonFailureMessage(str, ::string()).c_str()); -} -#endif - // char array vs std::string TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsStdString) { const char str[] = "hi \"world\""; @@ -1355,15 +1293,6 @@ TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsStdString) { FormatForComparisonFailureMessage(str, ::std::string()).c_str()); } -#if GTEST_HAS_GLOBAL_WSTRING -// wchar_t array vs wstring -TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsWString) { - const wchar_t str[] = L"hi \"world\""; - EXPECT_STREQ("L\"hi \\\"world\\\"\"", // The content should be escaped. - FormatForComparisonFailureMessage(str, ::wstring()).c_str()); -} -#endif - #if GTEST_HAS_STD_WSTRING // wchar_t array vs std::wstring TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsStdWString) { diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 4e67120b..9c1827d4 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -1243,12 +1243,6 @@ TEST_F(ExpectFatalFailureTest, CatchesFatalFaliure) { EXPECT_FATAL_FAILURE(AddFatalFailure(), "Expected fatal failure."); } -#if GTEST_HAS_GLOBAL_STRING -TEST_F(ExpectFatalFailureTest, AcceptsStringObject) { - EXPECT_FATAL_FAILURE(AddFatalFailure(), ::string("Expected fatal failure.")); -} -#endif - TEST_F(ExpectFatalFailureTest, AcceptsStdStringObject) { EXPECT_FATAL_FAILURE(AddFatalFailure(), ::std::string("Expected fatal failure.")); @@ -1331,13 +1325,6 @@ TEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailure) { "Expected non-fatal failure."); } -#if GTEST_HAS_GLOBAL_STRING -TEST_F(ExpectNonfatalFailureTest, AcceptsStringObject) { - EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(), - ::string("Expected non-fatal failure.")); -} -#endif - TEST_F(ExpectNonfatalFailureTest, AcceptsStdStringObject) { EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(), ::std::string("Expected non-fatal failure.")); @@ -4852,72 +4839,6 @@ TEST(EqAssertionTest, StdWideString) { #endif // GTEST_HAS_STD_WSTRING -#if GTEST_HAS_GLOBAL_STRING -// Tests using ::string values in {EXPECT|ASSERT}_EQ. -TEST(EqAssertionTest, GlobalString) { - // Compares a const char* to a ::string that has identical content. - EXPECT_EQ("Test", ::string("Test")); - - // Compares two identical ::strings. - const ::string str1("A * in the middle"); - const ::string str2(str1); - ASSERT_EQ(str1, str2); - - // Compares a ::string to a const char* that has different content. - EXPECT_NONFATAL_FAILURE(EXPECT_EQ(::string("Test"), "test"), - "test"); - - // Compares two ::strings that have different contents, one of which - // having a NUL character in the middle. - ::string str3(str1); - str3.at(2) = '\0'; - EXPECT_NONFATAL_FAILURE(EXPECT_EQ(str1, str3), - "str3"); - - // Compares a ::string to a char* that has different content. - EXPECT_FATAL_FAILURE({ // NOLINT - ASSERT_EQ(::string("bar"), const_cast("foo")); - }, ""); -} - -#endif // GTEST_HAS_GLOBAL_STRING - -#if GTEST_HAS_GLOBAL_WSTRING - -// Tests using ::wstring values in {EXPECT|ASSERT}_EQ. -TEST(EqAssertionTest, GlobalWideString) { - // Compares two identical ::wstrings. - static const ::wstring wstr1(L"A * in the middle"); - static const ::wstring wstr2(wstr1); - EXPECT_EQ(wstr1, wstr2); - - // Compares a const wchar_t* to a ::wstring that has identical content. - const wchar_t kTestX8119[] = { 'T', 'e', 's', 't', 0x8119, '\0' }; - ASSERT_EQ(kTestX8119, ::wstring(kTestX8119)); - - // Compares a const wchar_t* to a ::wstring that has different - // content. - const wchar_t kTestX8120[] = { 'T', 'e', 's', 't', 0x8120, '\0' }; - EXPECT_NONFATAL_FAILURE({ // NOLINT - EXPECT_EQ(kTestX8120, ::wstring(kTestX8119)); - }, "Test\\x8119"); - - // Compares a wchar_t* to a ::wstring that has different content. - wchar_t* const p1 = const_cast(L"foo"); - EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, ::wstring(L"bar")), - "bar"); - - // Compares two ::wstrings that have different contents, one of which - // having a NUL character in the middle. - static ::wstring wstr3; - wstr3 = wstr1; - wstr3.at(2) = L'\0'; - EXPECT_FATAL_FAILURE(ASSERT_EQ(wstr1, wstr3), - "wstr3"); -} - -#endif // GTEST_HAS_GLOBAL_WSTRING - // Tests using char pointers in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, CharPointer) { char* const p0 = nullptr; -- cgit v1.2.1