summaryrefslogtreecommitdiffstats
path: root/base/scoped_clear_errno_unittest.cc
diff options
context:
space:
mode:
authoryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-02 23:06:26 +0000
committeryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-02 23:06:26 +0000
commit34d58a296e3b0d3f81f4692a48bc54ec3128c850 (patch)
treefb059cdc70f298603e3a05fc037008571be2e776 /base/scoped_clear_errno_unittest.cc
parent256513322f97e767c51012f3fb69321e2169b885 (diff)
downloadchromium_src-34d58a296e3b0d3f81f4692a48bc54ec3128c850.zip
chromium_src-34d58a296e3b0d3f81f4692a48bc54ec3128c850.tar.gz
chromium_src-34d58a296e3b0d3f81f4692a48bc54ec3128c850.tar.bz2
Stop overwriting errno in base::StringPrintf, StringAppendV, and StringToDouble.
BUG=None TEST=new tests added Review URL: https://chromiumcodereview.appspot.com/14749003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198001 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/scoped_clear_errno_unittest.cc')
-rw-r--r--base/scoped_clear_errno_unittest.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/base/scoped_clear_errno_unittest.cc b/base/scoped_clear_errno_unittest.cc
new file mode 100644
index 0000000..8afb33e
--- /dev/null
+++ b/base/scoped_clear_errno_unittest.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <errno.h>
+
+#include "base/scoped_clear_errno.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace base {
+
+TEST(ScopedClearErrno, TestNoError) {
+ errno = 1;
+ {
+ ScopedClearErrno clear_error;
+ EXPECT_EQ(0, errno);
+ }
+ EXPECT_EQ(1, errno);
+}
+
+TEST(ScopedClearErrno, TestError) {
+ errno = 1;
+ {
+ ScopedClearErrno clear_error;
+ errno = 2;
+ }
+ EXPECT_EQ(2, errno);
+}
+
+} // namespace base