Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1129)

Unified Diff: base/logging_unittest.cc

Issue 367063006: Move logging.h's definitions of operator<< into namespace std. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a // namespace std. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/logging.cc ('k') | base/test/launcher/test_results_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging_unittest.cc
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc
index f823d6ee2d7814a089f930ffb2f130ed48e2b514..6ebe32e432aa06374645477badb59a2b2b5fd09f 100644
--- a/base/logging_unittest.cc
+++ b/base/logging_unittest.cc
@@ -233,6 +233,24 @@ TEST_F(LoggingTest, DcheckReleaseBehavior) {
DCHECK_EQ(some_variable, 1) << "test";
}
+// Test that defining an operator<< for a type in a namespace doesn't prevent
+// other code in that namespace from calling the operator<<(ostream, wstring)
+// defined by logging.h. This can fail if operator<<(ostream, wstring) can't be
+// found by ADL, since defining another operator<< prevents name lookup from
+// looking in the global namespace.
+namespace nested_test {
+ class Streamable {};
+ ALLOW_UNUSED std::ostream& operator<<(std::ostream& out, const Streamable&) {
+ return out << "Streamable";
+ }
+ TEST_F(LoggingTest, StreamingWstringFindsCorrectOperator) {
+ std::wstring wstr = L"Hello World";
+ std::ostringstream ostr;
+ ostr << wstr;
+ EXPECT_EQ("Hello World", ostr.str());
+ }
+} // namespace nested_test
+
} // namespace
} // namespace logging
« no previous file with comments | « base/logging.cc ('k') | base/test/launcher/test_results_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698