blob: 1666d7ae8dd432e8fdb23bc481fcb6d442801898 [file] [log] [blame]
Vitaly Bukacbed2062015-08-17 12:54:05 -07001// 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 Buka8750b272015-08-18 18:39:08 -07007#include <gtest/gtest.h>
8
Vitaly Bukacbed2062015-08-17 12:54:05 -07009#include "base/scoped_clear_errno.h"
Vitaly Bukacbed2062015-08-17 12:54:05 -070010
11namespace base {
12
13TEST(ScopedClearErrno, TestNoError) {
14 errno = 1;
15 {
16 ScopedClearErrno clear_error;
17 EXPECT_EQ(0, errno);
18 }
19 EXPECT_EQ(1, errno);
20}
21
22TEST(ScopedClearErrno, TestError) {
23 errno = 1;
24 {
25 ScopedClearErrno clear_error;
26 errno = 2;
27 }
28 EXPECT_EQ(2, errno);
29}
30
31} // namespace base