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

Unified Diff: headless/public/util/error_reporter_unittest.cc

Issue 1867753005: headless: Add error reporter utility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK that path has no more components 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/public/util/error_reporter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/util/error_reporter_unittest.cc
diff --git a/headless/public/util/error_reporter_unittest.cc b/headless/public/util/error_reporter_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f23ced9ef2993bfd2a858f72ed2be270ae21bf7a
--- /dev/null
+++ b/headless/public/util/error_reporter_unittest.cc
@@ -0,0 +1,52 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "headless/public/util/error_reporter.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace headless {
+
+TEST(ErrorReporterTest, NoErrors) {
+ ErrorReporter reporter;
+ EXPECT_FALSE(reporter.HasErrors());
+ EXPECT_TRUE(reporter.errors().empty());
+}
+
+TEST(ErrorReporterTest, TopLevelErrors) {
+ ErrorReporter reporter;
+ reporter.AddError("instructions unclear");
+ reporter.AddError("head stuck in std::unordered_map");
+ EXPECT_TRUE(reporter.HasErrors());
+ EXPECT_EQ(2u, reporter.errors().size());
+ EXPECT_EQ("instructions unclear", reporter.errors()[0]);
+ EXPECT_EQ("head stuck in std::unordered_map", reporter.errors()[1]);
+}
+
+TEST(ErrorReporterTest, UnnamedContext) {
+ ErrorReporter reporter;
+ reporter.Push();
+ reporter.AddError("lp0 is on fire");
+ reporter.Pop();
+ EXPECT_TRUE(reporter.HasErrors());
+ EXPECT_EQ(1u, reporter.errors().size());
+ EXPECT_EQ("lp0 is on fire", reporter.errors()[0]);
+}
+
+TEST(ErrorReporterTest, NestedContexts) {
+ ErrorReporter reporter;
+ reporter.Push();
+ reporter.SetName("ship");
+ reporter.Push();
+ reporter.SetName("front");
+ reporter.AddError("fell off");
+ reporter.Pop();
+ reporter.AddError("uh oh");
+ reporter.Pop();
+ EXPECT_TRUE(reporter.HasErrors());
+ EXPECT_EQ(2u, reporter.errors().size());
+ EXPECT_EQ("ship.front: fell off", reporter.errors()[0]);
+ EXPECT_EQ("ship: uh oh", reporter.errors()[1]);
+}
+
+} // namespace headless
« no previous file with comments | « headless/public/util/error_reporter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698