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

Side by Side Diff: chrome/browser/autofill/form_field_unittest.cc

Issue 8687002: Cleanup: Convert ASCIIToUTF16("") to string16(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/string16.h"
5 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
6 #include "chrome/browser/autofill/autofill_field.h" 7 #include "chrome/browser/autofill/autofill_field.h"
7 #include "chrome/browser/autofill/form_field.h" 8 #include "chrome/browser/autofill/form_field.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 TEST(FormFieldTest, Match) { 11 TEST(FormFieldTest, Match) {
11 AutofillField field; 12 AutofillField field;
12 13
13 // Empty strings match. 14 // Empty strings match.
14 EXPECT_TRUE(FormField::Match(&field, string16(), FormField::MATCH_LABEL)); 15 EXPECT_TRUE(FormField::Match(&field, string16(), FormField::MATCH_LABEL));
15 16
16 // Empty pattern matches non-empty string. 17 // Empty pattern matches non-empty string.
17 field.label = ASCIIToUTF16("a"); 18 field.label = ASCIIToUTF16("a");
18 EXPECT_TRUE(FormField::Match(&field, string16(), FormField::MATCH_LABEL)); 19 EXPECT_TRUE(FormField::Match(&field, string16(), FormField::MATCH_LABEL));
19 20
20 // Strictly empty pattern matches empty string. 21 // Strictly empty pattern matches empty string.
21 field.label = ASCIIToUTF16(""); 22 field.label = string16();
22 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^$"), 23 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^$"),
23 FormField::MATCH_LABEL)); 24 FormField::MATCH_LABEL));
24 25
25 // Strictly empty pattern does not match non-empty string. 26 // Strictly empty pattern does not match non-empty string.
26 field.label = ASCIIToUTF16("a"); 27 field.label = ASCIIToUTF16("a");
27 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^$"), 28 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^$"),
28 FormField::MATCH_LABEL)); 29 FormField::MATCH_LABEL));
29 30
30 // Non-empty pattern doesn't match empty string. 31 // Non-empty pattern doesn't match empty string.
31 field.label = string16(); 32 field.label = string16();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 field.label = ASCIIToUTF16("contains word:"); 107 field.label = ASCIIToUTF16("contains word:");
107 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("\\bword\\b"), 108 EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("\\bword\\b"),
108 FormField::MATCH_LABEL)); 109 FormField::MATCH_LABEL));
109 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcon\\b"), 110 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcon\\b"),
110 FormField::MATCH_LABEL)); 111 FormField::MATCH_LABEL));
111 // Make sure the circumflex in 'crepe' is not treated as a word boundary. 112 // Make sure the circumflex in 'crepe' is not treated as a word boundary.
112 field.label = UTF8ToUTF16("cr" "\xC3\xAA" "pe"); 113 field.label = UTF8ToUTF16("cr" "\xC3\xAA" "pe");
113 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcr\\b"), 114 EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("\\bcr\\b"),
114 FormField::MATCH_LABEL)); 115 FormField::MATCH_LABEL));
115 } 116 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/address_field_unittest.cc ('k') | chrome/browser/autofill/phone_number_i18n_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698