| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |