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

Side by Side Diff: base/strings/stringprintf_unittest.cc

Issue 902643002: Revert "Enable positional parameters for base::vsnprintf and base::vswprintf on Windows." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: extension Created 5 years, 10 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
« no previous file with comments | « base/strings/string_util_win.h ('k') | chrome/installer/setup/install.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 wchar_t invalid[2]; 156 wchar_t invalid[2];
157 invalid[0] = 0xffff; 157 invalid[0] = 0xffff;
158 invalid[1] = 0; 158 invalid[1] = 0;
159 159
160 std::wstring out; 160 std::wstring out;
161 SStringPrintf(&out, L"%ls", invalid); 161 SStringPrintf(&out, L"%ls", invalid);
162 EXPECT_STREQ(L"", out.c_str()); 162 EXPECT_STREQ(L"", out.c_str());
163 } 163 }
164 #endif 164 #endif
165 165
166 // Test that the positional parameters work.
167 TEST(StringPrintfTest, PositionalParameters) {
168 std::string out;
169 SStringPrintf(&out, "%1$s %1$s", "test");
170 EXPECT_STREQ("test test", out.c_str());
171
172 #if defined(OS_WIN)
173 std::wstring wout;
174 SStringPrintf(&wout, L"%1$ls %1$ls", L"test");
175 EXPECT_STREQ(L"test test", wout.c_str());
176 #endif
177 }
178
179 // Test that StringPrintf and StringAppendV do not change errno. 166 // Test that StringPrintf and StringAppendV do not change errno.
180 TEST(StringPrintfTest, StringPrintfErrno) { 167 TEST(StringPrintfTest, StringPrintfErrno) {
181 errno = 1; 168 errno = 1;
182 EXPECT_EQ("", StringPrintf("%s", "")); 169 EXPECT_EQ("", StringPrintf("%s", ""));
183 EXPECT_EQ(1, errno); 170 EXPECT_EQ(1, errno);
184 std::string out; 171 std::string out;
185 StringAppendVTestHelper(&out, "%d foo %s", 1, "bar"); 172 StringAppendVTestHelper(&out, "%d foo %s", 1, "bar");
186 EXPECT_EQ(1, errno); 173 EXPECT_EQ(1, errno);
187 } 174 }
188 175
189 } // namespace base 176 } // namespace base
OLDNEW
« no previous file with comments | « base/strings/string_util_win.h ('k') | chrome/installer/setup/install.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698