This source file includes following definitions.
- TEST
#include "components/autofill/core/browser/autofill_regexes.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_regex_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::ASCIIToUTF16;
namespace autofill {
TEST(AutofillRegexesTest, AutofillRegexes) {
struct TestCase {
const char* const input;
const char* const pattern;
};
const TestCase kPositiveCases[] = {
{"", ""},
{"Look, ma' -- a non-empty string!", ""},
{"string", "tri"},
{"string", "str"},
{"string", "^str"},
{"string", "ring"},
{"string", "ring$"},
{"StRiNg", "string"},
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPositiveCases); ++i) {
const TestCase& test_case = kPositiveCases[i];
SCOPED_TRACE(test_case.input);
SCOPED_TRACE(test_case.pattern);
EXPECT_TRUE(autofill::MatchesPattern(ASCIIToUTF16(test_case.input),
ASCIIToUTF16(test_case.pattern)));
}
const TestCase kNegativeCases[] = {
{"", "Look, ma' -- a non-empty pattern!"},
{"string", "trn"},
{"string", " str"},
{"string", "^tri"},
{"string", "ring "},
{"string", "rin$"},
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kNegativeCases); ++i) {
const TestCase& test_case = kNegativeCases[i];
SCOPED_TRACE(test_case.input);
SCOPED_TRACE(test_case.pattern);
EXPECT_FALSE(autofill::MatchesPattern(ASCIIToUTF16(test_case.input),
ASCIIToUTF16(test_case.pattern)));
}
}
}