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

Side by Side Diff: base/string_util_unittest.cc

Issue 197018: Strip .plugin off of Mac plugin names when showing the crash info bar. (Closed)
Patch Set: Add a test with the match in the middle Created 11 years, 3 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/string_util.cc ('k') | chrome/browser/tab_contents/tab_contents.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) 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 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 EXPECT_TRUE(StartsWith(L"javascript:url", L"javascript", false)); 1569 EXPECT_TRUE(StartsWith(L"javascript:url", L"javascript", false));
1570 EXPECT_TRUE(StartsWith(L"JavaScript:url", L"javascript", false)); 1570 EXPECT_TRUE(StartsWith(L"JavaScript:url", L"javascript", false));
1571 EXPECT_FALSE(StartsWith(L"java", L"javascript", true)); 1571 EXPECT_FALSE(StartsWith(L"java", L"javascript", true));
1572 EXPECT_FALSE(StartsWith(L"java", L"javascript", false)); 1572 EXPECT_FALSE(StartsWith(L"java", L"javascript", false));
1573 EXPECT_FALSE(StartsWith(L"", L"javascript", false)); 1573 EXPECT_FALSE(StartsWith(L"", L"javascript", false));
1574 EXPECT_FALSE(StartsWith(L"", L"javascript", true)); 1574 EXPECT_FALSE(StartsWith(L"", L"javascript", true));
1575 EXPECT_TRUE(StartsWith(L"java", L"", false)); 1575 EXPECT_TRUE(StartsWith(L"java", L"", false));
1576 EXPECT_TRUE(StartsWith(L"java", L"", true)); 1576 EXPECT_TRUE(StartsWith(L"java", L"", true));
1577 } 1577 }
1578 1578
1579 TEST(StringUtilTest, EndsWith) {
1580 EXPECT_TRUE(EndsWith(L"Foo.plugin", L".plugin", true));
1581 EXPECT_FALSE(EndsWith(L"Foo.Plugin", L".plugin", true));
1582 EXPECT_TRUE(EndsWith(L"Foo.plugin", L".plugin", false));
1583 EXPECT_TRUE(EndsWith(L"Foo.Plugin", L".plugin", false));
1584 EXPECT_FALSE(EndsWith(L".plug", L".plugin", true));
1585 EXPECT_FALSE(EndsWith(L".plug", L".plugin", false));
1586 EXPECT_FALSE(EndsWith(L"Foo.plugin Bar", L".plugin", true));
1587 EXPECT_FALSE(EndsWith(L"Foo.plugin Bar", L".plugin", false));
1588 EXPECT_FALSE(EndsWith(L"", L".plugin", false));
1589 EXPECT_FALSE(EndsWith(L"", L".plugin", true));
1590 EXPECT_TRUE(EndsWith(L"Foo.plugin", L"", false));
1591 EXPECT_TRUE(EndsWith(L"Foo.plugin", L"", true));
1592 }
Mark Mentovai 2009/09/04 18:09:00 I'd also add a few cases to test |str == search|,
1593
1579 TEST(StringUtilTest, GetStringFWithOffsets) { 1594 TEST(StringUtilTest, GetStringFWithOffsets) {
1580 std::vector<string16> subst; 1595 std::vector<string16> subst;
1581 subst.push_back(ASCIIToUTF16("1")); 1596 subst.push_back(ASCIIToUTF16("1"));
1582 subst.push_back(ASCIIToUTF16("2")); 1597 subst.push_back(ASCIIToUTF16("2"));
1583 std::vector<size_t> offsets; 1598 std::vector<size_t> offsets;
1584 1599
1585 ReplaceStringPlaceholders(ASCIIToUTF16("Hello, $1. Your number is $2."), 1600 ReplaceStringPlaceholders(ASCIIToUTF16("Hello, $1. Your number is $2."),
1586 subst, 1601 subst,
1587 &offsets); 1602 &offsets);
1588 EXPECT_EQ(2U, offsets.size()); 1603 EXPECT_EQ(2U, offsets.size());
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 } 1816 }
1802 } 1817 }
1803 1818
1804 TEST(StringUtilTest, HexEncode) { 1819 TEST(StringUtilTest, HexEncode) {
1805 std::string hex(HexEncode(NULL, 0)); 1820 std::string hex(HexEncode(NULL, 0));
1806 EXPECT_EQ(hex.length(), 0U); 1821 EXPECT_EQ(hex.length(), 0U);
1807 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81}; 1822 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81};
1808 hex = HexEncode(bytes, sizeof(bytes)); 1823 hex = HexEncode(bytes, sizeof(bytes));
1809 EXPECT_EQ(hex.compare("01FF02FE038081"), 0); 1824 EXPECT_EQ(hex.compare("01FF02FE038081"), 0);
1810 } 1825 }
OLDNEW
« no previous file with comments | « base/string_util.cc ('k') | chrome/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698