Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3022)

Unified Diff: base/stringprintf_unittest.cc

Issue 14749003: Stop overwriting errno in base::StringPrintf, StringAppendV, and StringToDouble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comment Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/stringprintf.cc ('k') | base/strings/string_number_conversions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/stringprintf_unittest.cc
diff --git a/base/stringprintf_unittest.cc b/base/stringprintf_unittest.cc
index 305d24a881fda67c28b478313d4477e519b78c8e..c04b17e4c7c0413a6f43f1bbfd29fec39512f6a6 100644
--- a/base/stringprintf_unittest.cc
+++ b/base/stringprintf_unittest.cc
@@ -2,6 +2,8 @@
// 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/basictypes.h"
#include "base/stringprintf.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -172,4 +174,14 @@ TEST(StringPrintfTest, PositionalParameters) {
#endif
}
+// Test that StringPrintf and StringAppendV do not change errno.
+TEST(StringPrintfTest, StringPrintfErrno) {
+ errno = 1;
+ EXPECT_EQ("", StringPrintf("%s", ""));
+ EXPECT_EQ(1, errno);
+ std::string out;
+ StringAppendVTestHelper(&out, "%d foo %s", 1, "bar");
+ EXPECT_EQ(1, errno);
+}
+
} // namespace base
« no previous file with comments | « base/stringprintf.cc ('k') | base/strings/string_number_conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698