• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium OS 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 <brillo/errors/error_codes.h>
6 
7 #include <gtest/gtest.h>
8 
9 using brillo::errors::system::AddSystemError;
10 
TEST(SystemErrorCodes,AddTo)11 TEST(SystemErrorCodes, AddTo) {
12   brillo::ErrorPtr error;
13 
14   AddSystemError(&error, FROM_HERE, ENOENT);
15   EXPECT_EQ(brillo::errors::system::kDomain, error->GetDomain());
16   EXPECT_EQ("ENOENT", error->GetCode());
17   EXPECT_EQ("No such file or directory", error->GetMessage());
18   error.reset();
19 
20   AddSystemError(&error, FROM_HERE, EPROTO);
21   EXPECT_EQ(brillo::errors::system::kDomain, error->GetDomain());
22   EXPECT_EQ("EPROTO", error->GetCode());
23   EXPECT_EQ("Protocol error", error->GetMessage());
24   error.reset();
25 }
26 
TEST(SystemErrorCodes,AddTo_UnknownError)27 TEST(SystemErrorCodes, AddTo_UnknownError) {
28   brillo::ErrorPtr error;
29   AddSystemError(&error, FROM_HERE, 10000);
30   EXPECT_EQ(brillo::errors::system::kDomain, error->GetDomain());
31   EXPECT_EQ("error_10000", error->GetCode());
32   EXPECT_EQ("Unknown error 10000", error->GetMessage());
33 }
34