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

Unified Diff: base/test/logging_utils.cc

Issue 2638763004: Report CHECK/DCHECK to test launcher summary output. (Closed)
Patch Set: Fix review issues. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: base/test/logging_utils.cc
diff --git a/base/test/logging_utils.cc b/base/test/logging_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..79f04ac5580d43639faeff551c99d95a5be0e841
--- /dev/null
+++ b/base/test/logging_utils.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
Paweł Hajdan Jr. 2017/02/13 17:17:24 nit: No (c)
alex-ac 2017/02/14 10:34:27 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/test/logging_utils.h"
+
+#include <utility>
+
+namespace logging {
+
+namespace {
+
+// std::swap doesn't works with base::Callback.
Paweł Hajdan Jr. 2017/02/13 17:17:24 nit: doesn't works -> doesn't work
alex-ac 2017/02/14 10:34:27 Done.
+void SwapHandlers(LogAssertHandlerFunction* a, LogAssertHandlerFunction* b) {
+ LogAssertHandlerFunction temp = *a;
+ *a = *b;
+ *b = temp;
+}
+
+} // namespace
+
+ScopedLogAssertHandler::ScopedLogAssertHandler() {}
+
+ScopedLogAssertHandler::ScopedLogAssertHandler(LogAssertHandlerFunction handler)
+ : handler_(handler) {
+ if (handler_)
+ PushLogAssertHandler(handler);
+}
+
+ScopedLogAssertHandler::~ScopedLogAssertHandler() {
+ if (handler_)
+ PopLogAssertHandler();
+}
+
+ScopedLogAssertHandler::ScopedLogAssertHandler(ScopedLogAssertHandler&& other) {
+ SwapHandlers(&handler_, &other.handler_);
+}
+
+ScopedLogAssertHandler& ScopedLogAssertHandler::operator=(
+ ScopedLogAssertHandler&& other) {
+ ScopedLogAssertHandler temp_copy(std::move(other));
+ SwapHandlers(&handler_, &temp_copy.handler_);
+ return *this;
+}
+
+} // namespace logging

Powered by Google App Engine
This is Rietveld 408576698