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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 226 |
227 TEST_F(LoggingTest, DcheckReleaseBehavior) { | 227 TEST_F(LoggingTest, DcheckReleaseBehavior) { |
228 int some_variable = 1; | 228 int some_variable = 1; |
229 // These should still reference |some_variable| so we don't get | 229 // These should still reference |some_variable| so we don't get |
230 // unused variable warnings. | 230 // unused variable warnings. |
231 DCHECK(some_variable) << "test"; | 231 DCHECK(some_variable) << "test"; |
232 DPCHECK(some_variable) << "test"; | 232 DPCHECK(some_variable) << "test"; |
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 |
| 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 |
| 239 // found by ADL, since defining another operator<< prevents name lookup from |
| 240 // looking in the global namespace. |
| 241 namespace nested_test { |
| 242 class Streamable {}; |
| 243 ALLOW_UNUSED std::ostream& operator<<(std::ostream& out, const Streamable&) { |
| 244 return out << "Streamable"; |
| 245 } |
| 246 TEST_F(LoggingTest, StreamingWstringFindsCorrectOperator) { |
| 247 std::wstring wstr = L"Hello World"; |
| 248 std::ostringstream ostr; |
| 249 ostr << wstr; |
| 250 EXPECT_EQ("Hello World", ostr.str()); |
| 251 } |
| 252 } // namespace nested_test |
| 253 |
236 } // namespace | 254 } // namespace |
237 | 255 |
238 } // namespace logging | 256 } // namespace logging |
OLD | NEW |