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/browser/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"
14 TEST(AutofillRegexesTest, AutofillRegexes) {
16 const char* const input;
17 const char* const pattern;
20 const TestCase kPositiveCases[] = {
23 {"Look, ma' -- a non-empty string!", ""},
26 // Substring at beginning
35 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPositiveCases); ++i) {
36 const TestCase& test_case = kPositiveCases[i];
37 SCOPED_TRACE(test_case.input);
38 SCOPED_TRACE(test_case.pattern);
39 EXPECT_TRUE(autofill::MatchesPattern(ASCIIToUTF16(test_case.input),
40 ASCIIToUTF16(test_case.pattern)));
43 const TestCase kNegativeCases[] = {
45 {"", "Look, ma' -- a non-empty pattern!"},
48 // Substring at beginning
55 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kNegativeCases); ++i) {
56 const TestCase& test_case = kNegativeCases[i];
57 SCOPED_TRACE(test_case.input);
58 SCOPED_TRACE(test_case.pattern);
59 EXPECT_FALSE(autofill::MatchesPattern(ASCIIToUTF16(test_case.input),
60 ASCIIToUTF16(test_case.pattern)));
64 } // namespace autofill