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

Side by Side Diff: content/common/android/address_parser_unittest.cc

Issue 89243003: Move EmptyString, kWhitespace and the BOM to base. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/common/android/address_parser.h" 8 #include "content/common/android/address_parser.h"
9 #include "content/common/android/address_parser_internal.h" 9 #include "content/common/android/address_parser_internal.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 using namespace content::address_parser; 12 using namespace content::address_parser;
13 using namespace content::address_parser::internal; 13 using namespace content::address_parser::internal;
14 14
15 class AddressParserTest : public testing::Test { 15 class AddressParserTest : public testing::Test {
16 public: 16 public:
17 AddressParserTest() {} 17 AddressParserTest() {}
18 18
19 void TokenizeWords(const string16& content, WordList* words) const { 19 void TokenizeWords(const base::string16& content, WordList* words) const {
20 String16Tokenizer tokenizer(content.begin(), content.end(), 20 String16Tokenizer tokenizer(content.begin(), content.end(),
21 kWhitespaceUTF16); 21 base::kWhitespaceUTF16);
22 while (tokenizer.GetNext()) { 22 while (tokenizer.GetNext()) {
23 words->push_back(Word(tokenizer.token_begin(), tokenizer.token_end())); 23 words->push_back(Word(tokenizer.token_begin(), tokenizer.token_end()));
24 } 24 }
25 } 25 }
26 26
27 std::string GetHouseNumber(const std::string& content) const { 27 std::string GetHouseNumber(const std::string& content) const {
28 string16 content_16 = UTF8ToUTF16(content); 28 string16 content_16 = UTF8ToUTF16(content);
29 string16 result; 29 string16 result;
30 30
31 HouseNumberParser parser; 31 HouseNumberParser parser;
32 Word word; 32 Word word;
33 if (parser.Parse(content_16.begin(), content_16.end(), &word)) 33 if (parser.Parse(content_16.begin(), content_16.end(), &word))
34 result = string16(word.begin, word.end); 34 result = string16(word.begin, word.end);
35 return UTF16ToUTF8(result); 35 return UTF16ToUTF8(result);
36 } 36 }
37 37
38 bool ContainsHouseNumber(const std::string& content) const { 38 bool ContainsHouseNumber(const std::string& content) const {
39 return !GetHouseNumber(content).empty(); 39 return !GetHouseNumber(content).empty();
40 } 40 }
41 41
42 bool GetState(const std::string& state, size_t* state_index) const { 42 bool GetState(const std::string& state, size_t* state_index) const {
43 string16 state_16 = UTF8ToUTF16(state); 43 base::string16 state_16 = UTF8ToUTF16(state);
44 String16Tokenizer tokenizer(state_16.begin(), state_16.end(), 44 String16Tokenizer tokenizer(state_16.begin(), state_16.end(),
45 kWhitespaceUTF16); 45 base::kWhitespaceUTF16);
46 if (!tokenizer.GetNext()) 46 if (!tokenizer.GetNext())
47 return false; 47 return false;
48 48
49 size_t state_last_word; 49 size_t state_last_word;
50 WordList words; 50 WordList words;
51 words.push_back(Word(tokenizer.token_begin(), tokenizer.token_end())); 51 words.push_back(Word(tokenizer.token_begin(), tokenizer.token_end()));
52 return FindStateStartingInWord(&words, 0, &state_last_word, &tokenizer, 52 return FindStateStartingInWord(&words, 0, &state_last_word, &tokenizer,
53 state_index); 53 state_index);
54 } 54 }
55 55
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 EXPECT_TRUE(IsAddress("79th Street 1st Floor New York City, NY 10024-5192")); 585 EXPECT_TRUE(IsAddress("79th Street 1st Floor New York City, NY 10024-5192"));
586 586
587 EXPECT_FALSE(ContainsAddress("123 Fake Street, Springfield, Springfield")); 587 EXPECT_FALSE(ContainsAddress("123 Fake Street, Springfield, Springfield"));
588 EXPECT_FALSE(ContainsAddress("999 Street Avenue, City, ZZ 98765")); 588 EXPECT_FALSE(ContainsAddress("999 Street Avenue, City, ZZ 98765"));
589 EXPECT_FALSE(ContainsAddress("76 Here be dragons, CA 94043")); 589 EXPECT_FALSE(ContainsAddress("76 Here be dragons, CA 94043"));
590 EXPECT_FALSE(ContainsAddress("1 This, has, too* many, lines, to, be* valid")); 590 EXPECT_FALSE(ContainsAddress("1 This, has, too* many, lines, to, be* valid"));
591 EXPECT_FALSE(ContainsAddress( 591 EXPECT_FALSE(ContainsAddress(
592 "1 Supercalifragilisticexpialidocious is too long, CA 90000")); 592 "1 Supercalifragilisticexpialidocious is too long, CA 90000"));
593 EXPECT_FALSE(ContainsAddress("")); 593 EXPECT_FALSE(ContainsAddress(""));
594 } 594 }
OLDNEW
« no previous file with comments | « content/common/android/address_parser.cc ('k') | content/renderer/media/crypto/proxy_decryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698