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

Side by Side Diff: base/stringprintf_unittest.cc

Issue 9702002: Enable positional parameters for base::vsnprintf and base::vswprintf on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NULL terminate the beginning of the buffer in case of a failure + a unit test. Created 8 years, 9 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/string_util_win.h ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/stringprintf.h" 6 #include "base/stringprintf.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace base { 9 namespace base {
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 wchar_t invalid[2]; 142 wchar_t invalid[2];
143 invalid[0] = 0xffff; 143 invalid[0] = 0xffff;
144 invalid[1] = 0; 144 invalid[1] = 0;
145 145
146 std::wstring out; 146 std::wstring out;
147 SStringPrintf(&out, L"%ls", invalid); 147 SStringPrintf(&out, L"%ls", invalid);
148 EXPECT_STREQ(L"", out.c_str()); 148 EXPECT_STREQ(L"", out.c_str());
149 } 149 }
150 #endif 150 #endif
151 151
152 // Test that the positional parameters work.
153 TEST(StringPrintfTest, PositionalParameters) {
154 std::string out;
155 SStringPrintf(&out, "%1$s %1$s", "test");
156 EXPECT_STREQ("test test", out.c_str());
157
158 #if defined(OS_WIN)
159 std::wstring wout;
160 SStringPrintf(&wout, L"%1$ls %1$ls", L"test");
161 EXPECT_STREQ(L"test test", wout.c_str());
162 #endif
163 }
164
152 } // namespace base 165 } // namespace base
OLDNEW
« no previous file with comments | « base/string_util_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698