Vitaly Buka | cbed206 | 2015-08-17 12:54:05 -0700 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <errno.h> |
| 6 | |
Vitaly Buka | 8750b27 | 2015-08-18 18:39:08 -0700 | [diff] [blame] | 7 | #include <gtest/gtest.h> |
| 8 | |
Vitaly Buka | cbed206 | 2015-08-17 12:54:05 -0700 | [diff] [blame] | 9 | #include "base/scoped_clear_errno.h" |
Vitaly Buka | cbed206 | 2015-08-17 12:54:05 -0700 | [diff] [blame] | 10 | |
| 11 | namespace base { |
| 12 | |
| 13 | TEST(ScopedClearErrno, TestNoError) { |
| 14 | errno = 1; |
| 15 | { |
| 16 | ScopedClearErrno clear_error; |
| 17 | EXPECT_EQ(0, errno); |
| 18 | } |
| 19 | EXPECT_EQ(1, errno); |
| 20 | } |
| 21 | |
| 22 | TEST(ScopedClearErrno, TestError) { |
| 23 | errno = 1; |
| 24 | { |
| 25 | ScopedClearErrno clear_error; |
| 26 | errno = 2; |
| 27 | } |
| 28 | EXPECT_EQ(2, errno); |
| 29 | } |
| 30 | |
| 31 | } // namespace base |