summaryrefslogtreecommitdiffstats
path: root/googletest/test
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2017-05-15 21:07:03 (GMT)
committerNico Weber <thakis@chromium.org>2017-05-15 21:53:04 (GMT)
commit09fd5b3ebfaac10b78bda664ec7f57fac74ef214 (patch)
tree89a7afc9280b7e42b96391ea2b42075446503e0f /googletest/test
parent294f72bc773c92410aa3c5ecdd6cd4a757c3fbf4 (diff)
downloadgoogletest-09fd5b3ebfaac10b78bda664ec7f57fac74ef214.zip
googletest-09fd5b3ebfaac10b78bda664ec7f57fac74ef214.tar.gz
googletest-09fd5b3ebfaac10b78bda664ec7f57fac74ef214.tar.bz2
Use std::string and ::string explicitly in gtest and gmock code.refs/pull/1089/head
This merges a Google-internal change (117235625). Original CL description: This CL was created manually in about an hour with sed, a Python script to find all the places unqualified 'string' was mentioned, and some help from Emacs to add the "std::" qualifications, plus a few manual tweaks.
Diffstat (limited to 'googletest/test')
-rw-r--r--googletest/test/gtest-death-test_test.cc2
-rw-r--r--googletest/test/gtest-printers_test.cc52
-rw-r--r--googletest/test/gtest_unittest.cc7
3 files changed, 29 insertions, 32 deletions
diff --git a/googletest/test/gtest-death-test_test.cc b/googletest/test/gtest-death-test_test.cc
index bb4a3d1..957fe38 100644
--- a/googletest/test/gtest-death-test_test.cc
+++ b/googletest/test/gtest-death-test_test.cc
@@ -505,7 +505,7 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
# if GTEST_HAS_GLOBAL_STRING
- const string regex_str(regex_c_str);
+ const ::string regex_str(regex_c_str);
EXPECT_DEATH(GlobalFunction(), regex_str);
# endif // GTEST_HAS_GLOBAL_STRING
diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc
index 107b10f..b0a8341 100644
--- a/googletest/test/gtest-printers_test.cc
+++ b/googletest/test/gtest-printers_test.cc
@@ -236,7 +236,7 @@ using ::stdext::hash_multiset;
// Prints a value to a string using the universal value printer. This
// is a helper for testing UniversalPrinter<T>::Print() for various types.
template <typename T>
-string Print(const T& value) {
+std::string Print(const T& value) {
::std::stringstream ss;
UniversalPrinter<T>::Print(value, &ss);
return ss.str();
@@ -246,7 +246,7 @@ string Print(const T& value) {
// value printer. This is a helper for testing
// UniversalPrinter<T&>::Print() for various types.
template <typename T>
-string PrintByRef(const T& value) {
+std::string PrintByRef(const T& value) {
::std::stringstream ss;
UniversalPrinter<T&>::Print(value, &ss);
return ss.str();
@@ -383,7 +383,7 @@ TEST(PrintBuiltInTypeTest, FloatingPoints) {
// Since ::std::stringstream::operator<<(const void *) formats the pointer
// output differently with different compilers, we have to create the expected
// output first and use it as our expectation.
-static string PrintPointer(const void *p) {
+static std::string PrintPointer(const void* p) {
::std::stringstream expected_result_stream;
expected_result_stream << p;
return expected_result_stream.str();
@@ -596,7 +596,7 @@ TEST(PrintPointerTest, MemberFunctionPointer) {
// The difference between this and Print() is that it ensures that the
// argument is a reference to an array.
template <typename T, size_t N>
-string PrintArrayHelper(T (&a)[N]) {
+std::string PrintArrayHelper(T (&a)[N]) {
return Print(a);
}
@@ -649,7 +649,7 @@ TEST(PrintArrayTest, WConstCharArrayWithTerminatingNul) {
// Array of objects.
TEST(PrintArrayTest, ObjectArray) {
- string a[3] = { "Hi", "Hello", "Ni hao" };
+ std::string a[3] = {"Hi", "Hello", "Ni hao"};
EXPECT_EQ("{ \"Hi\", \"Hello\", \"Ni hao\" }", PrintArrayHelper(a));
}
@@ -831,7 +831,7 @@ TEST(PrintStlContainerTest, HashMultiMap) {
map1.insert(make_pair(5, false));
// Elements of hash_multimap can be printed in any order.
- const string result = Print(map1);
+ const std::string result = Print(map1);
EXPECT_TRUE(result == "{ (5, true), (5, false) }" ||
result == "{ (5, false), (5, true) }")
<< " where Print(map1) returns \"" << result << "\".";
@@ -842,9 +842,9 @@ TEST(PrintStlContainerTest, HashMultiMap) {
#if GTEST_HAS_HASH_SET_
TEST(PrintStlContainerTest, HashSet) {
- hash_set<string> set1;
- set1.insert("hello");
- EXPECT_EQ("{ \"hello\" }", Print(set1));
+ hash_set<int> set1;
+ set1.insert(1);
+ EXPECT_EQ("{ 1 }", Print(set1));
}
TEST(PrintStlContainerTest, HashMultiSet) {
@@ -853,8 +853,8 @@ TEST(PrintStlContainerTest, HashMultiSet) {
hash_multiset<int> set1(a, a + kSize);
// Elements of hash_multiset can be printed in any order.
- const string result = Print(set1);
- const string expected_pattern = "{ d, d, d, d, d }"; // d means a digit.
+ const std::string result = Print(set1);
+ const std::string expected_pattern = "{ d, d, d, d, d }"; // d means a digit.
// Verifies the result matches the expected pattern; also extracts
// the numbers in the result.
@@ -879,11 +879,8 @@ TEST(PrintStlContainerTest, HashMultiSet) {
#endif // GTEST_HAS_HASH_SET_
TEST(PrintStlContainerTest, List) {
- const string a[] = {
- "hello",
- "world"
- };
- const list<string> strings(a, a + 2);
+ const std::string a[] = {"hello", "world"};
+ const list<std::string> strings(a, a + 2);
EXPECT_EQ("{ \"hello\", \"world\" }", Print(strings));
}
@@ -1039,9 +1036,10 @@ TEST(PrintTr1TupleTest, VariousSizes) {
// VC++ 2010's implementation of tuple of C++0x is deficient, requiring
// an explicit type cast of NULL to be used.
::std::tr1::tuple<bool, char, short, testing::internal::Int32, // NOLINT
- testing::internal::Int64, float, double, const char*, void*, string>
- t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str,
- ImplicitCast_<void*>(NULL), "10");
+ testing::internal::Int64, float, double, const char*, void*,
+ std::string>
+ t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, ImplicitCast_<void*>(NULL),
+ "10");
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")",
Print(t10));
@@ -1098,9 +1096,10 @@ TEST(PrintStdTupleTest, VariousSizes) {
// VC++ 2010's implementation of tuple of C++0x is deficient, requiring
// an explicit type cast of NULL to be used.
::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT
- testing::internal::Int64, float, double, const char*, void*, string>
- t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str,
- ImplicitCast_<void*>(NULL), "10");
+ testing::internal::Int64, float, double, const char*, void*,
+ std::string>
+ t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, ImplicitCast_<void*>(NULL),
+ "10");
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")",
Print(t10));
@@ -1204,13 +1203,13 @@ TEST(PrintReferenceTest, PrintsAddressAndValue) {
// reference.
TEST(PrintReferenceTest, HandlesFunctionPointer) {
void (*fp)(int n) = &MyFunction;
- const string fp_pointer_string =
+ const std::string fp_pointer_string =
PrintPointer(reinterpret_cast<const void*>(&fp));
// We cannot directly cast &MyFunction to const void* because the
// standard disallows casting between pointers to functions and
// pointers to objects, and some compilers (e.g. GCC 3.4) enforce
// this limitation.
- const string fp_string = PrintPointer(reinterpret_cast<const void*>(
+ const std::string fp_string = PrintPointer(reinterpret_cast<const void*>(
reinterpret_cast<internal::BiggestInt>(fp)));
EXPECT_EQ("@" + fp_pointer_string + " " + fp_string,
PrintByRef(fp));
@@ -1542,12 +1541,12 @@ TEST(UniversalPrintTest, WorksForCString) {
const char* s1 = "abc";
::std::stringstream ss1;
UniversalPrint(s1, &ss1);
- EXPECT_EQ(PrintPointer(s1) + " pointing to \"abc\"", string(ss1.str()));
+ EXPECT_EQ(PrintPointer(s1) + " pointing to \"abc\"", std::string(ss1.str()));
char* s2 = const_cast<char*>(s1);
::std::stringstream ss2;
UniversalPrint(s2, &ss2);
- EXPECT_EQ(PrintPointer(s2) + " pointing to \"abc\"", string(ss2.str()));
+ EXPECT_EQ(PrintPointer(s2) + " pointing to \"abc\"", std::string(ss2.str()));
const char* s3 = NULL;
::std::stringstream ss3;
@@ -1636,4 +1635,3 @@ TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) {
} // namespace gtest_printers_test
} // namespace testing
-
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 814a025..7627b88 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -86,9 +86,9 @@ class StreamingListenerTest : public Test {
class FakeSocketWriter : public StreamingListener::AbstractSocketWriter {
public:
// Sends a string to the socket.
- virtual void Send(const string& message) { output_ += message; }
+ virtual void Send(const std::string& message) { output_ += message; }
- string output_;
+ std::string output_;
};
StreamingListenerTest()
@@ -98,7 +98,7 @@ class StreamingListenerTest : public Test {
CodeLocation(__FILE__, __LINE__), 0, NULL) {}
protected:
- string* output() { return &(fake_sock_writer_->output_); }
+ std::string* output() { return &(fake_sock_writer_->output_); }
FakeSocketWriter* const fake_sock_writer_;
StreamingListener streamer_;
@@ -7703,4 +7703,3 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {
EXPECT_FALSE(SkipPrefix("world!", &p));
EXPECT_EQ(str, p);
}
-