Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: base/logging_unittest.cc

Issue 2731823002: Replace use of logging::DEBUG_MODE with DCHECK_IS_ON(). (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/logging.h ('k') | components/sync/base/logging.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 LogStateSaver log_state_saver_; 62 LogStateSaver log_state_saver_;
63 }; 63 };
64 64
65 class MockLogSource { 65 class MockLogSource {
66 public: 66 public:
67 MOCK_METHOD0(Log, const char*()); 67 MOCK_METHOD0(Log, const char*());
68 }; 68 };
69 69
70 TEST_F(LoggingTest, BasicLogging) { 70 TEST_F(LoggingTest, BasicLogging) {
71 MockLogSource mock_log_source; 71 MockLogSource mock_log_source;
72 EXPECT_CALL(mock_log_source, Log()).Times(DEBUG_MODE ? 16 : 8). 72 EXPECT_CALL(mock_log_source, Log())
73 WillRepeatedly(Return("log message")); 73 .Times(DCHECK_IS_ON() ? 16 : 8)
74 .WillRepeatedly(Return("log message"));
74 75
75 SetMinLogLevel(LOG_INFO); 76 SetMinLogLevel(LOG_INFO);
76 77
77 EXPECT_TRUE(LOG_IS_ON(INFO)); 78 EXPECT_TRUE(LOG_IS_ON(INFO));
78 // As of g++-4.5, the first argument to EXPECT_EQ cannot be a 79 EXPECT_TRUE((DCHECK_IS_ON() != 0) == DLOG_IS_ON(INFO));
79 // constant expression.
80 const bool kIsDebugMode = (DEBUG_MODE != 0);
81 EXPECT_TRUE(kIsDebugMode == DLOG_IS_ON(INFO));
82 EXPECT_TRUE(VLOG_IS_ON(0)); 80 EXPECT_TRUE(VLOG_IS_ON(0));
83 81
84 LOG(INFO) << mock_log_source.Log(); 82 LOG(INFO) << mock_log_source.Log();
85 LOG_IF(INFO, true) << mock_log_source.Log(); 83 LOG_IF(INFO, true) << mock_log_source.Log();
86 PLOG(INFO) << mock_log_source.Log(); 84 PLOG(INFO) << mock_log_source.Log();
87 PLOG_IF(INFO, true) << mock_log_source.Log(); 85 PLOG_IF(INFO, true) << mock_log_source.Log();
88 VLOG(0) << mock_log_source.Log(); 86 VLOG(0) << mock_log_source.Log();
89 VLOG_IF(0, true) << mock_log_source.Log(); 87 VLOG_IF(0, true) << mock_log_source.Log();
90 VPLOG(0) << mock_log_source.Log(); 88 VPLOG(0) << mock_log_source.Log();
91 VPLOG_IF(0, true) << mock_log_source.Log(); 89 VPLOG_IF(0, true) << mock_log_source.Log();
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 std::wstring wstr = L"Hello World"; 502 std::wstring wstr = L"Hello World";
505 std::ostringstream ostr; 503 std::ostringstream ostr;
506 ostr << wstr; 504 ostr << wstr;
507 EXPECT_EQ("Hello World", ostr.str()); 505 EXPECT_EQ("Hello World", ostr.str());
508 } 506 }
509 } // namespace nested_test 507 } // namespace nested_test
510 508
511 } // namespace 509 } // namespace
512 510
513 } // namespace logging 511 } // namespace logging
OLDNEW
« no previous file with comments | « base/logging.h ('k') | components/sync/base/logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698