| 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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 SetLogAssertHandler(&LogSink); | 227 SetLogAssertHandler(&LogSink); |
| 228 EXPECT_TRUE(DCHECK_IS_ON()); | 228 EXPECT_TRUE(DCHECK_IS_ON()); |
| 229 EXPECT_FALSE(DLOG_IS_ON(DCHECK)); | 229 EXPECT_FALSE(DLOG_IS_ON(DCHECK)); |
| 230 #else | 230 #else |
| 231 // Debug build. | 231 // Debug build. |
| 232 SetLogAssertHandler(&LogSink); | 232 SetLogAssertHandler(&LogSink); |
| 233 EXPECT_TRUE(DCHECK_IS_ON()); | 233 EXPECT_TRUE(DCHECK_IS_ON()); |
| 234 EXPECT_TRUE(DLOG_IS_ON(DCHECK)); | 234 EXPECT_TRUE(DLOG_IS_ON(DCHECK)); |
| 235 #endif | 235 #endif |
| 236 | 236 |
| 237 #if defined(DCHECK_IS_DUMP_WITHOUT_CRASH) |
| 238 const bool kDCheckLogsOutput = false; |
| 239 #else |
| 240 const bool kDCheckLogsOutput = DCHECK_IS_ON(); |
| 241 #endif |
| 242 |
| 237 EXPECT_EQ(0, log_sink_call_count); | 243 EXPECT_EQ(0, log_sink_call_count); |
| 238 DCHECK(false); | 244 DCHECK(false); |
| 239 EXPECT_EQ(DCHECK_IS_ON() ? 1 : 0, log_sink_call_count); | 245 EXPECT_EQ(kDCheckLogsOutput ? 1 : 0, log_sink_call_count); |
| 240 DPCHECK(false); | 246 DPCHECK(false); |
| 241 EXPECT_EQ(DCHECK_IS_ON() ? 2 : 0, log_sink_call_count); | 247 EXPECT_EQ(kDCheckLogsOutput ? 2 : 0, log_sink_call_count); |
| 242 DCHECK_EQ(0, 1); | 248 DCHECK_EQ(0, 1); |
| 243 EXPECT_EQ(DCHECK_IS_ON() ? 3 : 0, log_sink_call_count); | 249 EXPECT_EQ(kDCheckLogsOutput ? 3 : 0, log_sink_call_count); |
| 244 } | 250 } |
| 245 | 251 |
| 246 TEST_F(LoggingTest, DcheckReleaseBehavior) { | 252 TEST_F(LoggingTest, DcheckReleaseBehavior) { |
| 247 int some_variable = 1; | 253 int some_variable = 1; |
| 248 // These should still reference |some_variable| so we don't get | 254 // These should still reference |some_variable| so we don't get |
| 249 // unused variable warnings. | 255 // unused variable warnings. |
| 250 DCHECK(some_variable) << "test"; | 256 DCHECK(some_variable) << "test"; |
| 251 DPCHECK(some_variable) << "test"; | 257 DPCHECK(some_variable) << "test"; |
| 252 DCHECK_EQ(some_variable, 1) << "test"; | 258 DCHECK_EQ(some_variable, 1) << "test"; |
| 253 } | 259 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 std::wstring wstr = L"Hello World"; | 297 std::wstring wstr = L"Hello World"; |
| 292 std::ostringstream ostr; | 298 std::ostringstream ostr; |
| 293 ostr << wstr; | 299 ostr << wstr; |
| 294 EXPECT_EQ("Hello World", ostr.str()); | 300 EXPECT_EQ("Hello World", ostr.str()); |
| 295 } | 301 } |
| 296 } // namespace nested_test | 302 } // namespace nested_test |
| 297 | 303 |
| 298 } // namespace | 304 } // namespace |
| 299 | 305 |
| 300 } // namespace logging | 306 } // namespace logging |
| OLD | NEW |