Don't preload rarely seen large images
[chromium-blink-merge.git] / components / autofill / core / common / autofill_regexes_unittest.cc
blob954a7e865bb485b0051f18ae3a2e0240fd7f178c
1 // Copyright 2013 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.
5 #include "components/autofill/core/common/autofill_regexes.h"
7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "components/autofill/core/browser/autofill_regex_constants.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 using base::ASCIIToUTF16;
14 namespace autofill {
16 TEST(AutofillRegexesTest, AutofillRegexes) {
17 struct TestCase {
18 const char* const input;
19 const char* const pattern;
22 const TestCase kPositiveCases[] = {
23 // Empty pattern
24 {"", ""},
25 {"Look, ma' -- a non-empty string!", ""},
26 // Substring
27 {"string", "tri"},
28 // Substring at beginning
29 {"string", "str"},
30 {"string", "^str"},
31 // Substring at end
32 {"string", "ring"},
33 {"string", "ring$"},
34 // Case-insensitive
35 {"StRiNg", "string"},
37 for (size_t i = 0; i < arraysize(kPositiveCases); ++i) {
38 const TestCase& test_case = kPositiveCases[i];
39 SCOPED_TRACE(test_case.input);
40 SCOPED_TRACE(test_case.pattern);
41 EXPECT_TRUE(autofill::MatchesPattern(ASCIIToUTF16(test_case.input),
42 ASCIIToUTF16(test_case.pattern)));
45 const TestCase kNegativeCases[] = {
46 // Empty string
47 {"", "Look, ma' -- a non-empty pattern!"},
48 // Substring
49 {"string", "trn"},
50 // Substring at beginning
51 {"string", " str"},
52 {"string", "^tri"},
53 // Substring at end
54 {"string", "ring "},
55 {"string", "rin$"},
57 for (size_t i = 0; i < arraysize(kNegativeCases); ++i) {
58 const TestCase& test_case = kNegativeCases[i];
59 SCOPED_TRACE(test_case.input);
60 SCOPED_TRACE(test_case.pattern);
61 EXPECT_FALSE(autofill::MatchesPattern(ASCIIToUTF16(test_case.input),
62 ASCIIToUTF16(test_case.pattern)));
66 } // namespace autofill