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

Side by Side Diff: base/string_util_unittest.cc

Issue 6043: Added dangerous download prompting. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <math.h> 5 #include <math.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 { L"%f %d %o %u", true }, 1373 { L"%f %d %o %u", true },
1374 { L"%-8d (%02.1f%)", true }, 1374 { L"%-8d (%02.1f%)", true },
1375 { L"% 10s", false }, 1375 { L"% 10s", false },
1376 { L"% 10ls", true } 1376 { L"% 10ls", true }
1377 }; 1377 };
1378 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 1378 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
1379 EXPECT_EQ(cases[i].portable, base::IsWprintfFormatPortable(cases[i].input)); 1379 EXPECT_EQ(cases[i].portable, base::IsWprintfFormatPortable(cases[i].input));
1380 } 1380 }
1381 } 1381 }
1382 1382
1383 TEST(StringUtilTest, ElideString) {
1384 struct TestData {
1385 const wchar_t* input;
1386 int max_len;
1387 bool result;
1388 const wchar_t* output;
1389 } cases[] = {
1390 { L"Hello", 0, true, L"" },
1391 { L"", 0, false, L"" },
1392 { L"Hello, my name is Tom", 1, true, L"H" },
1393 { L"Hello, my name is Tom", 2, true, L"He" },
1394 { L"Hello, my name is Tom", 3, true, L"H.m" },
1395 { L"Hello, my name is Tom", 4, true, L"H..m" },
1396 { L"Hello, my name is Tom", 5, true, L"H...m" },
1397 { L"Hello, my name is Tom", 6, true, L"He...m" },
1398 { L"Hello, my name is Tom", 7, true, L"He...om" },
1399 { L"Hello, my name is Tom", 10, true, L"Hell...Tom" },
1400 { L"Hello, my name is Tom", 100, false, L"Hello, my name is Tom" }
1401 };
1402 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
1403 std::wstring output;
1404 EXPECT_EQ(cases[i].result,
1405 ElideString(cases[i].input, cases[i].max_len, &output));
1406 EXPECT_TRUE(output == cases[i].output);
1407 }
1408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698