• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7 #include <gtest/gtest.h>
8 
9 #include "base/scoped_clear_errno.h"
10 
11 namespace base {
12 
TEST(ScopedClearErrno,TestNoError)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 
TEST(ScopedClearErrno,TestError)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
32