OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 | 6 |
7 #include "base/scoped_clear_errno.h" | 7 #include "base/scoped_clear_errno.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/googletest/include/gtest/gtest.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
11 | 11 |
12 TEST(ScopedClearErrno, TestNoError) { | 12 TEST(ScopedClearErrno, TestNoError) { |
13 errno = 1; | 13 errno = 1; |
14 { | 14 { |
15 ScopedClearErrno clear_error; | 15 ScopedClearErrno clear_error; |
16 EXPECT_EQ(0, errno); | 16 EXPECT_EQ(0, errno); |
17 } | 17 } |
18 EXPECT_EQ(1, errno); | 18 EXPECT_EQ(1, errno); |
19 } | 19 } |
20 | 20 |
21 TEST(ScopedClearErrno, TestError) { | 21 TEST(ScopedClearErrno, TestError) { |
22 errno = 1; | 22 errno = 1; |
23 { | 23 { |
24 ScopedClearErrno clear_error; | 24 ScopedClearErrno clear_error; |
25 errno = 2; | 25 errno = 2; |
26 } | 26 } |
27 EXPECT_EQ(2, errno); | 27 EXPECT_EQ(2, errno); |
28 } | 28 } |
29 | 29 |
30 } // namespace base | 30 } // namespace base |
OLD | NEW |