| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/title_chomper.h" | |
| 6 #include "googleurl/src/gurl.h" | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 class TitleChomperTest : public testing::Test { | |
| 10 }; | |
| 11 | |
| 12 TEST_F(TitleChomperTest, BasicCase) { | |
| 13 TitleChomper chomper; | |
| 14 chomper.AddTitle(L"A"); | |
| 15 chomper.AddTitle(L"A B"); | |
| 16 chomper.AddTitle(L"A B C"); | |
| 17 chomper.AddTitle(L"A B C D"); | |
| 18 | |
| 19 std::vector<std::wstring> chomped_titles; | |
| 20 chomper.ChompTitles(&chomped_titles); | |
| 21 | |
| 22 EXPECT_EQ(L"A", chomped_titles.at(0)); | |
| 23 EXPECT_EQ(L"B", chomped_titles.at(1)); | |
| 24 EXPECT_EQ(L"C", chomped_titles.at(2)); | |
| 25 EXPECT_EQ(L"D", chomped_titles.at(3)); | |
| 26 } | |
| 27 | |
| 28 TEST_F(TitleChomperTest, LongerTitleBasicCase) { | |
| 29 TitleChomper chomper; | |
| 30 chomper.AddTitle(L"A Q"); | |
| 31 chomper.AddTitle(L"A B Q"); | |
| 32 chomper.AddTitle(L"A B C Q"); | |
| 33 chomper.AddTitle(L"A B C D Q"); | |
| 34 | |
| 35 std::vector<std::wstring> chomped_titles; | |
| 36 chomper.ChompTitles(&chomped_titles); | |
| 37 | |
| 38 EXPECT_EQ(L"A Q", chomped_titles.at(0)); | |
| 39 EXPECT_EQ(L"B Q", chomped_titles.at(1)); | |
| 40 EXPECT_EQ(L"C Q", chomped_titles.at(2)); | |
| 41 EXPECT_EQ(L"D Q", chomped_titles.at(3)); | |
| 42 } | |
| 43 | |
| 44 TEST_F(TitleChomperTest, PunctuationCase) { | |
| 45 TitleChomper chomper; | |
| 46 // There should be able to be wacky punctuation and it should still work | |
| 47 chomper.AddTitle(L"A, Q."); | |
| 48 chomper.AddTitle(L"A, B:- Q."); | |
| 49 chomper.AddTitle(L"A, B:- C; Q"); | |
| 50 chomper.AddTitle(L"A B. C D; Q"); | |
| 51 | |
| 52 std::vector<std::wstring> chomped_titles; | |
| 53 chomper.ChompTitles(&chomped_titles); | |
| 54 | |
| 55 EXPECT_EQ(L"A, Q.", chomped_titles.at(0)); | |
| 56 EXPECT_EQ(L"B:- Q.", chomped_titles.at(1)); | |
| 57 EXPECT_EQ(L"C; Q", chomped_titles.at(2)); | |
| 58 EXPECT_EQ(L"D; Q", chomped_titles.at(3)); | |
| 59 } | |
| 60 | |
| 61 TEST_F(TitleChomperTest, IdentiticalTitleCase) { | |
| 62 TitleChomper chomper; | |
| 63 chomper.AddTitle(L"A Q"); | |
| 64 chomper.AddTitle(L"A Q"); | |
| 65 chomper.AddTitle(L"A B C Q"); | |
| 66 chomper.AddTitle(L"A B C Q"); | |
| 67 chomper.AddTitle(L"A B C Q"); | |
| 68 | |
| 69 std::vector<std::wstring> chomped_titles; | |
| 70 chomper.ChompTitles(&chomped_titles); | |
| 71 | |
| 72 EXPECT_EQ(L"A Q", chomped_titles.at(0)); | |
| 73 EXPECT_EQ(L"A Q", chomped_titles.at(1)); | |
| 74 EXPECT_EQ(L"A B C Q", chomped_titles.at(2)); | |
| 75 EXPECT_EQ(L"A B C Q", chomped_titles.at(3)); | |
| 76 EXPECT_EQ(L"A B C Q", chomped_titles.at(4)); | |
| 77 } | |
| 78 | |
| 79 TEST_F(TitleChomperTest, CraigslistCase) { | |
| 80 TitleChomper chomper; | |
| 81 chomper.AddTitle(L"craigslist: san francisco bay area classifieds for jobs, ap
artments, personals, for sale, services, community, and events"); | |
| 82 chomper.AddTitle(L"craigslist | cars & trucks"); | |
| 83 chomper.AddTitle(L"s.f. bayarea craigslist > > cars & trucks: search"); | |
| 84 chomper.AddTitle(L"s.f. bayarea craigslist > peninsula > cars & trucks: search
"); | |
| 85 chomper.AddTitle(L"s.f. bayarea craigslist > peninsula > cars & trucks: search
for \"tacoma\""); | |
| 86 | |
| 87 std::vector<std::wstring> chomped_titles; | |
| 88 chomper.ChompTitles(&chomped_titles); | |
| 89 | |
| 90 EXPECT_EQ(L"craigslist: san francisco bay area classifieds for jobs, apartment
s, personals, for sale, services, community, and events", chomped_titles.at(0)); | |
| 91 EXPECT_EQ(L"cars & trucks", chomped_titles.at(1)); | |
| 92 EXPECT_EQ(L"s.f. bayarea craigslist > > cars & trucks: search", chomped_title
s.at(2)); | |
| 93 EXPECT_EQ(L"peninsula > cars & trucks: search", chomped_titles.at(3)); | |
| 94 EXPECT_EQ(L"for \"tacoma\"", chomped_titles.at(4)); | |
| 95 } | |
| OLD | NEW |