OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 | 7 |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 DCHECK_EQ(some_variable, 1) << "test"; | 233 DCHECK_EQ(some_variable, 1) << "test"; |
234 } | 234 } |
235 | 235 |
236 // Test that defining an operator<< for a type in a namespace doesn't prevent | 236 // Test that defining an operator<< for a type in a namespace doesn't prevent |
237 // other code in that namespace from calling the operator<<(ostream, wstring) | 237 // other code in that namespace from calling the operator<<(ostream, wstring) |
238 // defined by logging.h. This can fail if operator<<(ostream, wstring) can't be | 238 // defined by logging.h. This can fail if operator<<(ostream, wstring) can't be |
239 // found by ADL, since defining another operator<< prevents name lookup from | 239 // found by ADL, since defining another operator<< prevents name lookup from |
240 // looking in the global namespace. | 240 // looking in the global namespace. |
241 namespace nested_test { | 241 namespace nested_test { |
242 class Streamable {}; | 242 class Streamable {}; |
243 ALLOW_UNUSED std::ostream& operator<<(std::ostream& out, const Streamable&) { | 243 ALLOW_UNUSED_TYPE std::ostream& operator<<(std::ostream& out, |
danakj
2014/10/16 15:27:06
nit: can you put this ALLOW on the other side of t
Peter Kasting
2014/10/16 17:39:06
Done.
| |
244 const Streamable&) { | |
244 return out << "Streamable"; | 245 return out << "Streamable"; |
245 } | 246 } |
246 TEST_F(LoggingTest, StreamingWstringFindsCorrectOperator) { | 247 TEST_F(LoggingTest, StreamingWstringFindsCorrectOperator) { |
247 std::wstring wstr = L"Hello World"; | 248 std::wstring wstr = L"Hello World"; |
248 std::ostringstream ostr; | 249 std::ostringstream ostr; |
249 ostr << wstr; | 250 ostr << wstr; |
250 EXPECT_EQ("Hello World", ostr.str()); | 251 EXPECT_EQ("Hello World", ostr.str()); |
251 } | 252 } |
252 } // namespace nested_test | 253 } // namespace nested_test |
253 | 254 |
254 } // namespace | 255 } // namespace |
255 | 256 |
256 } // namespace logging | 257 } // namespace logging |
OLD | NEW |