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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/stringprintf.cc ('k') | base/strings/string_number_conversions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h>
6
5 #include "base/basictypes.h" 7 #include "base/basictypes.h"
6 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 10
9 namespace base { 11 namespace base {
10 12
11 namespace { 13 namespace {
12 14
13 // A helper for the StringAppendV test that follows. 15 // A helper for the StringAppendV test that follows.
14 // 16 //
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 SStringPrintf(&out, "%1$s %1$s", "test"); 167 SStringPrintf(&out, "%1$s %1$s", "test");
166 EXPECT_STREQ("test test", out.c_str()); 168 EXPECT_STREQ("test test", out.c_str());
167 169
168 #if defined(OS_WIN) 170 #if defined(OS_WIN)
169 std::wstring wout; 171 std::wstring wout;
170 SStringPrintf(&wout, L"%1$ls %1$ls", L"test"); 172 SStringPrintf(&wout, L"%1$ls %1$ls", L"test");
171 EXPECT_STREQ(L"test test", wout.c_str()); 173 EXPECT_STREQ(L"test test", wout.c_str());
172 #endif 174 #endif
173 } 175 }
174 176
177 // Test that StringPrintf and StringAppendV do not change errno.
178 TEST(StringPrintfTest, StringPrintfErrno) {
179 errno = 1;
180 EXPECT_EQ("", StringPrintf("%s", ""));
181 EXPECT_EQ(1, errno);
182 std::string out;
183 StringAppendVTestHelper(&out, "%d foo %s", 1, "bar");
184 EXPECT_EQ(1, errno);
185 }
186
175 } // namespace base 187 } // namespace base
OLDNEW
« 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