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/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 if (false) | 251 if (false) |
252 CHECK_EQ(false, true); // Unreached. | 252 CHECK_EQ(false, true); // Unreached. |
253 else | 253 else |
254 CHECK_EQ(true, reached = true); // Reached, passed. | 254 CHECK_EQ(true, reached = true); // Reached, passed. |
255 ASSERT_TRUE(reached); | 255 ASSERT_TRUE(reached); |
256 | 256 |
257 if (false) | 257 if (false) |
258 CHECK_EQ(false, true); // Unreached. | 258 CHECK_EQ(false, true); // Unreached. |
259 } | 259 } |
260 | 260 |
261 // Test that scoped enums can be used with CHECK_EQ. | |
262 TEST_F(LoggingTest, ScopedEnum) { | |
263 enum class TestEnum { | |
danakj
2015/11/20 19:42:28
can you check fixed signed and unsigned int also?
| |
264 Value, | |
265 }; | |
266 CHECK_EQ(TestEnum::Value, TestEnum::Value); | |
267 } | |
268 | |
261 // Test that defining an operator<< for a type in a namespace doesn't prevent | 269 // Test that defining an operator<< for a type in a namespace doesn't prevent |
262 // other code in that namespace from calling the operator<<(ostream, wstring) | 270 // other code in that namespace from calling the operator<<(ostream, wstring) |
263 // defined by logging.h. This can fail if operator<<(ostream, wstring) can't be | 271 // defined by logging.h. This can fail if operator<<(ostream, wstring) can't be |
264 // found by ADL, since defining another operator<< prevents name lookup from | 272 // found by ADL, since defining another operator<< prevents name lookup from |
265 // looking in the global namespace. | 273 // looking in the global namespace. |
266 namespace nested_test { | 274 namespace nested_test { |
267 class Streamable {}; | 275 class Streamable {}; |
268 ALLOW_UNUSED_TYPE std::ostream& operator<<(std::ostream& out, | 276 ALLOW_UNUSED_TYPE std::ostream& operator<<(std::ostream& out, |
269 const Streamable&) { | 277 const Streamable&) { |
270 return out << "Streamable"; | 278 return out << "Streamable"; |
271 } | 279 } |
272 TEST_F(LoggingTest, StreamingWstringFindsCorrectOperator) { | 280 TEST_F(LoggingTest, StreamingWstringFindsCorrectOperator) { |
273 std::wstring wstr = L"Hello World"; | 281 std::wstring wstr = L"Hello World"; |
274 std::ostringstream ostr; | 282 std::ostringstream ostr; |
275 ostr << wstr; | 283 ostr << wstr; |
276 EXPECT_EQ("Hello World", ostr.str()); | 284 EXPECT_EQ("Hello World", ostr.str()); |
277 } | 285 } |
278 } // namespace nested_test | 286 } // namespace nested_test |
279 | 287 |
280 } // namespace | 288 } // namespace |
281 | 289 |
282 } // namespace logging | 290 } // namespace logging |
OLD | NEW |