| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 "files/public/c/lib/util.h" | |
| 6 | |
| 7 #include "files/public/interfaces/types.mojom.h" | |
| 8 #include "mojo/public/cpp/system/macros.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace mojio { | |
| 12 namespace { | |
| 13 | |
| 14 // TODO(vtl): This test is pretty lame until |mojo::files::Error| can also | |
| 15 // encapsulate "real" errno values. | |
| 16 TEST(UtilTest, ErrorToErrno) { | |
| 17 const struct ExpectedMapping { | |
| 18 mojo::files::Error from; | |
| 19 int to; | |
| 20 } kExpectedMappings[] = { | |
| 21 {mojo::files::Error::OK, 0}, | |
| 22 {mojo::files::Error::UNKNOWN, EIO}, | |
| 23 {mojo::files::Error::INVALID_ARGUMENT, EINVAL}, | |
| 24 {mojo::files::Error::PERMISSION_DENIED, EACCES}, | |
| 25 {mojo::files::Error::OUT_OF_RANGE, EINVAL}, | |
| 26 {mojo::files::Error::UNIMPLEMENTED, ENOSYS}, | |
| 27 {mojo::files::Error::CLOSED, EBADF}, | |
| 28 {mojo::files::Error::UNAVAILABLE, EACCES}, | |
| 29 {mojo::files::Error::INTERNAL, EIO}, | |
| 30 }; | |
| 31 | |
| 32 for (size_t i = 0; i < MOJO_ARRAYSIZE(kExpectedMappings); i++) { | |
| 33 const ExpectedMapping& m = kExpectedMappings[i]; | |
| 34 EXPECT_EQ(m.to, ErrorToErrno(m.from)) << "i=" << i << ", m.from=" << m.from; | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 } // namespace | |
| 39 } // namespace mojio | |
| OLD | NEW |