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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « headless/public/util/error_reporter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "headless/public/util/error_reporter.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace headless {
9
10 TEST(ErrorReporterTest, NoErrors) {
11 ErrorReporter reporter;
12 EXPECT_FALSE(reporter.HasErrors());
13 EXPECT_TRUE(reporter.errors().empty());
14 }
15
16 TEST(ErrorReporterTest, TopLevelErrors) {
17 ErrorReporter reporter;
18 reporter.AddError("instructions unclear");
19 reporter.AddError("head stuck in std::unordered_map");
20 EXPECT_TRUE(reporter.HasErrors());
21 EXPECT_EQ(2u, reporter.errors().size());
22 EXPECT_EQ("instructions unclear", reporter.errors()[0]);
23 EXPECT_EQ("head stuck in std::unordered_map", reporter.errors()[1]);
24 }
25
26 TEST(ErrorReporterTest, UnnamedContext) {
27 ErrorReporter reporter;
28 reporter.Push();
29 reporter.AddError("lp0 is on fire");
30 reporter.Pop();
31 EXPECT_TRUE(reporter.HasErrors());
32 EXPECT_EQ(1u, reporter.errors().size());
33 EXPECT_EQ("lp0 is on fire", reporter.errors()[0]);
34 }
35
36 TEST(ErrorReporterTest, NestedContexts) {
37 ErrorReporter reporter;
38 reporter.Push();
39 reporter.SetName("ship");
40 reporter.Push();
41 reporter.SetName("front");
42 reporter.AddError("fell off");
43 reporter.Pop();
44 reporter.AddError("uh oh");
45 reporter.Pop();
46 EXPECT_TRUE(reporter.HasErrors());
47 EXPECT_EQ(2u, reporter.errors().size());
48 EXPECT_EQ("ship.front: fell off", reporter.errors()[0]);
49 EXPECT_EQ("ship: uh oh", reporter.errors()[1]);
50 }
51
52 } // namespace headless
OLDNEW
« 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