chromium/components/autofill/core/browser/form_parsing/regex_patterns_unittest.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill/core/browser/form_parsing/regex_patterns.h"

// Keep these tests in sync with
// components/autofill/core/browser/autofill_regexes_unittest.cc.
// Only these tests will be kept once the pattern provider launches.

#include <string>
#include <string_view>
#include <vector>

#include "base/containers/flat_set.h"
#include "base/logging.h"
#include "base/ranges/ranges.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/form_parsing/buildflags.h"
#include "components/autofill/core/browser/form_parsing/regex_patterns_inl.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_regexes.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

Contains;
Each;
ElementsAre;
ElementsAreArray;
IsSupersetOf;
Not;
UnorderedElementsAreArray;

namespace autofill {

class MatchPatternRefTestApi {};

namespace {

MatchPatternRefTestApi test_api(MatchPatternRef p) {}

auto Matches(std::u16string_view regex) {}

auto Matches(MatchingPattern pattern) {}

auto Matches(MatchPatternRef pattern_ref) {}

// Matches if the actual value matches any of the `pattern_refs`.
auto MatchesAny(base::span<const MatchPatternRef> pattern_refs) {}

const auto IsSupplementary =;

bool IsEmpty(const char* s) {}

}  // namespace

bool operator==(MatchPatternRef a, MatchPatternRef b) {}

bool operator!=(MatchPatternRef a, MatchPatternRef b) {}

void PrintTo(MatchPatternRef p, std::ostream* os) {}

// The parameter is the PatternSource to pass to GetMatchPatterns().
class RegexPatternsTest : public testing::TestWithParam<PatternSource> {};

INSTANTIATE_TEST_SUITE_P();

// The parameter is the index of a MatchPatternRef.
class MatchPatternRefInternalsTest
    : public ::testing::TestWithParam<MatchPatternRefTestApi::UnderlyingType> {};

INSTANTIATE_TEST_SUITE_P();

// Tests MatchPatternRef's index() and is_supplementary().
TEST_P(MatchPatternRefInternalsTest, MatchPatternRef) {}

// Tests MatchPatternRef's dereference operator.
//
// Since we want to test that supplementary patterns only contain
// MatchAttribute::kName, choose `index` such that `kPatterns[0]` contains
// MatchAttribute::kLabel.
TEST_F(RegexPatternsTest, MatchPatternRefDereference) {}

TEST_F(RegexPatternsTest, IsSupportedLanguageCode) {}

// Tests that for a given pattern name, the pseudo-language-code "" contains the
// patterns of all real languages.
TEST_P(RegexPatternsTest, PseudoLanguageIsUnionOfLanguages) {}

// Tests that for a given pattern name, if the language doesn't isn't known we
// use the union of all patterns.
TEST_P(RegexPatternsTest, FallbackToPseudoLanguageIfLanguageDoesNotExist) {}

// Tests that for a given pattern name, the non-English languages are
// supplemented with the English patterns.
TEST_P(RegexPatternsTest,
       EnglishPatternsAreAddedToOtherLanguagesAsSupplementaryPatterns) {}

struct PatternTestCase {};

class RegexPatternsTestWithSamples
    : public testing::TestWithParam<PatternTestCase> {};

TEST_P(RegexPatternsTestWithSamples, TestPositiveAndNegativeCases) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace autofill