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

Side by Side Diff: base/logging_unittest.cc

Issue 1885933002: Ensure that DLOG(FATAL) also asserts in release-with-asserts builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment with installer fix Created 4 years, 8 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') | base/message_loop/incoming_task_queue.cc » ('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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 PCHECK(!mock_log_source.Log()) << mock_log_source.Log(); 184 PCHECK(!mock_log_source.Log()) << mock_log_source.Log();
185 CHECK_EQ(mock_log_source.Log(), mock_log_source.Log()) 185 CHECK_EQ(mock_log_source.Log(), mock_log_source.Log())
186 << uncalled_mock_log_source.Log(); 186 << uncalled_mock_log_source.Log();
187 CHECK_NE(mock_log_source.Log(), mock_log_source.Log()) 187 CHECK_NE(mock_log_source.Log(), mock_log_source.Log())
188 << mock_log_source.Log(); 188 << mock_log_source.Log();
189 } 189 }
190 190
191 #endif 191 #endif
192 192
193 TEST_F(LoggingTest, DebugLoggingReleaseBehavior) { 193 TEST_F(LoggingTest, DebugLoggingReleaseBehavior) {
194 #if !defined(NDEBUG) 194 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
195 int debug_only_variable = 1; 195 int debug_only_variable = 1;
196 #endif 196 #endif
197 // These should avoid emitting references to |debug_only_variable| 197 // These should avoid emitting references to |debug_only_variable|
198 // in release mode. 198 // in release mode.
199 DLOG_IF(INFO, debug_only_variable) << "test"; 199 DLOG_IF(INFO, debug_only_variable) << "test";
200 DLOG_ASSERT(debug_only_variable) << "test"; 200 DLOG_ASSERT(debug_only_variable) << "test";
201 DPLOG_IF(INFO, debug_only_variable) << "test"; 201 DPLOG_IF(INFO, debug_only_variable) << "test";
202 DVLOG_IF(1, debug_only_variable) << "test"; 202 DVLOG_IF(1, debug_only_variable) << "test";
203 } 203 }
204 204
(...skipping 14 matching lines...) Expand all
219 219
220 TEST_F(LoggingTest, Dcheck) { 220 TEST_F(LoggingTest, Dcheck) {
221 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) 221 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
222 // Release build. 222 // Release build.
223 EXPECT_FALSE(DCHECK_IS_ON()); 223 EXPECT_FALSE(DCHECK_IS_ON());
224 EXPECT_FALSE(DLOG_IS_ON(DCHECK)); 224 EXPECT_FALSE(DLOG_IS_ON(DCHECK));
225 #elif defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) 225 #elif defined(NDEBUG) && defined(DCHECK_ALWAYS_ON)
226 // Release build with real DCHECKS. 226 // Release build with real DCHECKS.
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_TRUE(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 EXPECT_EQ(0, log_sink_call_count); 237 EXPECT_EQ(0, log_sink_call_count);
238 DCHECK(false); 238 DCHECK(false);
239 EXPECT_EQ(DCHECK_IS_ON() ? 1 : 0, log_sink_call_count); 239 EXPECT_EQ(DCHECK_IS_ON() ? 1 : 0, log_sink_call_count);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 std::wstring wstr = L"Hello World"; 291 std::wstring wstr = L"Hello World";
292 std::ostringstream ostr; 292 std::ostringstream ostr;
293 ostr << wstr; 293 ostr << wstr;
294 EXPECT_EQ("Hello World", ostr.str()); 294 EXPECT_EQ("Hello World", ostr.str());
295 } 295 }
296 } // namespace nested_test 296 } // namespace nested_test
297 297
298 } // namespace 298 } // namespace
299 299
300 } // namespace logging 300 } // namespace logging
OLDNEW
« no previous file with comments | « base/logging.h ('k') | base/message_loop/incoming_task_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698