| 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 | |
| 243 EXPECT_EQ(0, log_sink_call_count); | 237 EXPECT_EQ(0, log_sink_call_count); |
| 244 DCHECK(false); | 238 DCHECK(false); |
| 245 EXPECT_EQ(kDCheckLogsOutput ? 1 : 0, log_sink_call_count); | 239 EXPECT_EQ(DCHECK_IS_ON() ? 1 : 0, log_sink_call_count); |
| 246 DPCHECK(false); | 240 DPCHECK(false); |
| 247 EXPECT_EQ(kDCheckLogsOutput ? 2 : 0, log_sink_call_count); | 241 EXPECT_EQ(DCHECK_IS_ON() ? 2 : 0, log_sink_call_count); |
| 248 DCHECK_EQ(0, 1); | 242 DCHECK_EQ(0, 1); |
| 249 EXPECT_EQ(kDCheckLogsOutput ? 3 : 0, log_sink_call_count); | 243 EXPECT_EQ(DCHECK_IS_ON() ? 3 : 0, log_sink_call_count); |
| 250 } | 244 } |
| 251 | 245 |
| 252 TEST_F(LoggingTest, DcheckReleaseBehavior) { | 246 TEST_F(LoggingTest, DcheckReleaseBehavior) { |
| 253 int some_variable = 1; | 247 int some_variable = 1; |
| 254 // These should still reference |some_variable| so we don't get | 248 // These should still reference |some_variable| so we don't get |
| 255 // unused variable warnings. | 249 // unused variable warnings. |
| 256 DCHECK(some_variable) << "test"; | 250 DCHECK(some_variable) << "test"; |
| 257 DPCHECK(some_variable) << "test"; | 251 DPCHECK(some_variable) << "test"; |
| 258 DCHECK_EQ(some_variable, 1) << "test"; | 252 DCHECK_EQ(some_variable, 1) << "test"; |
| 259 } | 253 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 std::wstring wstr = L"Hello World"; | 291 std::wstring wstr = L"Hello World"; |
| 298 std::ostringstream ostr; | 292 std::ostringstream ostr; |
| 299 ostr << wstr; | 293 ostr << wstr; |
| 300 EXPECT_EQ("Hello World", ostr.str()); | 294 EXPECT_EQ("Hello World", ostr.str()); |
| 301 } | 295 } |
| 302 } // namespace nested_test | 296 } // namespace nested_test |
| 303 | 297 |
| 304 } // namespace | 298 } // namespace |
| 305 | 299 |
| 306 } // namespace logging | 300 } // namespace logging |
| OLD | NEW |