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 |